Hacker News new | comments | show | ask | jobs | submit login

if I may ask a dumb question : do experienced javascript programmers become more or less productive when they switch to Clojurescript or ELM or other js transpiling languages ?



I think it depends on what your expectations are as well as what you are willing to put into learning them. Both Clojurescript and Elm have their place.

Elm is very nice but definitely has a learning curve. You can try Elm in a low impact way by making a small component with it and using it alongside either React or Angular ( or in other scenarios as well ). It can also work as a state management solution for parts of your front end app. On the other hand building an entire SPA in Elm is a monumental task and requires significant investment. As the Elm experts say Elm is not really a good solution for quick one offs or prototyping. It may require you to reinvent the wheel for many widgets for which you could find relatively high quality open source options in React or Angular. Also, Elms JS interop is a bit tedious at times but works relatively well.

Clojurescript has been around longer then Elm and for most has less of a learning curve, but for some the JVM tooling may be a turn off. Nonetheless it is fun to use and there are several Clojurescript UI libraries (Rum, Reagent, Om, Hoplon/Javelin) all of which are used in production at various places.

I would say for an experienced javascript developer there is something to gain by delving into either Elm or Clojurescript and though both are very different the strong functional emphasis of both imparts habits of code organization and thinking that you might not develop as easily by staying in pure Javascript territory.


I suspect that in the short term the answer would be no, because of the initial learning curve. In the long run I think that it depends on the kind of project they are working on. Something like clojurescript would be a bit of heavyweight solution for really simple javascript enhancements. I suspect that productivity improvements of learning a transpiled language are similar to the improvements of learning a new javascript framework like React or Angular. They offer a learning curve in exchange eventually for a simplified programming model.


I became much less productive when I first switched to cljs but after a few projects I could prototype things fairly quickly.

Of course even today I miss out on react components on npm (having to first port them to cljsjs) which is a source of slowdown for me personally.


here is my experience:

- creating a project from scratch is easy: lein new reagent-frontend my-project. it creates a project from reagent-frontend template. you can build your app with lein cljsbuild auto or build a production build with lein release.

- build time significantly drops, even with advanced optimizations, comparing to webpack.

- both component and app state management becomes a lot easier thanks to reagent atoms.

- not much of a big deal but hiccup templates make inline styling easier.

- you get figwheel! [0] [1]

[0] https://github.com/bhauman/lein-figwheel/ [1] https://www.youtube.com/watch?v=j-kj2qwJa_E


Much more productive after the initial learning curve as some said. It's pretty easy to call standard js from Clojurescript which makes things play well.

I find having the syntax, tools, and power of Clojure to be a much better experience than using vanilla js. There are so many things that just work, and having immutable data structures as the default is a plus, and a huge win. Further, I find that it makes things a lot easier to use with the backend, especially if it is also Clojure.

As far as working with the backend, I often am able to rename a clj file to cljs and it just works. I can also share the same exact code literally and insert the occasional reader conditional and cljc file. This is a huge win as well given both Clojure and Clojurescript encourage data-first approaches. Most of my code tends to be just maps, sets, lists, and vectors, with the occasional custom data structure. Sending this back and forth between client and server is infinitely easier and nicer than vanilla js. Adding things like EDN, transit, and libs that are built for dual use in Clojure and Clojurescript save a ton of time here as well.

Regarding tools, I find if you just use decent emacs plugins or an IDE like IntelliJ with the Cursive plugin, the syntax checking and dev experience is great. I tend to do a lot in the REPL which I feel is a productivity win for me over just working in chrome dev tools alone or some other js tools. Figwheel for example is another great one I use for doing hot code reloads/side-by-side changes.

For more specific and complex cases, I get even more benefit using reactjs from Clojurescript. There are multiple good frameworks in cljs that simplify the react experience and in some cases, even makes it run a bit faster (unless you replicated more or less the same immutable experience from js).

As for bad things, here's a few worth noting:

- Initial project setup can be a lot more of a pain, especially with lein. Boot can be an improvement but isn't as widely supported and doesn't always makes things easier. The larger point is there is a lot of ceremony getting new projects setup for non-trivial things. For trivial things, lein templates and various git repos make it quick.

- Some situations using vanilla js arrays can lead to better performance. It just depends because the opposite can be true. In both Clojure and Clojurescript I use transients where possible for a slight boost in some use-cases.

- Debugging can be a bit of a pain at times if you really have something deep. Since most things are data though, I don't really care that much as I normally solve problems using the REPL and/or dumping app state. In reagent and other frameworks, you tend to have a single atom i.e. source of truth which makes it easier than most typical approaches in js.

- Every once in awhile I hit something weird in Google Closure or a weird bug with Clojurescript itself. These tend to get fixed though and it's not hard to reach the actual devs.

- Clojurescript tends to make me hate using non-Clojurescript libraries. Interfacing is not difficult, rather the quality bar and extra dependencies that many npm projects pull in just make me insane. It's more of a personal and elitist thing that happens to a lot of people I know who use Cljs, but not really a problem, just pointing it out.

As a whole, I feel like Clojurescript makes Javascript not suck so bad. I know a lot of people love js, and I've been using it since the beginning. It sucks and is a horrible language, but we're stuck with it. Fortunately Clojurescript and Elm are at least ways of making the experience less bad. The biggest criticism is any time you get into transpiling or further from an original language, there are always a few places where things leak or become more confusing, but I'd say given js in general, it's worth it for a solid set of libraries that just work and the dev experience that goes with it.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: