Hacker News new | comments | show | ask | jobs | submit login
ClojureScript Blues (venanti.us)
13 points by venantius 805 days ago | hide | past | web | 5 comments | favorite



The first issue is addressed by templates. I maintain Reagent and Luminus templates and make sure that Cljs compiles correctly for both dev and prod targets.

While I understand author's complaint regarding it being difficult to retrofit the template code into an existing project, I really don't see a simple solution to that.

Standard behaviors can be extracted into plugins and libraries, but project specific configuration really does have to be part of the project.

The Figwheel REPL can be trivially connected to an IDE as seen [here](http://www.luminusweb.net/docs/clojurescript.md#clojurescrip...). This should work with any editor the has nREPL support.

There's really no good reason to use the built in REPL on the command line when you can connect the editor and send the code for evaluation directly from there.

In terms of client-server interaction I found that using cljs-ajax https://github.com/JulianBirch/cljs-ajax on the client coupled with compojure-api https://github.com/metosin/compojure-api on the backend works really well.

With regards to Vim, it's definitely not as popular as Emacs or Cursive for Clojure development, so it's not surprising that the tooling around it would be more spotty.

I think this is one area where Clojure shines overall though, as there is support for it in majors IDEs and many popular editors. However, using something that's popular with the community will obviously get you the best mileage.

Overall, I still find ClojureScript to be far more productive than anything I've used to develop on the front-end.


Thanks so much for the post -- I've been wrestling painfully with some of these exact issues off and on for the last six months (particularly getting the vim/fireplace/cljs toolchain working properly). It's actually really heartening to hear that it's not just me ;P


What's your use case for seperate templates? Do you have a lot of existing templates written in jade that you want to reuse?

I try and avoid any templates apart from a single "masterpage" template that my apps sit in.


* figwheel -> https://github.com/adzerk-oss/boot-reload It's not as smart as figwheel because u can lose state, but it's mostly enough. We are actually quite fine with reloading the page manually most of the time.

* uberjar: If you use http://boot-clj.com/ instead of lein, you won't have issues with left-over files, because boot allows every build step to create a unique temp dir which gets erased on next run. Content amongst these temp dirs can be shared by a git-like object store and build tasks pass a virtual immutable file-system (called a fileset) between each other.

* templating: http://hoplon.io/ Your page is not a big data structure. It's an actual Clojure program, which generates DOM Elements directly. You can even call DOM Elements as functions to alter their attributes or their DOM children. Combined with https://github.com/hoplon/javelin you get reactivity in an unobtrusive way. You can separate you app state with it, just like you put data into a spreadsheet and wire up a chart to it which will update automatically. Your DOM is the equivalent of that chart in this case.

* cljs repl -> https://github.com/adzerk-oss/boot-cljs-repl but in practice it was hardly ever used by boot/hoplon people, so it's a bit neglected now.

* server-client state sharing: Hoplon + Javelin + https://github.com/hoplon/castra It's a bit under-documented... probably because it's so super simple... :) Castra does a remote function call via XHR and puts the result into a Javelin cell. If that cell is wired up to a DOM element (attribute or content), either directly or transformed by a formula cell, then your DOM updates automatically once the XHR call finishes. Errors are placed into an error cell, which can also be wired to the DOM...

* Falcor / GraphQL ... I have NOT done this yet but I'm planning to "just" pass Datomic queries via Castra to the backend and that's it. I can't "subscribe to live query" this way, but that's good enough for us. It's also just 1 HTTP end-point. No more RESTful rigidity... ;)

* Vim/REPL: We are just fine with the good old `(print)` and `(serve {:reload true})` from https://github.com/pandeiro/boot-http on the backend. Also we just use Sublime Text with paredit and lispindent. It's super fast even on 4-5 year old machines...

* Chestnut template / plugin: With boot this problem set shrinks to a size where distinction between template and plugin vanishes. You can create a .jar which defines a boot task. That task either creates a template project or defines a build step which u can intermix with other build steps using plain-vanilla function composition. Your environments are also just tasks combining specific build steps with specific options. Nothing custom or magical.

* Om: Again: Try Hoplon. Fraction of the complexity.

* CLJSJS: Your worries regarding extern files and maintenance are not a problem in practice really. We are maintaining a Semantic UI package https://github.com/exicon/hoplon-semantic-ui and just the other day I whipped up externs files for Google Analytics (3 lines), HubSpot (5 lines), Inspectlet (6 lines). See https://github.com/exicon/homepage/tree/master/src

Disclaimer:

I've started using Clojure ~10month ago.

Never really used Lein but experienced all of its pains via Grunt and Gulp I suspect...

Trained ~8 people to work with Boot & Hoplon during these months by pair programming with them. We don't really miss anything else, though we looked into Emacs, Vim, IntelliJ, LightTable.

There are some rough edges and missing documentation, but http://hoplon.discoursehosting.net/ and the #hoplon & #boot channels on http://clojurians.net/ Slack and freenode IRC https://botbot.me/freenode/hoplon/ were more than sufficient.


Update on figwheel vs boot-reload from some contributors of boot-reload:

- "Figwheel has more bells and whistles but the core functionality should be very similar" -- martinklepsch

- "...reloading individual namespaces isn't as useful with a Hoplon app as it is with for example react" -- micha

I haven't remembered this 2nd statement well, so I my corrected statement:

* figwheel at it's core is the same as what boot-reload can do for you if you develop a Hoplon app




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

Search: