Dead code elimination in clojurescript
source link: https://blog.klipse.tech/clojure/2016/03/23/dead-code-elimination.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Dead code elimination in clojurescript
Mar 23, 2016 • Yehonathan Sharvit
Do you see any substantial difference between the two pieces of code below?
Code #1:
(if 2 3)
Code #2:
(def x (if 2 3))
They seem to be quite the same, so you’d expect their js transpiled code to be the same.
Let’s check it with KLIPSE:
xxxxxxxxxx
(if 2 3)
(def x (if 2 3))
cljs.user.x = (3)
;
Do you see what’s going on here?
Code #1 is completely dead code no matter what code will come after it. Therefore it has been completly eliminated by the cljs transpiler!
Feel free to continue to play with dead code with KLIPSE.
Follow viebel to stay up-to-date with the coolest interactive articles around the world.
Discover more cool interactive articles about javascript, clojure[script], python, ruby, scheme, c++ and even brainfuck!
Give Klipse a Github star to express how much you appreciate Code Interactivity.
Subscribe to the Klipse newsletter:Feel free to email me [email protected] for getting practical tips and tricks in writing your first interactive blog post.
Recommend
-
22
Michael Feathers finds errors fascinating, but acknowledges that most developers don't spend a lot of time focusing on them. He also thinks most error handling is kind of giving up. Although best known for his book,
-
36
Code Splitting has been around for a while but I feel it is somewhat underused in most ClojureScript projects and there aren’t many examples showing how you actually use it. Once your project reaches a certain size you s...
-
12
I had no plans to writeanother post about zeros, but when life throws you a zero make zeroaid, or something like that. Here we go! If you want to jump over the winding reveal and just read the summary and advic...
-
17
Introduction If you made it down to thehardware survey on the last post, you might have wondered where Intel’s newest mainstream architect...
-
10
Recursive Feature Elimination, or RFE for short, is a popular feature selection algorithm. RFE is popular because it is easy to configure and use and because it is effective at selecting those features (columns...
-
9
crepl: Write and run ClojureScript code together03 Feb 2017 crepl is a collaborative editor written in Clojure and ClojureScript. In the editor you can write and evaluate Clojure...
-
9
Just Kidding: Understanding Identity Elimination in Homotopy Type Theory Several...
-
5
Post-Monomorphization Dead Code Elimination and Other Unwritten Blog Posts So I've had a lot of ideas for blog posts lately, but non...
-
4
Dead-code elimination Imagine you have the code below: function foo() { var a = foobar(); var b = 8; return 10; } after passing this code through
-
5
crepl: Write and run ClojureScript code together03 Feb 2017 crepl is a collaborative editor written in Clojure and ClojureScript. In the editor you can write and evaluate Clojure...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK