Show me cool, obscure languages!

View other answers to this thread
Start a personal dev blog on your domain for free and grow your readership.

3.4K+ developers have started their personal blogs on Hashnode in the last one month.

Write in Markdown ยท Publish articles on custom domain ยท Gain readership on day zero ยท Automatic GitHub backup and more

Dave Ceddia's photo

The Elixir language is cool. It's a functional language, first released in 2011, and gaining traction lately especially in the Ruby community. Elixir's syntax is inspired by Ruby, and its popular web framework Phoenix is reminiscent of Ruby on Rails.

Elixir is built upon the Erlang virtual machine, which means it inherits many of the superpowers that Erlang is good at -- namely, building large, scalable, fault-tolerant systems. In Elixir, and in Erlang, threads are extremely lightweight and cheap, so they're used all over the place. The Phoenix web framework was able to manage 2 million websocket connections on a single (very large) server.

One of my favorite Elixir features is the pipe operator:

# The normal way:
String.ends_with?(String.reverse(String.capitalize("freddy")), "F")

# The pipe operator way:
"freddy"
|> String.capitalize()
|> String.reverse()
|> String.ends_with?("F")

My other favorite feature is pattern matching, which, among other things, lets you do things like write multiple versions of a function and let the language figure out which one to call:

defmodule Greeter do
  def hello(:jane), do: "Hello Jane"

  def hello(name) do
    "Hello #{name}"
  end
end

Pattern matching also works to pick apart data structures, similar to JavaScript's destructuring:

{result, value} = {:ok, 2}
# result will be :ok
# value will be 2

And if you've ever had to work with binary data in a language like C, shifting bits and masking to get at the bits you want, Elixir's binary pattern matching is mindblowing ๐Ÿ˜„ Here's a nice tutorial on binary pattern matching showing a function to parse PNG files in only about 40 lines of code.

I've must say, I haven't spent a ton of time using Elixir and Phoenix yet, but I'm pretty excited about both.

Mark's photo

Great answer, I like that it has some example features!

It's a shame there are still so many languages without good pattern matching...

It seems people really like Ruby's syntax. I was actually looking at Crystal when posting this question.

Although I have to mention, the normal syntax in many languages would be

"freddy".ends_with?("F").reverse().capitalize()

But I still like the pipe stuff, no need to make everything an instance method that way :-)

Dave Ceddia's photo

Hah, of course ๐Ÿ˜„I probably should've called that "the functional way" or something. I forgot to mention that Elixir is functional at its core, so there aren't any instance methods on strings or anything else! (it does have modules, though, which can group together related functions)