Hy (programming language)

{{Short description|Dialect of the Lisp programming language designed to interact with Python}}

{{Infobox programming language

| name = Hy

| logo = Hy Cuddles.png

| logo caption = Hy logo – Cuddles the cuttlefish

| screenshot =

| screenshot caption =

| paradigm = Multi-paradigm: procedural, functional, object-oriented, meta, reflective, generic

| family = Lisp

| designer = Paul Tagliamonte

| developers = Core team

| released = {{Start date and age|2013|df=yes}}

| latest release version = {{wikidata|property|edit|reference|P348}}

| latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}}

| typing =

| scope = lexical, optionally dynamic{{citation needed |date=July 2017}}

| programming language =

| platform = IA-32, x86-64

| operating system = Cross-platform

| license = MIT-style

| file ext = .hy

| file format =

| website = {{URL|hylang.org}}

| implementations =

| dialects =

| influenced by = Kawa, Clojure, Common Lisp

| influenced =

}}

Hy is a dialect of the Lisp programming language designed to interact with Python by translating s-expressions into Python's abstract syntax tree (AST).{{Cite book|last1=Jaworski|first1=Michał|url=https://www.worldcat.org/oclc/1125343555|title=Expert Python programming|last2=Ziadé|first2=Tarek|publisher=Packt Publishing|year=2019|isbn=978-1-78980-677-9|edition=Third|location=Birmingham, U.K.|pages=173|oclc=1125343555}}{{Cite book|title=Serious Python: black-belt advice on deployment, scalability, testing, and more|last=Danjou|first=Julien|publisher=No Starch Press|year=2018|isbn=9781593278793|location=San Francisco, CA|pages=145–149|oclc=1057729260}} Hy was introduced at Python Conference (PyCon) 2013 by Paul Tagliamonte.{{cite speech |title=PyCon lightning talk |last=Tagliamonte |first=Paul |date=2 April 2013 |location=Santa Clara |url=http://blog.pault.ag/day/2013/04/02 |access-date=2 September 2014 |event=Python Conference (PyCon)}} Lisp allows operating on code as data (metaprogramming), thus Hy can be used to write domain-specific languages.{{cite speech |title=Getting Hy on Python: How to implement a Lisp front-end to Python |last=Tagliamonte |first=Paul |date=11 April 2014 |location=Montreal |url=https://us.pycon.org/2014/schedule/presentation/192/ |access-date=2 September 2014 |event=PyCon}}

Similar to Kawa's and Clojure's mappings onto the Java virtual machine (JVM),{{cite news |last1=Turto |first1=Tuukka |title=Programming Can Be Fun with Hy |url=http://www.opensourceforu.com/2014/02/programming-can-fun-hy/ |access-date=2 September 2014 |work=Open Source For You |date=14 February 2014}}{{Cite book |last=Watson |first=Mark |url=https://markwatson.com/opencontent/hy-lisp-python.pdf |title=A Lisp Programmer Living in Python-Land: The Hy Programming Language |publisher=LeanBooks |year=2020}} Hy is meant to operate as a transparent Lisp front-end for Python.{{cite web |last=Edge |first=Jake |title=Getting Hy on Python |url=https://lwn.net/Articles/596626/ |access-date=2 September 2014 |date=30 April 2014 |website=LWN.net}} It allows Python libraries, including the standard library, to be imported and accessed alongside Hy code with a compilingThe term "compiled" may apply to expressing Hy code in Python's AST or converting that AST into bytecode, the latter being dependent on the specific Python interpreter used and not Hy. step where both languages are converted into Python's AST.Hy is tested on Python 2.7, 3.4 through 3.6, and PyPy.{{cite web |title=Hy Documentation |url=http://docs.hylang.org/en/stable/tutorial.html#hy-is-a-lisp-flavored-python |website=hylang.org |access-date=3 September 2014}}{{cite book |last=Danjou |first=Julien |date=26 March 2014 |title=The Hacker's Guide to Python |chapter-url=https://books.google.com/books?id=B6nhAwAAQBAJ&pg=PT171 |chapter=The AST |pages=165–172}}{{cite web |last=Kitchin |first=John |title=More on Hy and why I think it is a big deal |url=http://kitchingroup.cheme.cmu.edu/blog/2016/03/31/More-on-Hy-and-why-I-think-it-is-a-big-deal/ |website=The Kitchin Research Group |publisher=Carnegie Mellon University |access-date=19 September 2018 |date=31 March 2016}}

Example code

From the language documentation:{{cite web |title=Quickstart |url=http://docs.hylang.org/en/stable/quickstart.html |website=Hylang.org |access-date=19 September 2018 |date=15 May 2018}}

=> (print "Hy!")

Hy!

=> (defn salutationsnm [name] (print (+ "Hy " name "!")))

=> (salutationsnm "YourName")

Hy YourName!

See also

Notes

References

{{reflist}}