2 min read

Tech Snippets #5

Welcome to the fifth part of Tech Snippets 🤓


How big is a kilobyte?

How big is a kilobyte, 1000 or 1024 bytes? What do you think?

Spoiler

tl;dr: either 1000 bytes or 1024 bytes, but there’s no consensus.

How big is a kilobyte?
1000 bytes, or 1024? There’s no agreement.

Announcing “use-sound”, a React Hook for Sound Effects

I am currently working on a multiplayer online game project using React and needed to add some sound to it. That is how I found the npm package use-sound by Joshua Comeau and he also created a great article on how to use it. But also on how to find good sounds, preparing it and accessibility.

Additionally, this article comes with a lot of interactive examples. It is definitely worth checking out.

Announcing “use-sound”, a React Hook for Sound Effects
By and large, using the web is a visual experience. This is in terrible contrast to mobile apps, which interact with three of our human senses (sight, sound, and touch, through haptic feedback). I just released a library to make it easy to add sound to your React app, and I make the case that you should consider using it!

Building a Compiler Frontend

Are you interested in creating your own programming language?

This blog post explains on how to write the compiler frontend, which converts a program text in language A (e.g. TypeScript, Go, Rust) into an intermedia representation that is understand by the compiler backend. Which then interprets it and produces machine code for a particular platform.

The tutorial makes use of pest, a general purpose parser written in Rust. The blog posts focuses on the frontend part but it also comes with a simple and more advanced example, which includes also the backend part. In the examples you have a super simple language that has functions and can do addition and subtraction and is interpreted and run on top of Rust.

Building a Compiler Frontend
Construction of a compiler frontend for a small arithmetic expressions language

Thank you for reading and have a wonderful day ☀️