When I started working with Git I had some experience with Concurrent Versions System (CVS) and Apache Subversion (SVN), so I tried to understand it in terms of those classic source code repository systems. That way of thinking only got me a limited understanding of Git’s capabilities. Since then I have grown to understand Git much better, so this article is a kind of “note to self” text to remind myself how Git works and explain it to those who are new to it. I assume you know your way around other more classical source code repositories like CVS or SVN.

Read More

This tutorial provides a programmer’s introduction to the Satisfiability Modulo Theories Solver Z3. It describes how to use Z3 through scripts, provided in the Python scripting language, and it describes several of the algorithms underlying the decision procedures within Z3. It aims to broadly cover almost all available features of Z3 and the essence of the underlying algorithms.

This book makes JavaScript less challenging to learn for newcomers by offering a modern view that is as consistent as possible.

Highlights:

  • Get started quickly by initially focusing on modern features.

  • Test-driven exercises and quizzes available for most chapters.

  • Covers all essential features of JavaScript, up to and including ES2021.

  • Optional advanced sections let you dig deeper.

No prior knowledge of JavaScript is required, but you should know how to program.

Dec 9, 2021

This tutorial is intended for C beginners who want to do some coding practice, and in the process gain valuable insights regarding low level programming and how (some) Virtual Machines operate under the hood.

By the end of the article, we will have a working register-based VM capable of interpreting and running a limited set of ASM instructions + some bonus programs to test if everything works well.

Sep 13, 2021

The Ghost in the Shell series were about efficient working in the shell environment but one of the feats of any sysadmin profession is the shell scripting. It is often needed to ‘glue’ various solutions and technologies to work as ‘Business’ requires or to fill the gap where any solution is not available – or at least not for free. It also serves a growing role in the automation of various tasks. Today I will try to show you the basics of writing POSIX /bin/sh compatible shell scripts.

You may want to check other articles in the Ghost in the Shell series on the Ghost in the Shell – Global Page where you will find links to all episodes of the series along with table of contents for each episode’s contents.

Read More
Sep 9, 2021

Type-level programming in haskell (and other languages that support it) can be quite useful from time to time, but I find that it’s something that a lot of people struggle with learning. In haskell specifically, I think learning how to use type-level programming appropriately can be quite hard because the best real-world examples of type-level programming often come from larger projects, and it can be hard to figure out how to grow the design of your own code to make use of type level programming effectively when you’re only seeing the end-state of projects that have already grown into type level programming.

Outside of real-world projects, there are some well written pieces that describe various aspects of type level programming, but few references that are both accessible to people first trying to dip their toes into the world of type level programming and which also address the various approaches you can take to programming with types holistically.

In this article you’ll learn how to build programs that make heavy use of type-level programming by working through building a theming system. I originally developed the ideas behind this talk and article when trying to write something to unify the various themes and configurations for my own xmonad desktop setup, but the theming system you’ll build as you work through this article can be equally applied to theming web content, desktop or command line applications, or really anything that needs configurable theming.

Read More

There is a lot of confusion about floating-point numbers and a lot of bad advice going around. IEEE-754 floating-point numbers are a complex beast[1], and comparing them is not always easy, but in this post, we will take a look at different approaches and their tradeoffs.

I hang out in a couple programming language development chat channels and new people often seem to ask the same practical questions about parsing and implementing parsers. So I wanted to write up a quick guide about the pragmatic implications of how these things work in the real world.

This assumes that you already have some idea of what a parser does and where it fits in a compiler’s pipeline, and are trying to put that theory into practice and grapple with all the choices involved. If you don’t know what a parser, lexer or abstract syntax tree are, you’ll need more background before this is useful. Come back after doing a light read of the first few chapters in one of the following books.

Read More
Aug 15, 2021

Today we will begin writing a compiler for a real high-level language. It will be a simple language for sure. But let’s not let simplicity stand in our way. We will be able to write real programs with our compiler. How real, you ask? Let’s plan on writing a compiler for our selected language and then being able to write a compiler in that same language the compiler compiles using our compiler to compile it! From zero to compiler to self-hosted compiler. It will take a good bit of work for sure, but I think we are up to the task. We’ll spend this series writing our initial, non-self-hosting compiler. We’ll take some time to enjoy our work, then we’ll come back and embark on a second series that develops the self-hosted compiler using the compiler we will write in this series.

For today, let’s select a language for our compiler. Two languages, actually. One language will be the language that the compiler understands. The other will be the language that the compiler is written in. Once we’ve done that, let’s do some organizational work, discuss some of the different ways we could implement our compiler, and choose one of those implementation methods.

Read More
Aug 6, 2021

A few friends have recently asked about literature introducing Monad Transformers. The best introduction I have found was in Haskell Programming From First Principles. If you don’t have, or want to purchase, this book, then here is a brief explanation with examples.

Lets start with the problem they solve.

Jul 19, 2021

WebAssembly threads support is one of the most important performance additions to WebAssembly. It allows you to either run parts of your code in parallel on separate cores, or the same code over independent parts of the input data, scaling it to as many cores as the user has and significantly reducing the overall execution time.

In this article you will learn how to use WebAssembly threads to bring multithreaded applications written in languages like C, C++, and Rust to the web.

I wrote Python for the last 10 years, and I always tend to write code in a “functional” way - map, filter, lambda and so on, it makes me feel clean and happy. Following this warm feeling I decided to try a True functional language.

So I read a couple of tutorials online and went through the famous Learn You a Haskell for Great Good ! It was a long and painful journey - which is not over yet. After some retrospection I wanted to share my own introduction to Haskell based on my python experience. What I wished I had learnt first and what I wished I learnt later down the road.

Read More
Jul 12, 2021

Hey you! Have you ever wanted to become a CPU Whisperer? Me too! I’m a frontend web developer by trade but low-level assembly code and compilers have always fascinated me. I’ve procrastinated on learning either for a long time but after I recently picked up Rust and have been hanging out in a lot of online Rust communities it’s given me the kick in the butt to dive in. Rustaceans use fancy words and acronyms like auto-vectorization, inlining, alignment, padding, linking, custom allocators, endianness, system calls, LLVM, SIMD, ABI, TLS and I feel bad for not being able to follow the discussions because I don’t know what any of that stuff is. All I know is that it vaguely relates to low-level assembly code somehow so I decided I’d learn assembly by writing entirely too many brainfuck compilers in Rust. How many is too many? Four! My compile targets are going to be x86, ARM, WebAssembly, and LLVM.

Read More

The best way to understand complex data structures is to see them in action. We’ve developed interactive animations for a variety of data structures and algorithms. Our visualization tool is written in javascript using the HTML5 canvas element, and run in just about any modern browser – including iOS devices like the iPhone and iPad, and even the web browser in the Kindle! (The frame rate is low enough in the Kindle that the visualizations aren’t terribly useful, but the tree-based visualizations – BSTs and AVL Trees – seem to work well enough)

Read More
Jul 5, 2021

As a web developer, I use relational databases every day at my job, but they’re a black box to me. Some questions I have:

  • What format is data saved in? (in memory and on disk)

  • When does it move from memory to disk?

  • Why can there only be one primary key per table?

  • How does rolling back a transaction work?

  • How are indexes formatted?

  • When and how does a full table scan happen?

  • What format is a prepared statement saved in?

In other words, how does a database work?

To figure things out, I’m writing a database from scratch. It’s modeled off sqlite because it is designed to be small with fewer features than MySQL or PostgreSQL, so I have a better hope of understanding it. The entire database is stored in a single file!

Read More
Created on Nov 8, 2020
By @gurlic