简体   繁体   中英

How do / Can I compile Clojure with GCJ

Because Clojure is built on top of the JVM, I would guess I could use GCJ to compile it directly to machine code, but I can't find any information about it.

When it's possible, how could I then "strip" it to it's bare essentials, so the startup time and memory footprint is as small as possible.

I'd really like to write small terminal programs following the UNIX principles with Clojure

In theory, you could AOT-compile Clojure source code to Java bytecode, and then use gcj to compile this byte code to native machine code. In practice, I would not expect this to work; gcj has severe limitations that prevent its use for most modern Java applications. Specifically, its support for language features stops at Java 1.2 (Clojure requires Java 1.6 ), and it has incomplete implementations of the standard class libraries required by the Clojure runtime. In the wild, I've seen Clojure applications crash and burn when accidentally launched using the gcj runtime instead of the OpenJDK or Oracle JREs.

The clojure compiler takes in source "expressions", usually from a file, and produces JVM bytecode. This bytecode is then compiled JIT style to machine code by the JVM. , though for different languages, so it does not make sense to talk about chaining one after the other. ,尽管它们针对不同的语言,所以谈论一个接一个地链接是没有意义的。 The clojure compiler does not produce java source code, it directly produces bytecode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM