10 ms·
Clojerl – Clojure for the Erlang VM
- macintux 7y agoThat’s very cool. I’ve added Clojerl to my list of alternative languages on the BEAM: https://gist.github.com/macintux/6349828#alternative-languages-targeting-the-erlang-vm https://gist.github.com/macintux/6349828#alternative-languag... Given the extent to which the Erlang VM is optimized for immutable data, network transparency, and message passing, I can see why Clojure on the JVM and CLR would not have had the same success with the actor model as Erlang has.
- jacobush 7y agoI don’t ...
- macintux 7y agoThe JVM is a kitchen sink environment. The BEAM is very opinionated. I would expect the VM built from the ground up to support a specific programming model to be superior at doing just that.
- macintux 7y agoIn addition, every library written for the BEAM in any language is designed for message passing and the actor model. Clojure would not have that advantage on the JVM.
- didibus 7y agoClojure doesn't use the actor model...
- macintux 7y agoWhich was part of the discussion at the linked article.
- didibus 7y agoOh okay, sorry I misunderstood your comment the first time. The rationale for why Rich Hickey didn't go for the actor model are actually documented here: https://clojure.org/about/state https://clojure.org/about/state I agree with you, that the JVM also would have probably made it more difficult to incorporate and leverage, though Scala seems to have pretty successfully done that, and Fantom has gone that route as well successfully (though the language is niche) on the JVM. So I'm not totally sure either.
- pron 7y agoBEAM is a wonderful VM, but calling it "optimized" for anything is problematic. It has focused on certain use cases, but it's seen less than 1% of the investment in the JDK, so I guess it's better to call it "specialized". While it works well enough for many things, its performance is like the JVM limping on both legs after a terrible car accident and a bad case of pneumonia while trying to walk on an icy road. You are correct, though, that it probably performs better than a general-purpose platform with a similar level of investment.
- nivertech 7y agoBTW, many years ago, the author of Erjang told me that eventually Erjang will be faster than BEAM for running Erlang apps, b/c of all the investment that went into the JVM ecosystem. I'm not sure it's the case now (probably since nobody using Erjang in production). You are correct in describing the raw performance of BEAM, but I'm not sure it's relevant for a typical IO-bound Erlang/Elixir app. Also most large real-life apps would use NIFs written in a language capable generating native code, i.e. C/C++ or Rust.
- patrec 7y agoThere is no doubt that JVM can provide massively better performance for a lot of stuff, but I wouldn't be suprised if Beam kicked JVM's butt in at least some areas. It's pretty much the only system I know of that provides for massive numbers of fairly scheduled, preemptive green threads. To do so it makes trade-offs that are not generally attractive, but I'd be surprised if it didn't beat the JVM here.
- pron 7y agoI would be. BEAM is just a very slow platform, not just compared to Java, but also compared to JavaScript and Go. Again, that's not to say it's not very useful for some things (although many Erlang apps are really mixed Erlang/C apps because of BEAM's performance). Hey, CPython is really slow, too and yet very useful. Green threads is another matter as it's not a feature that currently exists on the Java platform (there are somewhat similar features in Java platform languages like Kotlin's coroutines), but there is currently a project (that I'm leading) to add fibers (AKA user-mode threads, AKA lightweight threads, AKA green threads) to the JVM: https://wiki.openjdk.java.net/display/loom/ https://wiki.openjdk.java.net/display/loom/
- fulafel 7y agoBenchmarking Clojure (both JVM and JS) vs Erlang immutable data structures would be very interesting given the focus on clever implemeations (persistent data structures) on the Clojure side and the VM level specialization on the Erlang side.
- sbuttgereit 7y agoI like your list, but one thing that would be helpful for me is in the alternative languages available on the BEAM, make the distinction between those implementations which are "BEAM languages" vs those that are simply implemented on the BEAM. For example, Elixir is a proper BEAM language that targets the BEAM directly in a compile step.... but Luerl is not: Luerl is basically a Lua interpreter written in Erlang. I would expect different trade-offs from Elixir vs. Luerl as such. For example, I have a project where I need a limited, embedded scripting environment inside of an otherwise Elixir project. Using a BEAM language seems to be difficult to impose the desired limitations for such scripting environment, but in Luerl it seems I can do just that... limiting the scripting to a-less-than-system-wide scope. Of course... I expect a fairly substantial performance penalty for that... but trade-offs :-).
- macintux 7y agoI think if I were running this as a repo with the possibility of pull requests I’d get more granular, but I can rarely be bothered to do much more than occasionally add a link. To be pedantic, btw, Elixir compiles to Erlang Abstract Format, not the BEAM itself.
- yellowapple 7y ago> I’ve added Clojerl to my list of alternative languages on the BEAM Nice! As a bit of a shameless plug, I have an entry for your list: https://otpcl.github.io/ https://otpcl.github.io/ (GitHub repo: https://github.com/otpcl/otpcl https://github.com/otpcl/otpcl)
- tanzbaer 7y agoWhy would I use this over elixir?
- macintux 7y agoIf you want a Lisp (although there are multiple Lisps for the BEAM). If you want to help build a new language. If you don’t like Elixir’s syntax (raises hand).
- whitepoplar 7y agoJust curious--what don't you like about Elixir's syntax?
- im_down_w_otp 7y agoI don't particularly care for the ambiguity that stems from facets of it being optional, nor the way function match arms are defined, nor the :atom or lowercase variable naming syntax. The mixing of do and -> kinda bugs me as well. :shrug: Though my opinion on the matter is deeply colored and probably unreliable because I'm one of those weirdos that thinks that Erlang syntax is actually quite nice for the most part. Also, I'm in no position to complain since currently my technical life (what little is left not making slide decks) now revolves around Rust, Agda, and TLA+ (god help me).
- lackbeard 7y ago
- noncoml 7y agoSorry for the off topic. Any good recommendations for a Clojure book for a seasoned programmer but with little exposure to Lisps?
- goostavos 7y agoJoy of Clojure is my favorite whirl wind tour of the language. I generally suggest also pairing it with Clojure Applied, which deals with the larger "assembling the pieces into a whole" side of things.
- manishsharan 7y agoI bought Clojure in Action and The Joy of Clojure , both from Manning. I found Clojure in Action to be better suited to me as I too had little exposure to Lisps. Everybody raves about Joy of Clojure but it did not work for me. But now my favourite book is Clojure for the Brave and True -- it is awesome and fun.
- ashton314 7y agoI taught myself Clojure with [Clojure for the Brave and True](https://www.braveclojure.com https://www.braveclojure.com). It's a silly (free) online resource. I grew up learning Common Lisp and Scheme, and it was really easy for me to get into. That just meant I skipped the first chapter. It quickly got into doing things the Clojure Way™ and how to leverage its strengths. Highly recommended.
- gleenn 7y agoI second this resource, it's well explained and was also concise enough so that I actually finished it. Definitely covers the the important bits and a lot of advanced bits like macros and atoms, etc.
- pixelperfect 7y agoGetting Clojure by Russ Olsen. It's the most recently published of the introductory Clojure books and imo the best written.
- deleted 7y ago
- ggregoire 7y agoAny initiative like this (language on top of the Erlang VM) with static typing out-of-the-box? I really want to love Elixir but dynamic typing is a NO for me.
- johnsimer 7y agoGLEAM - its Ocaml + elixir
- macintux 7y agoThanks, added that to my gist.
- macintux 7y agoAt least a couple: * https://github.com/alpaca-lang/alpaca https://github.com/alpaca-lang/alpaca * https://github.com/wende/elchemy https://github.com/wende/elchemy
- toastal 7y agoThere's Purerl for PureScript that compiles to Erlang. There's a maintained package set for Spago for the Purerl community.
- starman100 7y agoJust use Erlang with Dialyzer. It's not quite as nice as a lanugage with types built-in, but if you're strict about using it, it does work. I won't code without it.
- PopeDotNinja 7y agoI have burned more time than I care to admit trying to decipher dialyzer output shenanigans. I love dialyzer when my code doesn't generate any errors, and the rest of the time I kind of want to cry.
- zambal 7y ago
- giancarlostoro 7y agoInteresting! I posted Erjang (JVM based Erlang VM)[0] a few days ago, I guess I missed this one. I have a fascination with both Erlang and Lisp. I love Erlang because it is definitely a back-end language. I also love it's resiliency. I like how expressive Lisp languages can be. So maybe we'll just run Clojerl on top of Erjang, which is on the JVM, and Clojerl is based on a JVM language, talk about an onion. [0]: https://news.ycombinator.com/item?id=20174830 https://news.ycombinator.com/item?id=20174830
- starman100 7y agoPutting an Erlang-like language on the JVM would really lose all the advantages of Erlang, wouldn't it. The syntax, while very useful, isn't the real strength of the language. It's the BEAM.
- brianpgordon 7y agoIt looks like this is actually running the real Erlang/OTP, just with some amount of performance penalty from not being on the BEAM. This could be fantastic for fans of BEAM languages who now have a low-profile way to introduce, say, an Elixir proof of concept into a JVM-dominated infrastructure.
- cuddlecake 7y agoWould it really matter though, whether the underlying VM is JVM or BEAM, if people don't want to code in Erlang or Elixir? I don't think introducing the BEAM is the hard part, I think it's all about the language barrier.
- lostjohnny 7y agoIn my experience the opposite is true. I've been able to introduce the BEAM in a large company (where I work) but the barrier has been they don't know it, they know very well the JVM and they don't care about the language if it can produce a runnable jar. I would really use the JVM more if I could program it in Elixir.
- starman100 7y agoInteresting. I'd really like to see Pytherl. Use the easy-to-learn Python syntax, as best as possible, but on the BEAM. I think that would be even better than Elixir for getting people on board.
- macintux 7y agoYou might like Reia. http://reia-lang.org/ http://reia-lang.org/
- notamy 7y agoSadly it seems like all work on it has been stopped and they recommend using Elixir instead.
- didibus 7y agoI mean, at that point the only difference with Elixir is that you want whitespace delimited blocks over using DO/END. Otherwise, none of the Python semantics make any sense on the BEAM, so I'm not sure that's that helpful, but who knows.
- DanielDent 7y agoI doubt this is quite what you are looking for, but https://github.com/fazibear/export https://github.com/fazibear/export provides simple Elixir/Python interop.
- cupidtrails 7y agoAre you looking for the best platform to make money while traveling? Cupidtrails is the best online platform for instagram travel bloggers and influencers. Visit now!! https://www.cupidtrails.com/ https://www.cupidtrails.com/
- _pmf_ 7y agoGood fit, but I think Elixir already _is_ Clojure on BEAM in spirit (sans Lisp syntax).
- fouc 7y agoHow true is that?
- tosh 7y agoChangelog for 0.5.0 https://github.com/clojerl/clojerl/blob/0.5.0/CHANGELOG.md https://github.com/clojerl/clojerl/blob/0.5.0/CHANGELOG.md
- _jayhack_ 7y agoLove how puns are the go-to in CS
- keymone 7y agoi especially like the QA section explaining "why do it if Hickey said actors are bad" (intentional strawman there): > The points he makes are of course very good. For example, when no state is shared between processes there is some communication overhead, but this isolation is also an advantage under a lot of circumstances. He also mentions here that building for the distributed case (a.k.a processes and message passing) is more complex and not always necessary, so he decided to optimise for the non-distributed case and add distribution to the parts of the system that need it. Rich Hickey calls Erlang "quite impressive", so my interpretation of these writings is that they are more about exposing the rationale behind the decisions and the trade-offs he made when designing Clojure (on the JVM), than about disregarding the actor model. That would be my understanding as well. Clojure and Erlang are ideologically quite close, just made with slightly different purposes. Erlang - to be distributed from the ground up. Clojure - to handle mutability on somewhat lower level and be on JVM, where mutability is the norm.
- namelosw 7y agoThis is brilliant. I'm a shallow Clojure user, I like Clojure but every time I look into 'modern' Clojure code base I would see a lot stuartsierra/component. I know this is quite a library with high quality, but it's more like a sign of compromise - 'we still need stateful component eventually, although we already have 5 different ways to deal with the state, we need another one'. Despite what Rich said about Actors, the state in Erlang/OTP is more well-modeled. The state(process mechanism) is not only playing well with immutable functional languages but also much more robust than OO languages. And it also largely simpifies the mental model - it removes the need of atom/agent/variable/object, etc. Another neat thing, of course, no awkward loop/recur anymore.
- alexeiz 7y agoHow does Clojerl compare to Lisp Flavored Erlang (http://lfe.io/ http://lfe.io/)? LFE looks like a quite mature project and it maps Lisp directly to BEAM. Interestingly, LFE has a collection of Clojure-like macros (https://github.com/rvirding/lfe/blob/develop/doc/lfe_clj.txt https://github.com/rvirding/lfe/blob/develop/doc/lfe_clj.txt).
- tombert 7y agoYou should play with them both, and see what you like more. I don't feel like one is objectively "better" than the other, it's mostly a matter of preference. I personally like LFE a bit better, because of the more-direct mappings to BEAM (as you mentioned). Lisp-Flavoured-Erlang is a very honest name; it feels like you're writing Erlang, just a nice and consistent Lisp syntax. That said, I think Clojerl is pretty neat. I tend to find Clojure's macro syntax a bit cleaner than LFE's Common-Lisp style (I still get tripped up on commas). Also, Lisp-1 semantics are a lot more reasonable...I still hate putting `funcall`s everywhere.