
ClojureScript is the most-used functional language that compiles to JavaScript - gw
https://sekao.net/blog/industry.html
======
delegate
"Ok the app works now!"

I say this after running the last command in the REPL - it's what I've been
doing for the last 2 hours. I haven't looked at the browser since I started.

I switch to the browser and sure enough, the whole thing works perfectly.

This is the Clojure(script) experience - it's a different method of developing
applications. Combined with the brilliant weirdness of the language itself, it
sucks you into the REPL and persists even after you've finished coding.

The most suitable word for this experience is "hacking". You don't code your
program, you hack it.

The only drawback of Clojure/Clojurescript is the high learning curve.

Maybe the 20 years of OO programming have really left a dent on my brain or
maybe it was because of the young age of the ecosystem, or maybe because
tooling wasn't quite there yet, but I found it quite a challenge, before I
could write even basic programs.

Even now, after having spent months learning it, I still find it intimidating.

Oh and did I mention how much clearer it is to write C++ after learning
Clojure ?

Pure functions, immutable data, data vs code.. just some of the concepts that
help a lot when you bring them to an OO language.

~~~
dustingetz
I love the JVM repl experience from Cursive and emacs. But I've never come
close to it from ClojureScript for browser development. Can you describe your
repl capabilities and dump some links? (I am looking for a real repl
experience like on JVM where the IDE is hooked into the repl and forms can be
sent across individually and the app can be built up piecemeal without
restarts. If this isn't what I want, tell me what I want. Figwheel doesn't
seem to be it.)

~~~
swannodette
I don't understand. The Figwheel REPL does exactly that + hot loading. I use
Figwheel with Cursive - works great.

~~~
dustingetz
Can you post a short video of your workflow? It might help a lot of people

------
joshlemer
This article provides zero data to back up its claim that ClojureScript is the
most-used functional compile-to-JS language, just a list of companies that use
it.

~~~
virtualwhys
Crude, but combine companies using with Github stars and I'd say the claim is
accurate.

Second most used FP <> JS language would probably be Scala.js, which, as far
as we know[1] doesn't yet have many companies publicly using it.

Take it all with a grain of salt, OP himself says, "ClojureScript has almost
certainly become the industry's most-used functional language that compiles to
JavaScript. Admittedly, this is like being the most popular person who can
speak Klingon".

Translation: combined adoption of niche languages <> JS is still miniscule.

[1] [https://www.scala-js.org/community/](https://www.scala-js.org/community/)

~~~
Vinnl
I would guess the Elm is used more often than Scala.js. But then again, I have
no data :)

~~~
virtualwhys
Elm in itself is useless; the claim here is that among FP _server-side_
languages that compile to js, CS leads the pack.

Sure, with Node.js on the server then Elm, Purescript, BuckleScript, etc. can
do client-server, but they can't do so in the _same language_ , seamlessly
share code, etc. That's one of the selling points of one-language-to-rule-
them-all (i.e. target js, wasm, native, clr, jvm, ...).

Saying that, looking at BuckleScript this weekend -- completely shocked that
there's _zero overhead_ wrt to generated file size; it's like typed
Coffeescript a la OCaml, unbelievable (this from a dev using Scala/Scala.js in
day job).

------
paulddraper
Isn't Javascript is the most-used functional language that compiles to
Javascript?

