mastodon.social Archive
I migrated from mastodon.social to fosstodon.org. This page is meant to archive all my posts from the old instance, just in case.
I migrated from mastodon.social to fosstodon.org. This page is meant to archive all my posts from the old instance, just in case.
In the previous article, we created the most naive interpreter, which can basically execute number + number expressions. A logical extension is obviously to handle all basic operations: addition, s...
I’ve always felt that writing a compiler is the most romantic software engineering task. You’re writing a program that reads textual instructions describing precisely what a computer should do. Do ...
I asked Claude Code to rewrite CuTe, my 20-year-old 3D Tetris clone, from C++/OpenGL/WinAPI into modern Go. What went well, what broke, and what I had to fix four times.
A glossary of OpenTelemetry and observability terms, from traces and spans to Grafana and Datadog. Opinionated definitions for developers who don't have time for dry documentation.
How to turn YouTube channels, radio stations and 'read later' articles into custom podcasts
Location, location, location! That’s what the real estate agent will tell you when asked what’s the most important factor when choosing the place to live. When living in a modern, busy city like Wa...
In JavaScript, should we await on a returned promise or not? async function foo() { //... return await waitAndMaybeReject(); } If we remove await, the code compiles and behaves exactly t...
Yukihiro Matsumoto, the creator of Ruby programming language, famously said: "_I hope to see Ruby help every programmer in the world to be productive, and to enjoy programming, and to be happy_." Honestly, not many programming languages were built with developer's happines in mind. And to be honest, Ruby is a joy to work with. It's fairly easy to learn, easy to read, yet, very powerful. Also, with the appearance of Ruby on Rails, it became insanely productive. But first things first.
Border Gateway Protocol, BGP for short, is probably the most important protocols you might have never heard of. Well, you did at least once, in October 2021. When Facebook, WhatsApp, Instagram and Messenger all went down because of BGP misconfiguration. Or that one day back in 2008 when all YouTube traffic was accidentally routed to Pakistan. Because of BGP... misconfiguration. So what's the big deal with BGP? First we must understand how the Internet works.
SQLite is by far the most common SQL database ever deployed. Are you listening to this on iPhone or Android device? It runs SQLite. Or maybe through a web browser? Chrome, Safari, Firefox, Opera and Android Browser all use SQLite underneath. Are you running MacOS or Windows? It's built-in. Most Linux distributions have it as well. "But I'm listening to your podcast while driving a car", you say. Well, most automotive systems use SQLite internally. If you happen to listen to my podcast while coding in PHP or Python, they include SQLite out-of-the-box. Oh, and it's the default choice for Ruby on Rails as well. I'm pretty sure SQLite is used somewhere on the International Space Station and it maybe even landed on other planets? So, what makes this unsung hero so popular to run at least *one trillion* databases worldwide?
Scala is a programming language running on the Java Virtual Machine. It's statically typed, and you can use it both as functional and object-oriented language. Even at the same time. The functional side of Scala supports higher-order (and higher-kinded) types. For those of you know what it means. On the other hand, object-relational features of Scala are equally strong. Including powerful trait composition, that you can somewhat compare to multiple inheritance. Combine than with great Java interoperability and no wonder why Scala became a go to language for many ex-Java developers.
K-means clustering is an algorithm for partitioning data into multiple, non-overlapping buckets. For example, if you have a bunch of points in two-dimensional space, this algorithm can easily find concentrated clusters of points. To be honest, that's quite a simple task for humans. Just plot all the points on a piece of paper and find areas with higher density. For example, most of the points are located on the top-left of the plane, some at the bottom and a few at the centre-right. However, this is not that straightforward once you can no longer rely on graphical representation. For instance, when your data points live 3-, 4- or 100-dimensional space. Turns out, this is not that uncommon. Let me clarify.
Apart from recording a podcast, I also listen to a ton of podcasts myself. Probably 1-2 hours per day during house chores. The following is a list of all podcasts I listen to. It’s auto-generated f...
Clojure is a dynamically, strongly typed programming language. It's a dialect of _Lisp_ running on the Java Virtual Machine. Lisp is 6 decades old and has a really weird syntax. That weird syntax is called _Polish prefix notation_. Basically, in every other language you've used math operators like plus or minus are infix. It means they are placed between operands. For example, `1 + 2`. In Clojure, you always put the operator (or any other function for that matter) in front. So simple addition becomes... `+ 1 2`.
There are two main ways to communicate between components in your distributed system: synchronous and asynchronous. Synchronous communication is like making a phone call. The system on the other side must be present and you actively wait for a response to your every question. Examples of this style include [REST](https://nurkiewicz.com/44), [SOAP](https://nurkiewicz.com/74) and [GraphQL](https://nurkiewicz.com/3).
After many dramatic events around Twitter lately, many people, including myself, began experimenting with Mastodon. Superficially it's an open-source clone of the former that anyone can deploy and host. However, once you look deeper, it's actually a completely different philosophy and architecture. Let's focus on how Mastodon federated network is built. To understand the difference, we'll start from scratch.
I’m moving to https://fosstodon.org/@nurkiewicz. Feel free to follow me there for updates Sun Oct 30 22:23:16 2022 # Quote from “Building Evolutionary Architectures” by @neal4d, @rebeccaparso...
RabbitMQ is a message broker, allowing asynchronous communication in distrubuted systems. The key advantages of RabbitMQ include: 15 years of open source history, battle proven Erlang implementation and support for industry standard protocols. RabbitMQ is among the most popular implementations of message brokers. Others include [ActiveMQ](https://activemq.apache.org/) for Java, [celery](https://pypi.org/project/celery/) for Python and [Kafka](https://nurkiewicz.com/8) - if you consider it a message broker. Also, pretty much all cloud providers have their proprietary implementations, like, [Google Pub/Sub](https://cloud.google.com/pubsub/), [Amazon Kinesis](https://aws.amazon.com/kinesis/), [Azure Service Bus](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview) and so on. RabbitMQ at its core implements [AMQP](https://www.amqp.org/), a standard protocol for information interchange. So not only it's open source, it's also built on top of open standards.
Many people, when asked about SLA, simply shout 99%. The correct answer to that question is probably a long, boring PDF, written by lawyers. Yes, SLA is a legal obligation. Not a metric or a number. You probably meant SLI or SLO.
An artificial neural network is a computer algorithm somewhat inspired by our brains. Superficially, our brain is a network of neurons connected with each other and communicating via electrical impulses. Artificial intelligence experts implemented a similar concept purely in software. An artificial neuron is basically a function that takes a set of inputs and has an output. Just like the biological one. By connecting hundreds of such neurons in a network, we can observe quite _intelligent_ behaviours. For example, artificial neural networks can recognize what's in the image. Or quite the opposite - generate images from text.
A few weeks ago Ethereum blockchain moved from proof-of-work to a proof-of-stake algorithm. This step alone reduced global energy consumption by 0.2%. It's as much as an energy usage of Austria. At this point, Ethereum, the second largest blockchain after Bitcoin, is using barely as much electricity as a few hundred households. How is that possible? How does the proof-of-stake algorithm work, avoiding catastrophic energy waste?
A genetic algorithm is a heuristic approach to solving complex computational problems. This includes various optimizations, especially around scheduling and design. For example, NASA designed a radio antenna for their spacecraft using a genetic algorithm. Its shape is quite complicated, like nothing that could be designed by hand. So how do genetic algorithms work their way to the solution? Well, they are inspired by the natural selection process in living creatures (!)
Non-fungible tokens, NFTs for short, are financial instruments implemented on top of the blockchain. They can be bought and sold, just like cryptocurrencies. However, unlike bitcoins, each NFT is unique and traded individually. Whereas Bitcoins or ether are interchangeable, just like hundred-dollar bills. So what makes each NFT unique? Why would you purchase this particular NFT rather than the other one? Well, an NFT has an associated piece of data. That data is typically a hyperlink to a digital piece of art. What you actually purchase is... well... that link?
We all know this feeling. You search for a hotel in Paris and you keep getting ads for hotels and flights for weeks to come. Or something even scarier. You visit a blog post highlighting the first symptoms of a pregnancy. An hour later every single website on the planet advertises diapers and baby formulas. How is that possible? How do they know? And how did we get into this dystopia? All of this became possible with real-time bidding. The billion-dollar industry that tracks our every movement.
MongoDB is a NoSQL database. Precisely speaking, it's a document-oriented database. It stores arbitrarily complex key-value objects. For example, in a single `Car` object you can store as much information as you want. Not only license plate or manufacturing year. But also information about each individual part, history of repairs, insurance and all owners. No matter how much information you want to keep, you just put that in a single, easily accessible document. Contrast that to relational databases, where each relationship has to be modelled as a separate table. So the same `Car` would have been spread across tens of tables. Imagine all these SQL JOINs! No wonder why MongoDB is one of the most popular databases.
_Author: Holly Cummins_
Ethereum is a network of computers with no central trusted authority. They achieve consensus by running computation-intensive algorithm, known as proof-of-work. The agreed state is added to an append only ledger, known as blockchain. Yes, Ethereum is yet another blockchain. And it's used to track transactions in a cryptocurrency, known as Ether. However, unlike Bitcoin, it's much more than a simple log. Bitcoin accounts simply hold currency. Ethereum accounts can run programs as well. Ethereum network is actually one, huge computer!
QUIC can be thought of as the third fundamental protocol of the Internet. Next to UDP and TCP/IP. Let's talk a little bit about these two. They both build upon IP, Internet Protocol. IP supports exchanging packets of data between two machines having... IP addresses. UDP adds ports. Port is a logical concept. It's simply a number within one machine that identifies a certain process. Thanks to ports, many different processes on the same machine can exchange data.
Stuxnet was probably one of the most sophisticated pieces of software ever built. I can easily imagine a Hollywood movie about it. A computer program that could change the course of history. Ironically, Stuxnet was a computer virus. A virus that infected 200 thousand machines. But activated and damaged only on a fraction of that.
Denial-of-service attack tries to take down a server by sending specially-crafted requests. The simplest form of this attack is just sending *a lot* of requests in a short period of time. But more sophisticated methods are possible. For example, sending a single unusual request that overwhelms the server. One such example is a ZIP bomb, that I'll explain later. But the most widespread technique requires a large number of attacking servers. Also known as distributed denial-of-service. DDoS for short.
In part 2 of the Twelve-Factor App, we'll explore the second half of the principles. Be sure to listen to the previous episode as well. We still have only four minutes, so let's go!
Twelve-Factor App is a set of design guidelines defined by Heroku. These guidelines are best suited for cloud-native, portable and resilient services. In this episode, I'll explain the first seven principles. I have four minutes left, so let's go!
SOAP, formerly known as Simple Object Access Protocol, is a messaging standard. SOAP is very broad and general. Technically, it can support request-response, as well as fire-and-forget communication. The underlying protocol is typically HTTP, but there's nothing against using message brokers. Or even good old SMTP. You know, the one for exchanging e-mails. The communication happens through XML messages. These messages are well-defined and structured. XML schema is agreed upon before any communication.
Neo4j is a NoSQL database engine. What makes it different is the unusual data model. In Neo4j everything is modelled as a graph. A graph is a collection of nodes connected with edges. A typical example is a graph of friends on a social media website. Or a network of movies and actors. But it turns out many problems can be efficiently modelled as graphs. Like a customer having orders, each order has items. Or insurance, connected to a certain car and an accident. So what makes Neo4j special?
React.js is a JavaScript library for building dynamic user interfaces. React applications are built on top of reusable components. Components encapsulate look and feel, logic and state. Also, React has quite an advanced state propagation mechanism. In simple words, it means that the user interface is very responsive and consistent. To improve developer experience, React typically uses JSX. An extension to JavaScript language. Let's dive deeper into why React.js became the most popular web framework. Or library. Or both. Depends who you ask.
Erlang is a programming language designed for highly scalable, fault-tolerant systems. Its primary use case used to be telecommunication. But these days it powers some of the biggest distributed systems. For example, half-billion WhatsApp users. The unique features of Erlang allow it to achieve amazing availability. A typical enterprise system may be unavailable for, let's say, a few hours per year. This means 99.9% availability. Systems written in Erlang may even reach _so_called_ nine nines. Or 99.9999999%. It means the system is unavailable for less than 31 milliseconds. Per year. How is that possible?
Hello everyone! My name is Martin Kleppmann. I'm a researcher at the University of Cambridge. And I would like to tell you briefly about the technology called CRDTs. So, CRDT stands for Conflict-free Replicated Data Type. It's a type of data structure that you can use to build collaboration software. So think software like Google Docs for example. Or Figma. Or Trello. Or a TODO list that syncs between your computer and your phone. You can build this type of software using CRDTs.
DevOps is a movement to bridge the gap between developers and operations teams. Traditionally, these two groups were separate and rarely interacted with each other. Developers didn't quite understand how software is deployed and managed. Operation teams, on the other hand, treated software as a black box. DevOps encourages synergy between these two roles. Developers should take responsibility for their software. Including how it runs and behaves on production. Ops should understand the software they run. But more importantly, they should adopt well-established software engineering principles. For example, automation, auditing, testing, and fast feedback. Ideally, devs and ops should work together in a single team, toward a common goal.
Transactions in SQL databases are rock-solid. By reading and modifying data within a transaction we limit the risk of data corruption. Actually, there's an acronym describing transactions: ACID. Which stands for: _atomicity_, _consistency_, _isolation_ and _durability_. A good database engine follows these properties religiously. NoSQL engines, on the other hand, trade ACID properties for availability or speed. Of course, this is a gross simplification. Anyways, NoSQL crowd coined another acronym: BASE. Which stands for: _basically available_, _soft state_ and _eventually consistent_. We'll leave BASE for another episode.
Version control systems, like git, serve two purposes. First of all, they allow collaborating on the same code by multiple developers. Collaboration is needed for any non-trivial project. Secondly, they keep the history of changes. Modification history allows tracking bug fixes and regressions. That, and many other applications of version control, will become obvious in a second.
DRY, or _don't repeat yourself_ is a common principle in pSpring AOP riddlerogramming. That's why we invented functions and objects. But some sources of duplication are really hard to get rid of. Well, sometimes it's even hard to realize there's duplication in the first place! Common examples are logging, validation, checking security, starting a transaction. Often, these are one-liners that are too simple to extract. Too mundane too bother. And too ubiquitous to forget.
Remember the days when deploying a new version of your application required downtime? If your application is particularly important, you might have had to schedule a maintenance window. Or perform the deployment in the middle of the night to avoid disruption. Today's tools and DevOps practices allow deploying tens or even hundreds of times per day. With no downtime, and no noticeable disruption. Sometimes every commit is deployed automatically to production within minutes. How's all this possible?
TypeScript is a programming language, a superset of JavaScript. This means any valid JavaScript program is also valid TypeScript. But not vice-versa! TypeScript adds a ton of features, addressing the shortcomings of JavaScript. The most important one is optional static typing, including `null`-safety. The fact that you can take any JavaScript code and turn it into TypeScript by simply changing a file extension is crucial. It means you can gradually start using TypeScript's features without rewriting your whole application.
You can't look at your application all the time. Instead, it should leave some sort of persistent trace. Such an audit log can be examined later on. However, it's the responsibility of the application itself to log appropriately. But more importantly, the data it logs for later must be well-structured. Simply printing random words to a console is no longer sufficient.
Object-relational mapping, ORM for short, simplifies access to relational databases. Such frameworks help with developing applications without writing SQL. SQL was supposed to be easy to use for non-programmers. That's part of the reason why SQL is so verbose. However, writing complex joins by hand is hard. Also, typically, once you fetch data from your database, you immediately translate it to objects. So why not build a universal framework for such mapping? Like, object-relational mapping?
Spring framework is probably the most popular and most successful application framework for Java. Writing a server or a web application before Spring was cumbersome. And it required an insane amount of boilerplate. Even in already bloated Java language. This framework was created sort of as a by-product for a book by Rod Johnson, back in 2003. He wanted to build an alternative to heavyweight Enterprise Java Beans standard. What was just an idea sparked to be one of the largest ecosystems for Java.
Haskell is a purely-functional programming language. It is also statically and strongly typed. Haskell takes these characteristics to the extreme. For example, doing any input/output is considered impure from a functional programming point of view. So in some books, a simple "_Hello, world_" example appears as late as in chapter... 9.
A compiler is an application that turns text into an executable program. It's quite extraordinary how much work these complex pieces of software are doing. Pretty much every compiler works by executing several phases. Each phase takes the input of the previous ones to finally produce the runnable code. Let's take a journey through the compiler internals.