Blog

  • Errors as Values: Free Yourself From Unexpected Runtime Exceptions

    Introduction

    When I try to sell people on Functional Programming, I’ll say things like “Imagine a world with no null pointer exceptions”. That’s a bit misleading as I’m actually referring to is the power of a sound types.

    However, it’s assumed in Functional Programming that do not have runtime Exceptions at all. Instead, functions that can fail will return if they worked or not. When referring to this, people will sometimes say “Errors as Values” instead of Errors being a runtime exception that has the error inside of it. That belief system is what I want embraced, not sound types as many are using dynamic languages, so the belief is more impactful in those type-less areas.

    It’s quite an alien viewpoint, and hard to visualize how you’d program this way if you’ve never been exposed to it. This is especially true if you’re using non-FP languages (excluding Go and Lua) which can look weird if you start returning values.

    This is a bit nuanced so I wanted to cover this core concept here so people clearly understand you can live in a programming world without unexpected runtime exceptions. Keyword there: “unexpected”. You can do this returning errors from functions instead of intentionally raising errors. Optionally, using sound types will get you to 100% of code, while not solving resource exhaustion exceptions.

    The benefit to you? Your code is more predictable, you can release to production with more confidence, and you can deliver more features, faster.

    You do this by treating errors as values; just like you return a string or number of discriminated union from a function, so too can you return an error instead of throwing/raising it.

    (more…)
  • Converting a JavaScript Library to ReScript

    Introduction

    I spent the past couple of years playing around with Reason, which later split off into ReScript: the OCAML for JavaScript developers. Last weekend, I finally was productive. I wanted to cover what I’ve learned in the past 2 years, and even this weekend. My hope is it will inspire you to check out what ReScript has to offer compared to TypeScript.

    (more…)
  • In Search of the Best Functional Programming Back-End: 2021 Update

    Introduction

    For 3 years I’ve been searching for an enjoyable language to use in writing back-end code, for API’s & Serverless. Specifically a strictly typed, functional one.

    I haven’t found it.

    However, I have learned a lot, and though I’d share a summary of that below. Both to hopefully inspire readers, and in hopes someone can either fill in some gaps, or shed light in a new direction I should look.

    (more…)
  • Beecher Ridge Backcountry Camping

    Beecher Ridge Backcountry Camping

    Emboldened by my last backcountry camping trip, I wanted to try a different place. Meaning, hike into the wilderness carrying all you need, camp somewhere random in the forest, then hike out the next day. While there are trails, most backcountry often doesn’t have designated camping spots; you just have to find your own while not hurting the plants. Below is what I did and learned.

    (more…)