Web Development
-
Sick of the stupid jokes? Write your own arbitrary-precision JavaScript math library
Written by James SinclairJavascript has its fair share of ‘wat’ moments. Even though most of them have a logical explanation once you dig in, they can still be surprising. But JavaScript doesn’t deserve all the indignant laughter. And now that BigInt is officially part of the TC39 ECMAScript standard, we have options. I’m going to show you how to take advantage of them.
-
The Algebraic Structure of Functions, illustrated using React components
Written by James SinclairDid you know there’s an algebraic structure for functions? That may not surprise you at all. But it surprised me when I first found out about it. I knew we used functions to build algebraic structures. It never occurred to me that functions themselves might have an algebraic structure. The structure is fascinating, but functions can be rather abstract. So we’ll look at some concrete things we can do with React functional components.
-
What’s more fantastic than fantasy land? An Introduction to Static land
Written by James SinclairFantasy land is great. It opens up a whole world of interoperable functions and structures. And the title, though originally a joke, is quite fitting. But Fantasy land isn’t perfect. And it’s not the only way to do algebraic structures in JavaScript.
-
Algebraic Data Types: Things I wish someone had explained about functional programming
Written by James SinclairAlgebraic data types and algebraic data structures sound similar. It’s like they ought to be the same thing. But they’re not. They both have ‘algebraic’ in the name, so it’s confusing. I got them mixed up at times. Others have too. But, they’re different concepts. Understanding the difference will help if you’re trying to learn functional programming.
-
Type Classes: Things I wish someone had explained about functional programming
Written by James SinclairType classes are not the same thing as algebraic structures. But you’ll find many people use the terms interchangably. And that can be confusing. It confused me for a long time. In this article we look at what type classes actually are. And we’ll also look at why programmers from other languages are so enthusiastic about them.
-
Algebraic Structures: Things I wish someone had explained about functional programming
Written by James SinclairAlgebraic Structures are something I wish I’d understood better, sooner. I had a hazy idea of what they were, but didn’t know the correct terminology. That was a massive barrier to finding out more. This article is my attempt to stop that happening to others. We’ll look at: What are algebraic structures? How do we use them in JavaScript? Why would we bother? What’s the big deal?
-
Things I wish someone had explained about functional programming
Written by James SinclairIt’s hard learning functional programming on your own. But it ought not to be. You don’t need a PhD to understand functional programming. The concepts are abstract, yes. But that doesn’t make them incomprehensible. It shouldn’t be this difficult. This is the first in a four-part series on things I wish someone had explained to me about functional programming.
-
Functional JavaScript: What are higher-order functions, and why should anyone care?
Written by James Sinclair“Higher-order function” is one of those phrases people throw around a lot. But it’s rare for anyone to stop to explain what that means. Perhaps you already know what a higher-order function is. But how do we use them in the real world? What are some practical examples of when and how they’re useful? Can we use them for manipulating the DOM? Or, are people who use higher-order functions showing off? Are they over-complicating code for no good reason?
-
Functional JavaScript: Traversing Trees with a Recursive Reduce
Written by James SinclairTrees come up a lot in web development. As in, more than you would expect. They pop up all over the place. But trees can be tricky. If you’re like me, you know that there ought to be a way to process them neatly. You might want to change all the values, or make some calculation on the tree. But the way to do it isn’t always obvious. And utility libraries like Ramda or Lodash don’t come with tree-traversing functions. So, what do we do?
-
Magical, Mystical JavaScript Transducers
Written by James SinclairTransducers are very cool. They give us a lot of power. But they are also a bit abstract. And that makes them hard to explain. But they also embody the dream of functional programming. We write tiny, simple functions. Then we piece them together with flexible tools that work for lots of different data structures. And we end up with powerful, performant programs.