> [Javascript is] a multi-paradigm language, supporting object-oriented,
> imperative, and functional programming styles
> [https://en.wikipedia.org/wiki/JavaScript](https://en.wikipedia.org/wiki/JavaScript)

The author must have a very particular idea what "functional" means to include
Clojure but not JS. That's fine, though it'd be enlightening if he shared it.

~~~
ryeguy
You must have a very particular idea of what "functional" means to include JS.
What definition of functional programming does JS meet that you can't apply to
nearly every language? It can't be that it just has first class functions,
lambdas, or higher-order functions: many, many languages have that.

Functional languages emphasize immutability. Javascript does not do this.
Clojure[script] does.

~~~
paulddraper
> What definition of functional programming does JS meet that you can't apply
> to nearly every language?

Since functional programming is a programming _paradigm_ , not a language,
don't be surprised if many languages support it, just as many diverse
languages support OO.

The language support generally thought necessary is first-class functions (and
consequently concepts like higher-order functions). For example, Java < 8 and
C# < 2.0 aren't usually considered functional.

If you think allowed mutability makes or breaks a functional language, then
neither Clojure nor Clojurescript fit the definition.

------
kim0
I'm learning clj/cljs .. finding that experience a blast! I almost never do
any front end work, but with cljs and re-agent, I found myself productive. Clj
itself strikes me as a very well thought out language

~~~
lambdadmitry
Check out re-frame [1], too. It's a very thin layer on top of Reagent, but it
will help you to get the overall structure just right.

Also, its README is worth reading even if you won't use re-frame :)

[1]: [https://github.com/Day8/re-frame](https://github.com/Day8/re-frame)

~~~
tluyben2
Re-frame was the project that sucked me in. It is a good read, from the README
to the code.

------
escherize
For anyone wanting to see some live examples of ClojureScript in action,
please checkout my project, [http://cljsfiddle.com](http://cljsfiddle.com)

------
tomatsu
[http://tvtropes.org/pmwiki/pmwiki.php/Main/OverlyNarrowSuper...](http://tvtropes.org/pmwiki/pmwiki.php/Main/OverlyNarrowSuperlative)

Also, there are a bunch of languages with functional features which compile to
JavaScript. I don't think ClojureScript is more popular than, say, TypeScript
or Dart.

~~~
swannodette
If I'm on an engineering team that's using Dart or TypeScript I'm not going to
lean on functional programming patterns the way I would if I was on a team
using ClojureScript. Idioms matter when you're working on production stuff
with other people.

But sure, TypeScript appears to dwarf all other compile-to-JS languages in
terms of actual usage.

------
mrcactu5
I think Clojure or ClojureScript is a very important as a member of the Lisp
family and yet also compiles to Java or JavaScript. This is complementary to
languages like Elm or Haskell which emphasize type purity. I have gone the
second route, but many people dislike it.

I once ran a meetup with ClojureScript Koans and people loved it. I should
hopefully add a few.

------
jondubois
I dislike all compile-to-JavaScript languages. The compilation step is a
massive overhead and it becomes a major pain in the neck once your project
reaches a certain size.

Whatever shortcomings of JavaScript these languages claim to solve are not
worth the pain and suffering that this extra compilation step adds.

They all claim to compile really fast, yet whenever I have worked on a project
which uses a compile-to-js language, they always seem to end up taking 10 to
30 seconds to compile each time and this slows down debugging significantly.

~~~
wott
> _they always seem to end up taking 10 to 30 seconds to compile each time_

Oh yeah, that's huge, at least the time to sip half a glass, that's
scandalous. Hmm... you're kidding, right? How can it be a problem in absolute
value, and furthermore how can it be a problem in relative value? That time
should be absolutely negligible _vs_ the design, the thinking, the typing, the
thinking again, etc.

> _and this slows down debugging significantly._

There is also the option to think about what you program instead of proceeding
by trial and error.

I don't want "a project of a certain size" to be handled through trial and
error. And yet, according to the pitiful results and condition of current
software, especially shitty web apps, that has to be representative of the
current model of development.

~~~
jstimpfle
I doubt you have done this kind of development. The advantages of fast
edit/compile/run cycles are widely acknowledged (as are the advantages of
compiled languages). Many development domains profit greatly from instant
feedback.

"Should I put more space here? Is the border too thick? Let's see".

"Oops! I know why it's failing. I'm quickly going to fix the order of the
arguments".

It's great if you can do these things in 3-10 seconds instead of minutes. Not
everybody is designing airplane control software.

~~~
iLemming
Instant feedback? You ever heard about Figwheel? Watch the video and now
imagine that it also works with mobile platforms.

------
moomin
I maintain a small ClojureScript library, but I really don't think this
article is missing the point. The people comparing ClojureScript, Scala.js,
Elm, PureScript, and GHCJS are looking for something pretty specific. Not just
persistent data structures and the same map/filter primitives that are now
available in Java, but expressive and strong types. ClojureScript rejects that
this is even something you'd want.

------
xixixao
Yes, if you don't count CoffeeScript that is .)

~~~
drcode
Call us back once CoffeScript programs can use immutable data types as easily
as mutable ones :)

------
antsantoo
One quick question. Provided Javascript is a functional language, why one need
to go for clojurescript? Any advantages?

~~~
iLemming
Most people I know who actually tried Clojurescript like it and would like to
stay within its proper. Why don't you try it? I myself after trying
Coffeescript, Typescript, Livescript, Gorillascript, Fay, Haste, GHCJS,
Traceur and Babel found Clojurescript and it brings me an immense joy. Every
single day. I'm not even mentioning lots of templating engines, CSS
preprocessors and bunch of js testing frameworks, bundlers and build tools
that I had to deal with. That pain is gone. The work become a joy.

~~~
antsantoo
Thanks for your comment. I guess I should be start learning clojurescript in
the weekends.

------
muddysky
11 hours after the BuckleScript post

Edit: Why the downvotes?

------
amelius
I think the proper name for "compiles to JavaScript" is "AltJS compiler".

