We're planting a tree for every job application! Click here to learn more

"Code like Lego(tm)"

R H

23 Nov 2021

•

1 min read

"Code like Lego(tm)"
  • Elixir

Love at first sight :)

When I first stumbled across Elixir I was thrilled to discover the syntax was almost identical to that of the Ruby language. The power of Erlang available through a Ruby-like syntax. "What a find!", I thought.

A study project

To learn Elixir basics I dreamt up a trivial study project based around the beautiful simplicity of functions that always return one of two things, {:ok, result} or {:error, reason}.

The scene was set!

If our functions only return two types of tuple it makes it easy for us to chain them together:

One.func(45, "a string", 3.142)
|> Two.func("foobar")
|> Three.func()

Function Two.func/2 knows exactly what to expect from One.func/3; function Three.func/1 knows exactly what to expect from Two.func/2. Great!

But then I said, let's make all functions look the same (argument-wise) and call them 'modifiers' (after all, that's what they are!)

Code like Lego(tm)

ModifyChain provides the scaffolding that allows you to flexibly 'run' a 'chain' of standard, built-in modifiers and makes it easy to mix and blend them with ones you create yourself.

So the idea is that you can build anything, on the fly, by chaining together modifiers in different ways -- just like building a Lego model!

Conclusion

A super simple project to get my feet wet with Elixir and the creation, inadvertently, of a new, fun, easily extensible, scripting language -- ModifyChain Script!

Did you like this article?

R H

See other articles by R

Related jobs

See all

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Title

The company

  • Remote

Related articles

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

•

12 Sep 2021

JavaScript Functional Style Made Simple

JavaScript Functional Style Made Simple

Daniel Boros

•

12 Sep 2021

WorksHub

CareersCompaniesSitemapFunctional WorksBlockchain WorksJavaScript WorksAI WorksGolang WorksJava WorksPython WorksRemote Works
hello@works-hub.com

Ground Floor, Verse Building, 18 Brunswick Place, London, N1 6DZ

108 E 16th Street, New York, NY 10003

Subscribe to our newsletter

Join over 111,000 others and get access to exclusive content, job opportunities and more!

© 2024 WorksHub

Privacy PolicyDeveloped by WorksHub