Skip to content

Instantly share code, notes, and snippets.

View jsturg's full-sized avatar

Josh Sturgeon jsturg

View GitHub Profile
@jsturg
jsturg / pure-impure.md
Last active January 18, 2017 21:53 — forked from tomekowal/pure-impure.md
Pure vs impure

Pure vs impure and why should I care?

Some of the most important advancements in programming came from adding restrictions to the way we program. Famous article by Edsger Dijkstra Go To Statement Considered Harmful shows how introducing one statement into programming language breaks many key properties of that language. Using goto gives us freedom and solves a couple of simple problems like breaking from nested loops easily, but it can make programs very hard to understand.

This happens, because we cannot look at two pieces of code in separation. The execution can jump to some other place in code or even worse: it can jump from another piece of code to here and we need to keep that in mind.

@jsturg
jsturg / Elixirdesignpatterns.md
Created December 7, 2016 17:40 — forked from itsderek23/Elixirdesignpatterns.md
Elixir foundations for Ruby Devs: transforming data

Elixir foundations for Ruby Devs: transforming data

Have you ever reached for a drink of water, then realized, half-way through your first sip, it was Sprite? I like Sprite, but that first sip of a similar-looking, but very different liquid is a shock.

That's how Elixir can feel if you're coming from Ruby. The syntax looks similar, but Elixir is different from the first sip. For a smooth transition, you need to (a) learn some functional programming patterns and (b) unlearn some Object-Orientated habits.

A core design pattern of Elixir is the focus on data transformations: you'll see it in libraries like Ecto.Changeset, Ecto.Multi, Plug.Conn and built-ins like Enum. Let's dive in.

Data Transformations