Photo by Daniel von Appen on Unsplash

Functional programming is a deep topic that has foundations in some pretty complicated mathematics. Luckily, you don’t have to understand all that to benefit from using functional techniques in your code. You probably use some already — array methods like map and filter have their origins in functional programming, but they’re implemented in many non-functional languages as well.

That being said, learning more about functional programming can help you make the most of these features. I recently worked through a helpful guide to functional programming in JS, which I highly recommend. It goes over a lot more than I can…

This December I’ve been working though the latest iteration of Advent of Code. In case you haven’t seen it before, it consists of one holiday-themed coding challenge per day until Christmas. I decided I’d work through these challenges using Elixir, in order to help reinforce my understanding of the language.

Elixir is a functional language that doesn’t allow mutable data. Once defined, a piece of data stays the same way until it’s discarded. If an application needs to change state, you have to create a brand new piece of data to use in place of the old state, rather than…

Photo by Michelle McEwen on Unsplash

The rules of bowling seem simple: there are 10 frames per game, each frame has 10 pins, and for each frame you get two chances to knock down those pins. But there are a lot of weird conditions and edge cases. You get points for the pins you knock down, but also bonus points based on previous strikes and spares. Frames have two rolls each, except when you get a strike and immediately move to the next frame after the first roll. …

Photo by Andrew Buchanan on Unsplash

I try to spend some time each week practicing algorithms. Lately, I’ve been challenging myself to find solutions that are optimized for readability and clarity, not just time or space complexity. A well-written solution should be organized in a way that makes its key ideas as explicit as possible. Approaching algorithms this way helps me understand my solutions and explain them to others.

Let me illustrate this approach by applying it to the LeetCode problem First Missing Positive. Figuring this one out was a fascinating challenge. I’ll share my thought process and how I approached writing my solution.

The Challenge

Before we…

Photo by Samuel Sianipar on Unsplash

It can be really valuable to learn a new programming language, even if the what you learn doesn’t become your language of choice for day-to-day coding. Learning a new language (especially one that’s built around a different paradigm than what you’re used to) exposes you to new concepts and approaches, making it a great way to grow as a programmer.

In this spirit, I recently took a deep dive into Elixir, a functional programming language with an interesting approach to concurrency. Elixir has a lot of cool features, but there’s one in particular that I really miss now that I’m…

Photo by Nick Fewings on Unsplash

JavaScript is a multi-paradigm programming language that allows certain functional programming techniques. It does this by supporting the use of first-class functions — functions that can be stored in variables and treated like data. JavaScript functions can even be passed to other functions as inputs, and they can be returned from other functions as outputs. This is a seemingly small feature, but it can have enormous consequences for how you write code.

Unfortunately, many JavaScript newcomers have a hard time understanding the functional side of the language. …

Photo by Halacious on Unsplash

Building layouts is an important but challenging aspect of front-end development. Given this, it’s no surprise that CSS has a lot of layout-building tools to choose from. I’ll be talking about one of them here: the position property. This is a powerful tool that can create some impressive effects, but it’s also easily misunderstood and misused. There’s so much that I wish I had known when I was first learning CSS, and I’m going to try to share as much as I can. Let’s get started!

Ways to Position with CSS

We’ll start by looking at the ways of positioning HTML elements through CSS. …

One of the big advantages of React is that it lets you make complex components out of other React components. For instance, you might make a Form component that contains a SubmitButton component and multiple TextInput components. You can even build components recursively, where a component of a certain kind contains more instances of that same kind of component. This is a powerful technique that can be used to create components that exhibit some pretty cool behavior.

To demonstrate how this works, I’ll walk through the process of making an Orbiter component, which will allow us to animate circles so…

Contemporary programming languages allow various ways of repeatedly calling a function. For instance, some options in JavaScript include:

  1. Iterating with a for or while loop.
  2. Iterating with forEach on an array.
  3. Recursively calling a named function from within itself.

But imagine a world where ECMA suddenly removes for, while, forEach, and named functions from Javascript. In that world, could we still perform all of the computations that are currently possible?

It turns out we could! As long as JavaScript allows first-class functions (functions that can take other functions as arguments) we’ll be able to write all of the same recursive…

Ruby’s each is a powerful, general-purpose method for iterating over arrays. At least in theory, anything you want to do with the elements of an array can be done with each. This can make it tempting to ignore the other, more special-purpose iteration methods that Ruby has to offer. Why bother memorizing more syntax when each alone can suffice?

The answer is simple: using special-purpose iteration methods makes your code better. Using these methods helps you code more quickly, leaving you with more time to write the code that matters. Remembering these methods also makes it easier to remember the…

Ian Grubb

Full stack web developer and educator. Former software engineering coach at Flatiron School and adjunct professor in philosophy at NYU.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store