Experimental Clojure port written in Haxe targeting C++, HashLink, Python, Lua, JavaScript, JVM/Java, C#.
- C++, HashLink, Python, Lua
- JavaScript, Java, C# (because these implemetations already exist)
- PHP, Flash (not tested)
HashLink is a virtual machine for Haxe oriented towards real time games.
Current version is tested with Haxe 4.3.2. Install Haxe and appropriate libs for platforms. E.g. to build executable with cpp:
haxelib install hxcpp
$ haxelib install utest
$ haxe test.hxml
Work in progress. Near all major classes from clojure.lang.* have been ported, ignoring all concurrent primitives and thread-safety (see 'Concurrent primitives' table at the bottom). On the way to work on Compiler and load/compile clojure.core.
| Platform | Build size | Tests | Tests time | Comment |
|---|---|---|---|---|
| C++ | 6.3 MB | 226/226 (ALL) | 0,024s | |
| HashLink | 359 KB | 226/226 (ALL) | 0,093s | |
| Python | 836 KB | 226/226 (ALL) | 1,893s | |
| Lua | 952.5 KB | 225/226 | 1,356s | Due to #10909 |
| JavaScript | 610.5 KB | 226/226 (ALL) | 0,329s | |
| Java | 638.3 KB | 208/210 | 0,570s | Due to #10906 |
| C# | Not compiled | |||
| PHP | Not tested | |||
| Flash | Not tested |
Tests time are measured with time <command> (example time python3 main.py)
Pay attention that now only clojure.lang.* classes are implemented (and not even all). So after compiling clojure namespaces build sizes will be much bigger.
Build sizes are for builds that run tests.
In Java and Lua there are some bugs in haxe.Rest, but I think it is possible to avoid them or they will be fixed in feature Haxe realeases.
Because this port is based on Clojure JVM implementation, which uses some system features (for example filesystem in clojure.lang.RT), for JavaScript it needs some other implementations in those places and more conditional compilation. And because JS is not in 1 priority, sometimes it can be postponed and have old results in the table.
C# target is not built because of double methods generation, probably because of complex hierarchy and methods with same names in base class/interface and sublclasses/subinterfaces. Needs more investigating.
- Be able to run base, general, single-threaded version of Clojure REPL as interpreter (without full support for concurrency and parallelism for now) on various platforms
- Discover all posibilities that this will bring
- Have fun
| Java primitives | Haxe alternatives |
|---|---|
| ConcurentHashMap | |
| synchronized (method) | |
| AtomicReference | Atomic operations |
| ThreadLocal | |
| Thread | lang.misc.Thread wrapper |
For concurrency and parallelism it will probably need a special library, where for each primitive there would be a wrapper calling appropriate platform-specific realization. For example, in Atomic wrapper, for Java - using AtomicReference inside, for JS - just var, on other platforms - maybe other CAS implementations. Also haxe-concurrent library may be helpfull.
-
U.hx- utils for reflection and types -
Character.hx- there are not Characters in Haxe -
Comparable.hx,Comparator.hx- for sorting -
Collection.hx- for compatibility