3 ms·
This is like a dream coming true. I don't like Javascript's quirks, nor programming DOM with templates nor functions. I'm looking to build somewhat complex UIs
by jarpineh 13y ago
This is like a dream coming true. I don't like Javascript's quirks, nor programming DOM with templates nor functions. I'm looking to build somewhat complex UIs without having to think in JS and manage state. React absolves me from DOM and ClojureScript keeps JS at bay.
Only if starting ClojureScript development wasn't so hard. I'd like to use browser REPL, IDE like LightTable. I am used to LiveReload's speed which makes loading changes instantaneous. But ClojureScript compiling seems to be still slow(ish) and I have already found half a dozen of different cljsbuild configuration examples. Compiling simple cljs files can take anything from sub second to 20 secs, and I don't understand why.
Could you perhaps tell more about your development process, Swannodette? How do you develop ClojureScript apps? I don't see anything beyond base cljsbuild in Om's project.clj. I confess I haven't yet had time to play with Om and see how fast it can be compiled.
- swannodette 13y agoThe first build of ClojureScript app is somewhat slow because we need boot the JVM, compile ClojureScript, and then analyze and compile your code. After the first compile it should be sub second. I always use the auto build mode and when I'm developing I don't use any optimizations. Works well enough for me. I'd start with this, http://swannodette.github.io/2013/10/27/the-essence-of-clojurescript/ http://swannodette.github.io/2013/10/27/the-essence-of-cloju...
- jarpineh 13y agoThank you, yours is what I tried first and it's definitely fastest, sub second after first compile. However there is no REPL like cljs-start and couple of others I tested have. Between cljsbuild, Austin and LightTable I haven't yet found a stable and fast solution yet. I'll try adding these various REPLS to your example and see what happens. External browser with REPL inside LightTable seems easiest for a noob like me. Unfortunately LT doesn't support that use case yet, and you can't use Chrome debugger inside it. I still need to see what the browser thinks is happening and not just the ClojureScript's side. I did manage to get React + JSX, CoffeeScript and ClojureScript + bREPL working with LiveReload, in a single page app. That felt truly powerful.
- adrianm 13y agoI hear your pain - I can't live without a REPL, and a stable browser REPL for ClojureScript development is a must. I personally use Emacs and Austin to hook the browser REPL into nrepl. Here are some sample files that you can take a look at. Here's a sample project.clj: https://github.com/aamedina/foundation/blob/feature/cljs/project.clj https://github.com/aamedina/foundation/blob/feature/cljs/pro... I've become a fan of Stuart Sierra's Reloaded workflow: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-r... Here's my dev/user.clj https://github.com/aamedina/foundation/blob/feature/cljs/dev/user.clj https://github.com/aamedina/foundation/blob/feature/cljs/dev... Some notes about what I did here: you start the server by running (go), you can quit the CLJS repl easily by typing in :cljs/quit as normal and return to the user namespace and then safely (stop) or (reset), stop will stop the server and reset will refresh all of your Clojure namespaces (useful if you're writing macros in Clojure for use in ClojureScript). Aside from this, just turn on cljsbuild auto with :optimizations :none, and code recompiles are sub-second. Hope any of this helps you.
- jarpineh 13y agoThank you. I will definitely take a look at these over the weekend. User.clj seems particularly useful. Reloaded workflow reminds me of IPython, where you need to reload modules and reset the object instances for the new code to take effect.
- jamii 13y ago> External browser with REPL inside LightTable seems easiest for a noob like me. Unfortunately LT doesn't support that use case yet... It certainly does :) On the connections panel click 'Add connection' and then 'Browser (External)' The first time you do that it will give you a script tag to add to your page. Once you've added that and loaded the page in the browser, try again and it will connect. You can email me (jamie@kodowa.com) or the LT group (light-table-discussion@googlegroups.com) if you have any problems :)
- jarpineh 13y ago
- lucian1900 13y agoI don't think ClojureScript could become popular beyond a subset of Clojure users unless it becomes self-hosted, so it can be compiled without a JVM and eval in a browser with an extension. The JVM is not universally loved/acceptable. I keep meaning to make a game with it, but always give up because it's so much more painful than pretty much any other to-JS language.
- jarpineh 13y agoThat might be, but it's young yet. Just seeing its ideas (or general functional programming in general) getting more widespread, like React here, feels good to me. I have more pain points with JS. I'd rather deal with build difficulties than have to handle DOM state, evented programming and JS quirks.