top | item 12157293

Lisp Flavoured Erlang

129 points| indatawetrust | 9 years ago |lfe.io

44 comments

order

macintux|9 years ago

One of the particularly nice things about LFE is the team's commitment to documentation. Duncan McGreggor has done a great job.

edem|9 years ago

I think it would be nice to see some comparison to Clojure for example which is a JVM-integrated lisp-1. I have for example Elixir on my radar for a while but I'm very interested in seeing more lisp dialects running on popular VM implementations. My point is that I don't know how to compare this to Clojure (in my case). What advantages does it have and why should I use it?

DigitalJack|9 years ago

I am a fan of clojure. I'm interested in LFE, but I've been focussing on learning Haskell lately, and don't want to switch gears yet.

The big thing that I miss in clojure are the data structures, and the ease of use of those data structures. Specifically vectors and maps. These exist all over the place, but no where (in my experience) are they as pain-free as clojure.

That combined with their immutability (yet easy to transform) is a really significant win for productivity.

As I've looked for other languages to learn, those sorts of easy to use and highly productive datastructures has been a top criteria.

Haskell has them, but I wouldn't put them on the easy to use list yet. However I'm still learning, and it might just come down to familiarity.

Chicken Scheme has them as an egg, but the syntax makes them far more encumbering than clojure.

If LFE has the same unencumbered immutable datastructures for maps and vectors, well, that would be exciting to me.

i_s|9 years ago

As a Clojure fan, I tried using this, but I got the impression it has learned next to nothing from Clojure, so I ended up going with Elixir instead.

Particularly:

- No data structure literals (?) - (except e.g., '(1 2 3) for lists)

- Manual module exports, instead of just having 2 versions of def

- Other small syntactic annoyances, like plain parens everywhere, instead of brackets in some cases like Clojure, and atoms (like keywords in clojure) started with "'" rather than ":"

rkallos|9 years ago

LFE does have data structure literals for some of the main data types in Erlang. You have #() for tuples, #M() for maps, and #B() for binary syntax. Clojure additionally has syntax for vector literals, but vectors don't seem to be used very often in Erlang, though there is an Erlang module for dynamic arrays which is accessible in LFE. If you felt so inclined, I believe you could extend the LFE reader to add syntax for arbitrary data structures.

I'd guess that the manual module exports are a design decision inherited from Erlang, where you specify exported functions with the -export() macro.

As for the rest of the syntax; it appears (to me, at least) that LFE doesn't deviate terribly much from traditional Lisp syntax, while still being transparent about the underlying Erlang data types being used. Clojure took the opportunity to introduce a more opinionated Lispy syntax. This really boils down to personal preference.

All in all, I think that the various design decisions of LFE and Clojure make a lot more sense when you consider their respective host languages/VMs.

hashkb|9 years ago

Why assume every new lisp should borrow from Clojure? I think the extra parens types are annoying and unnecessary, personally. Clojure is pretty different from most lisps, maybe lfe is going for wider appeal?

i_s|9 years ago

In general, it seems like the authors of Elixir were able to capture more of the cool things about Clojure than LFE. Check out some of the top level functions in Elixir:

  update_in
  put_in
  get_in
http://elixir-lang.org/docs/stable/elixir/Kernel.html#update...

These are basically right out of Clojure. It may seem like a small thing, but consistent, well thought out functions like this makes working with immutable data structures much easier.

tazjin|9 years ago

There is also Joxa, a somewhat Clojure-inspired Lisp on the BEAM VM: http://joxa.org/

Note that other languages on BEAM are much more "first-class" than other languages on the JVM, meaning interoperability is usually a lot easier.

lispm|9 years ago

> but I got the impression it has learned next to nothing from Clojure

I think that's a feature, since Clojure basically has no Lisp compatibility at all. No prior Lisp code runs in Clojure as it has zero backwards compatibility. Clojure has randomly renamed concepts which were known in Lisp already or removed them. Lists are no longer lists, ATOM means something entirely different, etc etc.

Though the compatibility of LFE with other dialects isn't that great in general:

http://lfex.github.io/hyperpolyglot/

izietto|9 years ago

I love the website!!!

grenoire|9 years ago

[deleted]

insulanian|9 years ago

Unless one of the many right to left scripts is the one you learned first instead of the latin.

amelius|9 years ago

That cup of coffee in the logo suggests they are compiling to the Java JVM. If true, this makes me wonder why aren't they using Erlang itself as a target?

eggy|9 years ago

No, it is built right on top of Erlang for seamless integration, and of note is that it was created by Robert Virding, one of the original creators of Erlang along with Joe Armstrong.

LFE macros deliver true homoiconicity to Erlang. It is a Lisp 2, and supports function and macro definitions at the REPL.

I prefer it to Elixir, because I prefer Lisp. Robert has also created a Lua 5.2 written in pure Erlang.

Evidently, Erlang's actors and BEAM VM were influenced by the JVM and Scala, so I guess doing a JVM Erjang was in the cards. [1]

[1] https://www.infoq.com/news/2011/04/erlang-copied-jvm-and-sca...

hellofunk|9 years ago

That logo does not even remotely resemble the Java logo.

There are literally thousands of companies in the world using a bird in their logo, but they are not all the same company/organization/concept.

iamd3vil|9 years ago

They are not compiling to JVM. LFE compiles to BEAM.

toast0|9 years ago

I've only recently become a coffee drinker, but if someone gives me purple coffee, I'm not drinking it! We didn't even have purple coffee at Yahoo! I think that's tea.