leifericf

leifericf

Hello, friends!

Context:

As you might know from this thread, I’m working on a presentation.

Following a tour of Erlang history, I have a slide which reads:

“If Erlang is so great, then why should I bother with Elixir?”

On the following slide, I mention that Erlang has a somewhat alien syntax, since it was influenced by Prolog and Smalltalk. New programmers can find that scary and off-putting.

I go on to mention that one of the reasons to choose Elixir is that the syntax is more modern, familiar and user-friendly than its big brother, Erlang. I mention that is feels kind of Ruby-esque. Of course, I also point out that Elixir only looks like Ruby on the surface and that it is fundamentally different.

Problem:

In order to make this comparison more immediate, I would like to show some semantically equivalent code-snippets from Erlang and Elixir, side-by-side. They need to be short enough to fit on one slide.

Some of the attendees have never seen Erlang or Elixir code before. I have not shown any code examples up until this point in the presentation, as it is very high-level.

I’m struggling to come up with some good examples that show off the differences between Erlang and Elixir. Preferably, it would highlight some unique features as well, e.g. pattern matching.

Question:

Could I ask for your help? If you wanted to illustrate the syntactical differences between Erlang and Elixir, what do you think would be some good (and terse) examples?

I will also refer to this forum thread in my presentation, so attendees can see more examples.

Showing Posts 1 to 10

leifericf

leifericf OP

After a few hours of Googling, I discover that we have this page on the official website :joy:

That’s pretty much exactly what I was looking for.

But if you have any other examples, I would gladly take those as well!

leifericf

leifericf OP

For the curious, here is the comparison slide I ended up with:

I might change it or add a few more.

gregvaughn

gregvaughn

I’m not sure how much Smalltalk influence there is in the syntax. Prolog is the main influence I’ve heard about.

One other thing that might fit on the slide is to have a second clause for some_fun/1. In Erlang you’ll need to separate the clauses with a semi-colon, but Elixir has no explicit syntax for that.

leifericf

leifericf OP

Yeah, me neither to be honest. I just joinked’ that part straight from Wikipedia :blush:

Good tip, thanks! I’ll probably add a couple more example slides.

NobbZ

NobbZ

This slide does not only compare syntax. It also swaps out functions from the stdlibs.

Additionally you use atoms (single quotes) on the erlang slide, where you should use strings (double quotes).

And IO.inspect is more like using ~p in :io.format, as ~s will fail with badarg when given a tuple, while IO.inspect will happily print it out. Also a noteworthy difference is, that :io.format returns :ok, IO.inspect returns the inspected value.

leifericf

leifericf OP

Yes, it does show more than only syntax. Maybe that’s a good thing?

My goal is to have one or a few code snippets to illustrate differences between Erlang and Elixir. I suppose I could have been more precise about that in my post (syntax only is too narrow).

I will rename the slide to only “Comparison” instead of “Syntax Comparison.”

Do you have any ideas of what might make for a better example?

NobbZ

NobbZ

For a general comparison of language and how to use it, it is sufficient, as soon as you replace the singlequotes by doublequotes in the io:format examples.

leifericf

leifericf OP

Thanks for the tips!

easco

easco

If you desire is to show how Erlang and Elixir syntax are different then it might not be such a good thing.

However the difference between these two languages is much more than syntax. Do you have other slides to cover things like:

• Consistency in the Standard API
• Polymorphism (e.g. Enum)
• Metaprogramming
• Package tool (Hex)

  • Build/project management tool (mix)

These are all things that Elixir brings to the Erlang ecosystem above and beyond syntax

leifericf

leifericf OP

Thanks for the tips!

This will be a very high-level presentation of about 45 minutes for people who have never seen Erlang or Elixir before and some have never programmed in any language.

I do mention Hex in there, though (and other tools).

Those areas you mentioned are also interesting, so I might include those in some future talks at our newly created Meetup group. Can’t have too many topics from which to choose! :smiley:

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews