Hacker News new | ask | show | jobs
by vendiddy 1804 days ago
Elixir afaik has taken a lot of inspiration from clojure and lisp type languages.

It's not readily apparent from the ruby like syntax though.

1 comments

its funny you say that, Ruby ALSO took a lot from Lisp and lisp like langugaes. there's even a built in parser in Ruby that converts the language into S-expressions

  require 'ripper'
  Ripper.sexp('a && b')
  => [:program, [[:binary, [:vcall, [:@ident, "a", [1, 0]]],    :"&&", [:vcall, [:@ident, "b", [1, 5]]]]]]
  Ripper.sexp(<<-RB)
    if a
      b
    else
      c
    end
  RB
  => [:program, [[:if, [:vcall, [:@ident, "a", [1, 5]]],   [[:vcall, [:@ident, "b", [2, 4]]]], [:else, [[:vcall, [:@ident,  "c", [4, 4]]]]]]]]
  
Ruby is just way denser than most lisps.

I love Ruby, Elixir, and Lisp(s)

Didn't know that!

One striking similarly Elixir has to lisp style languages is the macro system. You have quoted and unquoted expressions just like lisp.

And like lisp most of Elixir, down to the low level stuff like if statements, modules, and so on, is built up from a few primitives.

Here are the primitives that the Elixir language is built from:

https://hexdocs.pm/elixir/1.12/Kernel.SpecialForms.html