hylang-hycc
hylang-hycc copied to clipboard
A static compiler for Hy
DEPRICATED
There will be no updates upcoming. Now I use Common Lisp and python instead, because Hy has too frequent changes to use for daily tasks. I hope that Hy gets matured and I could go back to Hy someday.
WIP; USE AT YOUR OWN RISK
HyCC
HyCC is a static compiler for Hy, can create shared libraries and standalone executables from Hy source files.
The input source file is once translated to C and then compiled to machine code.
You may also get the generated C source code and compile it mannually with any C/C++ compilers.
One of the recommended uses is to compile a Hy module and create a shared library in order to improve its performance.
In most cases, the compiled module runs much faster than Hy as well as Python, so we can say that hycc
replaces hyc
completely.
Requirements
- hy >= 0.13.0 (or, the latest version on github)
- Cython >= 0.25.2
Installation
$ pip install hycc
Usage
$ hycc --help
usage: hycc [options] module...
options:
-o <file> place the output into <file>
--clang create c code; do not compile
--python create python code; do not compile
--shared create shared library
--version show program's version number and exit
--help show this help and exit
Example
- hello.hy
(defn hello []
(print "hello"))
(defmain [&rest args]
(hello))
Create an executable file
$ hycc hello.hy
$ ./hello
hello
Create a shared library
$ hycc hello.hy --shared
You can import this from Hy as well as Python.
(import hello)
(hello.hello)
; > hello
import hello
hello()
# > hello
Note: if you want to import module as a part of package, __init__.py
is required instead of --init--.hy
.
License
HyCC is distributed under MIT license.