Software

A collection of posts about my favourite topics in programming

5 reasons why Hugo is better than Gatsby

Hugo is an amazingly underrated static site generator and this post is aimed to provide some examples on why it may be a better choice than Gatsby for your next static site!

TLDR;

  1. Hugo builds are way faster than Gatsby
  2. Hugo’s template system is simple
  3. Hugo’s built-in features are better than Gatsby’s plugin features
  4. Hugo doesn’t require any JS to be used, but supports JS with ESBuild
  5. Hugo has a small learning curve

1. Build Times

Gatsby

Read more →

Using TypeScript ADT’s to write more reliable React

You may have heard of Algebraic Data Types (ADT’s) before but didn’t understand how they can be applied to everyday code - so this article will provide some examples and explanations of why you should start using them.

Before we get into ADT’s, let’s go over the foundation of what ADT’s are made of.

Basic Types

In Javascript, you can not declare a type that prevents other types from being assigned to it. The below example we see that anything can be assigned to the language variable. We can assign a number or a boolean or an object to it if we later wanted, but that may cause bugs in the future if we were not expecting the variable type to be something other than a string.

Read more →

Lessons learned from my first 10k LOC in Elm

I have been working on a personal project of mine for the last couple of months that has the frontend written in Elm. So far everything is going great and the project is around 10k lines of code.

I have noticed a few reoccurring patterns of mine that I have learned so far and want to share, so here are 5 things I have learned:

1. Decoding Empty Lists & Strings

When I first started the project, I had a lot of types with fields declared like this:

Read more →

Pratica, now fully in Typescript!

Pratica is now written completely in Typescript!

What is Pratica?

Pratica is a super tiny 720B monadic library, comparable to Crocks or Monet JS.

Why would I use Pratica?

If you want to start writing more functional code in Javascript or Typescript, this is a great library for learning some FP fundamentals, while also making your code safer and more resilient to runtime bugs. It’s super tiny size and easy to read dot-chaining syntax makes it easy to get started in any project.

Read more →

Elm’s Remote Data Type in Javascript

Often in web development there is this recurring pattern of having to fetch some data from some server through a rest api, and then show it someway in the UI.

This often includes storing this data somewhere on the client side, either in a store or just a variable you can reference, and this is where the Remote Data type can help.

Usually saving the data would look something like this in JS:

Read more →

Comparing Elm to React/Redux

I have recently been exploring creating web apps in Elm and found it to be a breath of fresh air compared to the usual React/Redux projects I have worked on in the past.

*Disclaimer: I still think React/Redux is great and viable for large teams if done correctly. This article will just explain my pain points with it while working on large teams at various companies, and why I think Elm can be a better alternative in some cases.

Read more →