9 ms·
Lumo – A fast, standalone ClojureScript REPL that runs on Node.js and V8
- iagooar 10y agoSometimes I think Clojure should have been developed on top of the ErlangVM instead of the JVM. I think that the ErlangVM solves a lot better the problems that Clojure is trying to solve. Also, seems like targeting the ErlangVM is an achievable feat, since Elixir in its version 1.3 has proven to be extremely solid. Crazy idea: if I wanted to implement Clojure on top of the ErlangVM, where should I start?
- gandolfinmyhead 10y agoHmm hmm study the internals of Lumo maybe? Here's a question, would you be able to build non-actor based concurrency primitives like async's go blocks on a actor based erlang framework? (sorta shooting the shit here)
- shakna 10y agoTake a look at LFE [0] [0] http://lfe.io http://lfe.io
- berdario 10y agoIf I remember correctly, LFE is a Lisp2 Joxa (just like Clojure) is a Lisp1, thus maybe more apt http://joxa.org http://joxa.org
- glogla 10y agoI'm curious, what are the practical differences? I know what the theoretical differences are, but do you have any experience with how lisp1 and lisp2 are different in daily use?
- berdario 10y agoI'm afraid I don't have a satisfactory answer for you. I just prefer to pass around functions/closures as values, and being able to invoke them like any normal function, instead of having to call an helper `apply`/`invoke`/`call` function on them (depending on the language) That's why I said: "maybe more apt"... if OP doesn't care at all about that difference, and it's not among the details that they'd want to replicate from Clojure, it's perfectly ok to ignore
- patrec 10y agoI never found the funcall argument terribly convincing, because there is no reason it couldn't be much more concise. And it allows you to avoid silly variable names like lst or fst. In Common lisp to refer to a function as a variable you do (function f) or as (read-table) syntactic sugar #'f. You could easily use destructuring to write HOFs without funcall. So instead of requiring people to write (defun bad-map (f list) "Maps function `f' over `list', inefficiently." (when list (cons (funcall #'f (first list) (bad-map f (rest list))))) (bad-map #'- '(1 2 3)) A hypothetical lisp-2 could just as well allow destructuring like this: (defun bad-map (#'f list) "Maps function `f' over `list', inefficiently." (when list (cons (f (first list) (bad-map #'f (rest list))))) (bad-map #'- '(1 2 3)) The fact that higher order functions stick out a bit by the extra #' is not necessarily a bad thing IMO; it helps when reading unfamiliar code to know immediately what arguments are functions and which ones are just plain objects.
- lispm 10y agoIn Common Lisp in your first example it's not (funcall #'f (first list) ...) but (funcall f (first list)) ... f is already a function object. We could write a macro for that or a new version of defun. Here just a macro lisp1fy: (defmacro lisp2fy ((&rest calls) &body body) `(flet (,@(loop for (f . args) in calls collect `(,f ,args (funcall ,f ,@args)))) (declare (inline ,@(loop for (f . nil) in calls collect f))) ,@body)) (defun bad-map (f list) "Maps function `f' over `list', inefficiently." (lisp2fy ((f a)) (when list (cons (f (first list)) (bad-map f (rest list))))))
- sz4kerto 10y agoOne of the main objectives of Clojure was interoperability with Java because of the ecosystem. Java and Erlang ecosystems are not comparable. Also, JVM is great. :)
- aaimnr 10y agoThat's not true. One of the main objectives of Clojure was to be a hosted language. Not just 'language hosted on JVM'. So idea to make it work on top of Erlang VM is perfectly valid and consistent with original design assumptions.
- tech2 10y agoExcept then it might not have had as much uptake (tooling, existing Java libraries, installability to various providers and interoperability with existing systems etc.). Now that Clojure has a varied and excellent set of libraries of its own maybe some of this is less important, but not all (the ability to interact with existing Java systems is still very useful).
- dozzie 10y ago> One of the main objectives of Clojure was to be a hosted language. Not just 'language hosted on JVM'. Uhm... I always thought it was meant to be a Lisp for JVM. Where did you get your information from?
- deleted 10y ago[deleted]
- shadowmint 10y agoWhether it's as important now or not is a different matter I suppose, with various targets for the language (including other VMs), but I don't think it's in dispute that originally the extensive java ecosystem was core to what clojure was, and was designed to be. ...but hey, don't take my word for it: The net result is that the prospects for Clojure going forward are very good. The core model of Clojure has held up well and continues to appeal - accessible, robust, thread-safe, efficient dynamic functional programming, on a world-class infrastructure, with a huge set of libraries. Oh yeah, and it's great fun! - Rich Hickey, 2008 https://groups.google.com/forum/#!topic/clojure/2CA_H58Cbo0
- senand 10y agoI think I'd have a look at ClojureScript and/or Clojure CLR (https://github.com/clojure/clojure-clr https://github.com/clojure/clojure-clr). The former is Clojure on top of Javascript, the latter Clojure on top of .Net. It will not be easy, but I'm no expert. I'm also not sure why you'd really want that? Just to solve the long startup time?
- dotemacs 10y agoMaybe here: http://lfe.io/ http://lfe.io/
- dkersten 10y agoCrazy idea: if I wanted to implement Clojure on top of the ErlangVM, where should I start? I would look at retargeting the ClojureScript code generator. Clojure implements a lot of primitives in Java, but ClojureScript is largely written in Clojure and ClojureScript itself so should be easier to port.
- kimi 10y agoIt would be very interesting to have pointers here. I would have liked to do the same thing, but for Golang.
- wuschel 10y agoSuggestion: Have a look at Lisp Flavoured Erlang [1], a Lisp-2 on top of Erlang/OTP that might be 90% of what you want to achieve. :^) I am sure they are happy for new members of the community! [1] http://lfe.io/ http://lfe.io/
- _halgari 10y agoRead up on Lisp Favored Erlang, there's a lot of reasons why Clojure doesn't work well on BEAM, and they're covered by the author of LFE.
- mac01021 10y agoI think shared memory is foundational to Clojure's approach to concurrency, and that is something the Erlang VM cannot provide. So some main fixtures of Clojure's standard library, like atoms, STM, agents, become either useless or nonsensical. It's also not clear to me wether the Erlang VM provides what Clojure needs to efficiently implement its user-defined types, protocols, etc That said, a Clojure-like dialect of lisp built on Erlang is a fine idea and, as others have said, I would probably start by seeing how the Lisp-Flavoured-Erlang (LFE) guys built their lisp.
- DigitalJack 10y agoI would start with lisp flavored erlang, and add clojure's immutable yet fast-copy data structures. They are based on work by Phil Bagwell, https://en.wikipedia.org/wiki/Hash_array_mapped_trie https://en.wikipedia.org/wiki/Hash_array_mapped_trie http://infoscience.epfl.ch/record/64398/files/idealhashtrees.pdf http://infoscience.epfl.ch/record/64398/files/idealhashtrees... You might do better to create a Lisp Flavored Haskell (if one hasn't been started already). I'm sure haskeller's would be offended by the idea, but it already uses HAMT.
- s_kilk 10y agoForking Joxa (https://github.com/joxa/joxa https://github.com/joxa/joxa) could be a good place to start. Might I propose Cloxure ("clock-jur") as the language name? :)
- provemewrong 10y agos/Clojure/ClojureScript
- darklajid 10y agoI was confused as well. The article compares the standard Clojure REPL with two ClojureScript REPLs (one being the one introduced in the article). Interesting nevertheless, but still confusing.
- jaytaylor 10y agoFor those unfamiliar with the differences between Clojure and ClojureScript: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure https://github.com/clojure/clojurescript/wiki/Differences-fr...
- sandGorgon 10y agoany chance of a npm/yarn package ?
- anmonteiro90 10y agoHappy to consider it, but I'm unsure what the benefits would be? Probably something like Homebrew would be more suitable I believe.
- sandGorgon 10y agoWith all due respect we are on Linux. No homebrew for us. Since you are already on the node platform..this makes sense for all of us.
- anmonteiro90 10y agoMakes sense, I didn't specifically mean "just Homebrew", but I'm definitely open to uploading it to the NPM registry.
- rcarmo 10y agoErm. No. I'd pay not to use npm at all.
- spinningarrow 10y agoWhy? You can use it not at all for free!
- rcarmo 10y agoBecause the whole npm system is broken, and I wish yarn would break apart and start anew.
- jhbadger 10y agoYes, there's homebrew for Linux -- linuxbrew (http://linuxbrew.sh/ http://linuxbrew.sh/). I've found it extremely valuable because where I am, "normal" users aren't allowed root access but can compile things in their home directories. Linuxbrew, being a version of homebrew, makes this much easier than doing it manually.
- delegate 10y agoThe startup time is of course very low, so that's good. I think you're underselling the tool for beginners like myself - it's not just a ClojureScript REPL, it's actually an executable which can run node.js scripts written in clojurescript. For example, here's the typical node http server example: https://gist.github.com/anonymous/c14b2b57184c650d9f3ff0a9e1a84058 https://gist.github.com/anonymous/c14b2b57184c650d9f3ff0a9e1... You can run it with lumo test.cljs
- anmonteiro90 10y agoYeah, we have access to the whole Node.js ecosystem :-) it's also possible to npm install a package and use it from Lumo. The Node require resolution algorithm just works.
- mateuszf 10y agoHow do you specify which npm packages / versions do you want to use?
- anmonteiro90 10y agoJust like you'd do in Node. Add deps to a package.json and npm install. Then just `(js/require "your-package")`
- mateuszf 10y agoThat's great. Thanks.
- cutler 10y agoConsidering it's running as a standalone script, how does it resolve its dependency on cljs.nodejs? That's a Clojurescript library, no?
- anmonteiro90 10y agoThere are a number of pre-bundled libraries in Lumo. `cljs.nodejs` is actually part of ClojureScript so it's included too.
- anmonteiro90 10y agoAuthor here. Happy to answer any questions.
- Gonzih 10y agoAny canche to see ARM binaries pre built? Would love to run this on raspberry pi / pocket chip. Also planck had io support. Are you planning to add support for io in idiomatic clojure to your project?
- anmonteiro90 10y agoWhy not?! Sounds like a great idea. Happy to see someone help me with that
- spinningarrow 10y agoI've been using Planck (and Replete for iOS) when I need a fast-starting clj[s] REPL for checking things quickly. What would be the use case for Lumo for me?
- anmonteiro90 10y agoThe difference is that both Planck and Replete run on JavascriptCore, while Lumo runs on Node.js and V8. One of the advantages of piggybacking on Node is that we get access to its whole ecosystem for free.
- kimi 10y agoThis would be cool for ClojureScript scripting
- hellofunk 10y agoPlease change the title to ClojureScript, not Clojure.
- lispm 10y ago'fastest starting Clojure REPL'... which is still slow compared to alternatives.
- anmonteiro90 10y agoUnfortunately, Node.js and V8 seem to be about 2.5X slower than JavaScriptCore for bootstrapped ClojureScript. I haven't found a way around it. I also don't mean to trick anyone and this is explained in the post.
- lispm 10y agoTo me 'fast' means more than startup time. The headline is just clickbait. The time you are reporting is also not that 'fast'. Other tools start in a fraction of that time.
- grzm 10y agosbcl isn't Clojure, is it? Or am I mistaken? I don't see the article or its title comparing it to repls in general. Edit: original comment mentioned sbcl and included sbcl repl start-up time.
- lispm 10y agoBetter title would be: 'less slowest starting Clojure REPL of three' Mentioning 'fastest' at a time of 3GHZ multicore machines with SSD and a duration of 0.1 seconds is just absurd. That's >100 million instructions just to start a language prompt and evaluating a symbol to itself. The Java version is even more absurd with around 1 billion instructions just to get a REPL... A shell on a 1 MIPS DEC VAX 11/780 started faster, while the machine had a hundred users.
- fnordsensei 10y agoWhat tools? What are you comparing it to?
- 10y ago
- mark_l_watson 10y agoNeat project, but back when I was using Clojure a lot, I lived in Emacs and the time spent for booting up my interactive environment was OK because once booted up, I would work for a long time without restarting from scratch. Same for me now with Emacs+Intero for interactive Haskell development - once everything is loaded, Everything is fast. This project seems more suited to being able to write fast starting scripts in Clojurscript.
- cheez 10y agoCame here to say exactly this. The use case is very limited, although technically it's something that will push the state of the art forward.
- jiyinyiyong 10y agoReally hope one day we can build ClojureScript projects without JVM. Lumo is one more step further than Planck.
- fibonacho 10y agoI totally though this was about the WebGL tile rendering library: https://github.com/kbirk/lumo https://github.com/kbirk/lumo I was like "Clojure... V8, what?!"