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?
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.
> Specifically vectors and maps. These exist all over the place, but no where (in my experience) are they as pain-free as clojure.
You don't use vectors very much on the BEAM in general, so I wouldn't consider this very important. Maps are more popular, but have a complicated relationship with records and records have, due to historical reasons, not seen much light on the BEAM in general until lately.
Tuples, which you could use as vectors, sort of, can be written as follows:
(tuple 'hey 'ho "let's go") <-> #(hey ho "let's go")
Tuples are infinitely more important than maps on the BEAM and so they deserve special syntax.
I think insisting that everything should be like Clojure is a great way to not really see anything different. While I understand that your idea is that "everything else should see what's so great about Clojure", maybe you could take that to heart as well.
Edit, addition: I wonder what the stats on posts starting with "I'm/As a Clojure fan..." are. If someone is an Archlinux user, a vegan, a crossfitter and a Clojure user, which do they tell you first?
I prefaced with clojure fan to give context for my post. As a clojure fan, my point of view is going to be from a clojurist. It's a clue as to how to remove bias.
I don't think everything should be like clojure, I just think clojure gets datastructures right in ways that I haven't seen in other languages. I don't think I insisted on everything, or anything, being like clojure.
Right now my dream language would be mostly haskell with clojure maps. Next year it could be something different.
"Maps are more popular, but have a complicated relationship with records and maps have, due to historical reasons, not seen much light on the BEAM in general until lately."
The correction is that maps are the rarer thing, whereas records are more common, due to their lightweight implementation (tuples).
> 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.
I'm not sure I understand. Why do you miss them when you have them in Clojure? Is it a typo and you meant to say LFE?
By the way one of my biggest productivity boost for me is the hot code swap which works in Clojure seamlessly. In java you can't do this wihtout JRebel for example. What is the case with LFE?
I think (s)he meant that they are a feature in clojure that is missed in LFE. The sentence construction is a bit off, but I read it as "[I miss](in LFE)[in clojure are the data structures]". That is, the "in clojure" is the data structures, not where it is missed.
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 ":"
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.
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 can't prove that it should. Just providing a list of initial impressions from someone who has been using Clojure for a while, FWIW. It's necessarily subjective.
Seems like it would be a good idea though, since Clojure is a new lisp that has gotten a decent amount of traction in industry.
I think a lot of that has to do with Java interop. I could be wrong but IMO the language features people rave about are all balanced by warts. I like Clj and I like CL and many Schemes. Diversity is cool.
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:
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.
"update", "put" are already available in Erlang[0] and work with nested records[1] if I understand correctly. Likewise, it seems that LFE has map-update for the same use cases[2].
> 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:
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?
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]
> The BEAM VM was being worked on in 1992 a year after work on Java in 1991.
You're right. What I meant by "still earlier than Java" is "still earlier than
first public Java version", so there was no possibility to borrow anything.
BEAM was just one of a series of virtual machines that implement the Erlang language, so it's not really fair to compare it to Java (just as HotSpot was built a few years after Java).
The LFE compiler is referenced deeper in the documentation[1]. I also had to hunt to answer that question after the tutorial gave an example of compiling one of the example modules.
Erlang, LFE, and Elixir are all compiled languages, yes.
Having said that, they all support interactivity via a shell, including dynamically defining functions and tweaking the runtime. LFE does a better job at functions than Erlang; I'd wager Elixir too, but haven't looked closely at it.
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.