Hy

Last updated
Hy
Hy Cuddles.png
Hy logo - Cuddles the cuttlefish
Paradigm Multi-paradigm: procedural, functional, object-oriented, meta, reflective, generic
Family Lisp
Designed by Paul Tagliamonte
Developers Core team
First appeared2013;11 years ago (2013)
Stable release
0.28.0 [1]   OOjs UI icon edit-ltr-progressive.svg / 5 January 2024;4 months ago (5 January 2024)
Preview release
1.0a4 [2] / 16 March 2022;2 years ago (2022-03-16) [2]
Scope lexical, optionally dynamic[ citation needed ]
Platform IA-32, x86-64
OS Cross-platform
License MIT-style
Filename extensions .hy
Website hylang.org
Influenced by
Kawa, Clojure, Common Lisp

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). [3] [4] Hy was introduced at Python Conference (PyCon) 2013 by Paul Tagliamonte. [5] Lisp allows operating on code as data (metaprogramming), thus Hy can be used to write domain-specific languages. [6]

Contents

Similar to Kawa's and Clojure's mappings onto the Java virtual machine (JVM), [7] [8] Hy is meant to operate as a transparent Lisp front-end for Python. [9] It allows Python libraries, including the standard library, to be imported and accessed alongside Hy code with a compiling [note 1] step where both languages are converted into Python's AST. [note 2] [10] [11] [12]

Example code

From the language documentation: [13]

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

See also

Notes

  1. The 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.
  2. Hy is tested on Python 2.7, 3.4 through 3.6, and PyPy.

Related Research Articles

<span class="mw-page-title-main">Lisp (programming language)</span> Programming language family

Lisp is a family of programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in the late 1950s, it is the second-oldest high-level programming language still in common use, after Fortran. Lisp has changed since its early days, and many dialects have existed over its history. Today, the best-known general-purpose Lisp dialects are Common Lisp, Scheme, Racket, and Clojure.

<span class="mw-page-title-main">Python (programming language)</span> General-purpose programming language

Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation.

Programming languages can be grouped by the number and types of paradigms supported.

Pygame is a cross-platform set of Python modules designed for writing video games. It includes computer graphics and sound libraries designed to be used with the Python programming language.

<span class="mw-page-title-main">Django (web framework)</span> Python web framework

Django is a free and open-source, Python-based web framework that runs on a web server. It follows the model–template–views (MTV) architectural pattern. It is maintained by the Django Software Foundation (DSF), an independent organization established in the US as a 501(c)(3) non-profit.

<span class="mw-page-title-main">PyPy</span> Alternative implementation of the Python programming language

PyPy is an implementation of the Python programming language. PyPy often runs faster than the standard implementation CPython because PyPy uses a just-in-time compiler. Most Python code runs well on PyPy except for code that depends on CPython extensions, which either does not work or incurs some overhead when run in PyPy.

In programming, a docstring is a string literal specified in source code that is used, like a comment, to document a specific segment of code. Unlike conventional source code comments, or even specifically formatted comments like docblocks, docstrings are not stripped from the source tree when it is parsed and are retained throughout the runtime of the program. This allows the programmer to inspect these comments at run time, for instance as an interactive help system, or as metadata.

The following tables list notable software packages that are nominal IDEs; standalone tools such as source-code editors and GUI builders are not included. These IDEs are listed in alphabetic order of the supported language.

libffi is a foreign function interface library. It provides a C programming language interface for calling natively compiled functions given information about the target function at run time instead of compile time. It also implements the opposite functionality: libffi can produce a pointer to a function that can accept and decode any combination of arguments defined at run time.

<span class="mw-page-title-main">Clojure</span> Dialect of the Lisp programming language on the Java platform

Clojure is a dynamic and functional dialect of the Lisp programming language on the Java platform.

Benevolent dictator for life (BDFL) is a title given to a small number of open-source software development leaders, typically project founders who retain the final say in disputes or arguments within the community. The phrase originated in 1995 with reference to Guido van Rossum, creator of the Python programming language.

<span class="mw-page-title-main">Cython</span> Programming language

