pillaiindu

pillaiindu

How much is Elixir "strong" comparing to LISP?

Cross posting from reddit

The blog post Beating the Averages says that LISP is the strongest languages. Because it have Macros and bla bla, and when you write some software in this language a big portion (from 20 to 30%) of your code is basically Macros, and the post also says that it’s a good thing.

Also I read this quote somewhere:
“Lisp is a programmable programming language.”
— John Foderaro, CACM, September 1991

The above post is almost 14 or 15 years old and that time there was no Clojure, Scala or Elixir.
So how strong(er) or weak(er) Clojure or Elixir are comparing to common LISP?

And more importantly, will learning common LIPS make someone a better Clojure or a better Elixir programmer?

Most Liked Switch mode

easco

easco

The above post is almost 14 or 15 years old and that time there was no Clojure, Scala or Elixir.
So how strong(er) or weak(er) Clojure or Elixir are comparing to common LISP?

LISP is well-liked language for a variety of reasons. Certainly Macros play a role in that because it makes it practical to write Domain Specific Languages that are homoiconic with the language itself. Elixir’s macro structure can be used for similar reasons and if you get into Elixir macros you will find that the language is structured from homoiconic three-element tuples that one could potentially write in just like LISP.

In either case you have a turing complete language that offers you the ability to write useful programs. Elixir, and more specifically the underlying runtime system, has some built-in mechanisms directly supportive of concurrency and parallelism that makes it convenient to use when solving problems that involve those topics. One can (and Robert Virding has LFE (programming language) - Wikipedia written a LISP language on top of that runtime.

In short it depends on how you define “stronger”. Stronger at solving a set of problems involving concurrency and parallelism? I might give Elixir the edge there. But trying to compare programming languages rarely produces cut and dried results.

And more importantly, will learning common LIPS [sic] make someone a better Clojure or a better Elixir programmer?

Learning another programming language will usually make one a better programmer. One of the things I did which I personally felt enriched by was following the MIT Open courseware videos on the Structure and Interpretation of Computer Programs. It uses a LISP variant (Scheme in this case) to present some fundamental concepts of the theory of computation. Having those ideas in my head has allowed me to approach problems in new ways, regardless of programming language, and that has made me a better programmer. Swift and Scala gave me similar insights about types and type systems. Common patterns one finds in Objective-C thought me about Delegation and dynamic dispatch systems. Each language, and each environment, can teach you something if you let it. So “Yes” I believe that studying Common Lisp and Clojure could help you be a better Elixir programmer.

sribe

sribe

Heh, I remember an interview with Andrei Alexandrescu (C++ meta-programming wizard) who said that he’d learned valuable things from every programming language he’d ever used. Except Java, that there was absolutely nothing new or insightful to learn there…

OvermindDL1

OvermindDL1

I’ve also written a Lisp on top of elixir, lisp is dead-simple to create. But how about this for an example of it’s power:

First, Elixir has an AST, you cannot create or invent new forms, you can only make function-like things and parse already ‘formed’ expressions within those calls. Second, in Elixir you can parse a string at compile time (which is what I do with my elixir lisp), but the string is delimited, thankfully Elixir has a way around it by using things like ~L{lispy code} or so, but if you end up using } anywhere in the string then it dies, same regardless of the identifiers you use.

In comparison, I’ll use my elixir lisp as an example since it is more Elixir’y than normal lisp, there is no real form, there are just lists and symbols. A list is delimited by (/) (unless escaped via \), and everything else is a symbol, separated by whitespace (again, unless escaped). So if you want to define a number just doing 42 will not work, you’ve gotta do (integer 42) for example, or (atom blah) or (list a (integer 42) (float 6.28)) or (string This\ is\ a\ string), nasty painful and such. So you can simplify some things via macro’s, so like the above list one you could write a macro so you could just do something like (mymacro blah 42 6.28) and it expands it to the above list. However that is just like defining new functions, just like you can do in elixir, it is not really making new syntax, for that you need read-macro’s, which my lisp also supports in spades. I have a few built-in read-macro’s, like one triggers on : at the start of an expression, it then parses the next symbol (or fails if a list) and just wraps it in the (atom ...) list. I have one that reads based on " and reads characters until it hits an unescaped " (it supports a few other escapes as well) then just wraps that all up as a (string ...) as a single symbol. I have one that starts with a [ and reads sexpr’s until it hits a matching unescaped ] (since it reads sexpr’s it recurses back into the parser so you can have embedded [ no problem as one example) and wraps that up in the (list ...). And one that reads a { and is like list but wraps it up in (tuple ...). And one for %{ that wraps it up in a (map ...). I could actually quite easily (and it is planned) to make some kind of elixir read-macro that then passes the stream to the elixir parser to get the elixir ast back (essentially an elixir quote). The ‘magic’ of Lisp is that you can make domain specific languages for any problem you could possibly ever experience, able to add any functionality that any other language has or could ever have, and thanks to it’s macros and read-macro’s both then it can be as succinct and readable (even parenthesis-less if you really want) as you can imagine. You can embed Elixir in lisp, or python in lisp, and it all just compiles down to lisp.

Lisp itself is not so much a language to write programs in, but rather it is a language to write languages in which to write programs. :slight_smile:

And yes, Lisp is one of those languages you should definitely learn and keep learning until you finally get that *click* moment when everything becomes clear about why it is used, and I’m not just talking about treating code as data and data as code, I mean the way you can define any problem in it in a way that is natural to that problem. :slight_smile:

Last Post!

sribe

sribe

SICP calls it “meta-linguistic abstraction”, and they emphasize the notion that the path to good code involves bringing the language closer to the problem.

Where Next?

Trending in Questions Top

jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
saveman71
Hello ! We want new/edit form pages to POST/PUT to their own URL rather than the resources REST defaults (post /things, put /things/:id)...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement