8 ms·
ClojureScript is the most-used functional language that compiles to JavaScript
- muddysky 10y ago11 hours after the BuckleScript post Edit: Why the downvotes?
- amelius 10y agoI think the proper name for "compiles to JavaScript" is "AltJS compiler".
- deleted 10y ago[deleted]
- kim0 10y agoI'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
- luck_fenovo 10y agoI enjoy clojure a lot, I've had some difficulty getting started with cljs though. It seems like all the guides on getting set up with tooling are out of date. I'd particularly like to use it with node for scripting tasks, since the Clojure startup time makes it impractical to use for anything that isn't a long-running task. What have you used to get up and running?
- t1amat 10y agoLumo[1] probably fits your use case perfectly. It's a ClojureScript REPL running in a NodeJS context. You have access to both bootstrap-ClojureScript-compatible libs as well as the whole NodeJS ecosystem. The REPL has some nice ergonomic features and comes with a TCP socket REPL you can use with Emacs inf-clojure and (I hear) Cursive. [1]: https://github.com/anmonteiro/lumo https://github.com/anmonteiro/lumo
- luck_fenovo 10y agoInteresting, I'll check it out! Thanks for the tip
- lambdadmitry 10y agoCheck 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 10y agoRe-frame was the project that sucked me in. It is a good read, from the README to the code.
- joshlemer 10y agoThis 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 10y agoCrude, 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 10y agoI would guess the Elm is used more often than Scala.js. But then again, I have no data :)
- virtualwhys 10y agoElm 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).
- ww520 10y agoIt sounds like a marketing person speaking. You can get to the number 1 position in any area with enough qualifiers to slice to a tiny universe.
- tomatsu 10y agohttp://tvtropes.org/pmwiki/pmwiki.php/Main/OverlyNarrowSuperlative http://tvtropes.org/pmwiki/pmwiki.php/Main/OverlyNarrowSuper... 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.
- nine_k 10y agoTypeScript is somehow less radically functional than Clojure. (PureScript would be even more radical, of course.)
- swannodette 10y agoIf 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 10y agoI 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.
- deleted 10y ago[deleted]
- delegate 10y ago"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.
- cygned 10y agoI am familiar with the concept of Clojure's reply but I am always wondering how one gets code out of it eventually.
- jeremiep 10y agoYou don't get code out of the REPL. You evaluate your code inside the REPL, often directly from the source files. For example I'll often write a function in a source file, evaluate it from there so it exists in the process, then call it from the REPL to test it works correctly. When I launch the program, every temporaries made at the REPL are gone, but the source stays.
- cygned 10y agoThat is the workflow I currently use, too. Luckily, Leiningen reloads most of my changes. I wished, though, there was the ability to save the current name space from the REPL. Hacking together a couple of functions and save their definitions when you're happy.
- paulddraper 10y agoIsn'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 10y agoYou 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.
- Sanddancer 10y agoIt's functional. It has all the components needed to code in a functional style, but at the same time, lets you use other paradigms, such as OO, when they make the most sense to do so. I'd argue a "pure" functional language is akin to trying to write a novel on a keyboard without an "e" key. Sure, you'll eventually stumble and write "Gadsby", but there are times when being able to cheat is useful in making your code more clear and concise. When I code stuff in C++ or C#, I keep my objects immutable most of the time because it's the easiest way to rationalize the various components that way, but at the same time, when I'm doing things like handling I/O, a pure functional style gets in the way.
- paulddraper 10y ago> 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.
- cryptica 10y agoI 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.
- nadagast 10y agoHave you tried Typescript? It's less ambitious/different than Clojurescript, but the compiler in watch mode compiles on change very quickly.
- tps5 10y agoI don't think this should be downvoted, it's a valid perspective. Compile times matter. I use typescript and have it watching my files. Compilation (or transpilation, whatever you want to call it) time isn't an issue. I could see it being quite a hindrance if I had to run tsc on my entire project every time I changed one line, I don't know if this is the case with clojurescript, but it would be a downside for sure.
- drcode 10y agoWhile you are right that the pain of the compilation step is immense, I think you may not appreciate all the niceties we have in Clojurescript land that you have to do without in javascript land.
- yogthos 10y agoThe beauty of ClojureScript is that you don't have to recompile and reload your page all the time. Development is done using Figwheel https://github.com/bhauman/lein-figwheel https://github.com/bhauman/lein-figwheel and things reload live in the browser as you change the core in the editor. Not only don't you need to wait for recompilation, you don't even have to reload the page to see the changes. Everything happens interactively as you're writing the code.
- 10y ago
- moomin 10y agoI 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.
- jbeja 10y agoI think this is false. Typescript must be.
- xixixao 10y agoYes, if you don't count CoffeeScript that is .)
- drcode 10y agoCall us back once CoffeScript programs can use immutable data types as easily as mutable ones :)
- escherize 10y agoFor anyone wanting to see some live examples of ClojureScript in action, please checkout my project, http://cljsfiddle.com http://cljsfiddle.com
- antsantoo 10y agoOne quick question. Provided Javascript is a functional language, why one need to go for clojurescript? Any advantages?
- iLemming 10y agoMost 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 10y agoThanks for your comment. I guess I should be start learning clojurescript in the weekends.