typelead / eta

The Eta Programming Language, a dialect of Haskell on the JVM
https://eta-lang.org
BSD 3-Clause "New" or "Revised" License
2.61k stars 141 forks source link

suggestion: use clojure aot similar mechanism to reduce jar size. #955

Open clojurians-org opened 5 years ago

clojurians-org commented 5 years ago

haskell compile too much class file, it led to its big jar size.

clojure has a simple solution for this situation for reference.

it has pomegranate library(just like haskell hint library), it can be used to load clojure file in runtime to generate class dynamically. it also publish clj file as maven repository directrly.

in case we need the same physical class sometimes, it offer the aot mechanism to compile only little needed class file before script interpretion procecure. the situation is:

export physical jar class implement used by java project some library use refletion mechanism to load class, so the physical class file must exist. the reference doc is: https://clojure.org/reference/compilation

clojurians-org commented 5 years ago

a simple example, it offer aot entry for needed module for project configuration

(defproject clj-java-compile "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]]
  :aot [core, xxx.yyy, ...]
  :source-paths ["src/main/clojure"]
  :java-source-paths ["src/main/java"])
clojurians-org commented 5 years ago

as you can see from maven repository: http://central.maven.org/maven2/org/clojure/core.async/0.4.490/

the maven repository container only clj file without java.

jneira commented 5 years ago

Hi, the tool to minimize the jar that has been used so far is proguard , you can use it directly or including the appropiate gradle plugin if you are already are using gradle to build the eta project.