Cython is a superset of the programming language Python, which allows developers to write Python code that yields performance comparable to that of C.

scikit-learn Python library for machine learning

scikit-learn is a free and open-source machine learning library for the Python programming language. It features various classification, regression and clustering algorithms including support-vector machines, random forests, gradient boosting, k-means and DBSCAN, and is designed to interoperate with the Python numerical and scientific libraries NumPy and SciPy. Scikit-learn is a NumFOCUS fiscally sponsored project.

Theano is a Python library and optimizing compiler for manipulating and evaluating mathematical expressions, especially matrix-valued ones. In Theano, computations are expressed using a NumPy-esque syntax and compiled to run efficiently on either CPU or GPU architectures.

Elixir is a functional, concurrent, high-level general-purpose programming language that runs on the BEAM virtual machine, which is also used to implement the Erlang programming language. Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols.

<span class="mw-page-title-main">Julia (programming language)</span> Dynamic programming language

Julia is a high-level, general-purpose dynamic programming language, most commonly used for numerical analysis and computational science. Distinctive aspects of Julia's design include a type system with parametric polymorphism and the use of multiple dispatch as a core programming paradigm, efficient garbage collection, and a just-in-time (JIT) compiler.

In computer programming, self-hosting is the use of a program as part of the toolchain or operating system that produces new versions of that same program—for example, a compiler that can compile its own source code. Self-hosting software is commonplace on personal computers and larger systems. Other programs that are typically self-hosting include kernels, assemblers, command-line interpreters and revision control software.

References

  1. "Release 0.28.0". 5 January 2024. Retrieved 19 January 2024.
  2. 1 2 "Hy 1.0a4". GitHub.
  3. Jaworski, Michał; Ziadé, Tarek (2019). Expert Python programming (Third ed.). Birmingham, U.K.: Packt Publishing. p. 173. ISBN   978-1-78980-677-9. OCLC   1125343555.
  4. Danjou, Julien (2018). Serious Python: black-belt advice on deployment, scalability, testing, and more. San Francisco, CA: No Starch Press. pp. 145–149. ISBN   9781593278793. OCLC   1057729260.
  5. Tagliamonte, Paul (2 April 2013). PyCon lightning talk (Speech). Python Conference (PyCon). Santa Clara. Retrieved 2 September 2014.
  6. Tagliamonte, Paul (11 April 2014). Getting Hy on Python: How to implement a Lisp front-end to Python (Speech). PyCon. Montreal. Retrieved 2 September 2014.
  7. Turto, Tuukka (14 February 2014). "Programming Can Be Fun with Hy". Open Source For You . Retrieved 2 September 2014.
  8. Watson, Mark (2020). A Lisp Programmer Living in Python-Land: The Hy Programming Language (PDF). LeanBooks.
  9. Edge, Jake (30 April 2014). "Getting Hy on Python". LWN.net . Retrieved 2 September 2014.
  10. "Hy Documentation". hylang.org. Retrieved 3 September 2014.
  11. Danjou, Julien (26 March 2014). "The AST". The Hacker's Guide to Python. pp. 165–172.
  12. Kitchin, John (31 March 2016). "More on Hy and why I think it is a big deal". The Kitchin Research Group. Carnegie Mellon University . Retrieved 19 September 2018.
  13. "Quickstart". Hylang.org. 15 May 2018. Retrieved 19 September 2018.
19581960196519701975198019851990199520002005201020152020
 LISP 1, 1.5, LISP 2(abandoned)
  Maclisp
  Interlisp
  MDL
  Lisp Machine Lisp
  Scheme  R5RS R6RS R7RS small
  NIL
  ZIL (Zork Implementation Language)
  Franz Lisp
  Common Lisp  ANSI standard
  Le Lisp
  MIT Scheme
  XLISP
  T
  Chez Scheme
  Emacs Lisp
  AutoLISP
  PicoLisp
  Gambit
  EuLisp
  ISLISP
  OpenLisp
  PLT Scheme   Racket
  newLISP
  GNU Guile
  Visual LISP
  Clojure
  Arc
  LFE
  Hy
  Chialisp