The enchanted electrical website of Dr. Sinclair
-
Rethinking the JavaScript ternary operator
Written by James SinclairLots of people treat the ternary operator with suspicion. At first glance, ternaries appear unnecessary. Nothing more than a tool for the overly clever to trim some characters from their code. A favourite hack for coders who don’t care about readability. And sure, it’s all too easy to turn ternaries into an indecipherable mess. But what if we’re missing something? What if there’s more to ternaries than meets the eye?
-
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.
-
Remote teams and the half-life of social capital
Written by James SinclairRemote work is a mixed bag. Some aspects are wonderful. The lack of commute and extra flexibility is great. But there are drawbacks. Being remote comes with radical changes to how we communicate. Things that were effortless and unconscious in person become tiresome when we’re remote. And right now, so many of us are trying out this remote experiment together. But as time goes on, maybe the novelty is starting to wear off.
-
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.
-
How to write things people actually want to read
Written by James SinclairStaring at a blank screen can be scary. And writing is hard work. Don’t let anyone tell you different. It takes extended periods of concentration to write anything significant. And that’s a rare commodity these days. And even if you manage to beat your attention into submission, the craft of writing is still complex. It can be tough to know where to start. What if my writing turns out to be boring? What if nobody reads it? What if people hate it? Or worse, they start reading and get so bored they quit?
-
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.