Co-Author of ClojureScript Unreveled book here.

It seems tha that statement is deprecated now, I can remember some issues
in the past for some optimizations modes but now I think it works pretty
well in all optimization modes.

Myself I'm using advanced compilation mode with node in many of my projects
without issues.

PS: I will fix it in the book asap.

On Mon, Jan 25, 2016 at 10:48 AM, Moe Aboulkheir <[email protected]> wrote:

> I don't know what the official position is, but I use :advanced on nodejs
> a bunch.
>
> Take care,
> Moe
>
> On Mon, Jan 25, 2016 at 4:36 AM, Roc King <[email protected]> wrote:
>
>> Hi all!
>>
>> It seems unclear from the quick start wiki page[1]. But in Clojurescript
>> Unraveled[2], it says that :optimizations :none is *mandatory* for nodejs.
>>
>> Can we relay on advanced optimizations when targeting nodejs(currently or
>> in the future)?
>>
>> Thanks in advance.
>>
>>
>> Some reasons(other than runtime performance) to use advanced
>> optimizations:
>>
>> . fast startup time and small memory footprint
>> . easy to deployment
>> . hard to reverse engineering
>>
>> without them, clojurescript + nodejs are not so attractive than clojure +
>> jvm.
>>
>>
>> The hello world program from the quick start wiki page will take half a
>> second without optimizations:
>>
>> $ env time -f '%E %M' node none.js >/dev/null
>> 0:00.50 232320
>>
>> It is 4x slower and uses 4x memory than the empty nodejs program:
>>
>> $ env time -f '%E %M' node </dev/null
>> 0:00.13 59264
>>
>> and is worse than clojure-jvm plus some tweaks for options:
>>
>> $ env time -f '%E %M' java -jamvm -XX:+TieredCompilation
>> -Xbootclasspath/a:$HOME/.m2/repository/org/clojure/clojure/1.8.0/clojure-1.8.0.jar
>> clojure.main - <<< '(println "hello clojure-jvm")' >/dev/null
>> 0:00.50 175024
>>
>> And how could we deploy those things?
>>
>> $ du -shc none.js out
>> 4.0K    main.js
>> 2.7M    out
>> 2.8M    total
>> $ find none.js out -type f | wc -l
>> 26
>>
>> Without dead code removal, it will be even worse for non-trival programs.
>>
>>
>> :optimizations :simple will solve the deployment problem and will reduce
>> startup time and memory footprint. But it is still 2x slower and uses 3x
>> memory than the empty nodejs program:
>>
>> $ env time -f '%E %M' node simple.js >/dev/null
>> 0:00.30 174912
>> $ du -sh simple.js
>> 708K    simple.js
>>
>> And there are some bugs(timeout in core.async, in particular) under
>> simple optimizations. Again, there is no dead code removal in simple
>> optimizations. The Library Problem[3] still exists in clojurescript +
>> nodejs.
>>
>>
>> Under advanced optimizations, it will use 1.2x time and memory:
>>
>> $ env time -f '%E %M' node advanced.js >/dev/null
>> 0:00.16 73552
>> $ du -sh advanced.js
>> 84K     advanced.js
>>
>> With the help of dead code removal, we paid for what we actually use.
>>
>>
>> The hello world program and the build options are the same as in the wiki
>> page[1]:
>>
>> (ns hello-world.core
>>   (:require [cljs.nodejs :as nodejs]))
>> (nodejs/enable-util-print!)
>> (defn -main [& args]
>>   (println "Hello world!"))
>> (set! *main-cli-fn* -main)
>>
>> (cljs.build.api/build "src"
>>   {:main 'hello-world.core
>>    :output-to "none.js"
>>    :target :nodejs})
>>
>> simple.js and advanced.js are built using the following options:
>>
>> (cljs.build.api/build "src"
>>   {:main 'hello-world.core
>>    :output-to "simple.js"
>>    :optimizations :simple
>>    :target :nodejs})
>>
>> (cljs.build.api/build "src"
>>   {:main 'hello-world.core
>>    :output-to "advanced.js"
>>    :optimizations :advanced
>>    :optimize-constants true
>>    :static-fns true
>>    :target :nodejs})
>>
>> version of nodejs and java are 0.12 and 1.7 respectively:
>>
>> $ node -v
>> v0.12.9
>>
>> $ java -version
>> java version "1.7.0_55"
>> OpenJDK Runtime Environment (IcedTea 2.4.7)
>> (7u55-2.4.7-1ubuntu1~0.12.04.2)
>> OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
>>
>>
>> [1]:
>> https://github.com/clojure/clojurescript/wiki/Quick-Start/7f2360af24953303b282771870085620a83f0711#user-content-running-clojurescript-on-nodejs
>>
>> [2]:
>> https://web.archive.org/web/20150716040442/http://funcool.github.io/clojurescript-unraveled#none
>>
>> [3]:
>> https://github.com/clojure/clojurescript/wiki/Rationale#user-content-the-library-problem
>>
>> --
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "ClojureScript" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/clojurescript.
>>
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/clojurescript.
>



-- 
Andrey Antukh - Андрей Антух - <[email protected]>
http://www.niwi.nz
https://github.com/niwinz

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to