π₯ Tech Blips #22.6
Every month I try to summarise some techniques, tools, languages and frameworks or platforms on the cloud and web horizon that are worth taking a look at.
TL;DR in this technology newsletter:
- Techniques: Monorepo (Adopt)
- Tools: Nx (Trial)
- Language and Frameworks: WebAssembly (Assess)
- Platforms: Fly.io (Trial)
For a long time, the de facto standard for structuring source code in Git repositories was the polyrepo approach.
Polyrepo means that there's a separate repository for each team, application, or project. Typically, each repository has a single build artefact and a simple build pipeline.
In contrast to polyrepo, there's the monorepo technique: a monorepo is a single repository for an entire organisation that contains several different projects with clearly defined relationships.
The following figure shows the difference between these two techniques when dealing with Git:
With the monorepo approach across all projects you're able to:
π‘ Β Local and distributed computation caching.
The ability to store and reuse files and process output from build and deployment tasks.
Whether on the same machine or remotely across different environments, you'll never build or test the same thing twice.
π‘ Workspace Analysis
You've a single source of truth for all projects in one repository. So you can analyse the entire dependency graph easily.
π‘ Easy code sharing
Each project can share its code with other projects without any additional configuration overhead.
π‘ Local and distributed task orchestration
You can run different time-consuming tasks in parallel. So it's also possible to delegate some tasks to different distributed build agents that can be easily orchestrated.
π‘ Identify affected projects and packages
When you change a common source code, you can directly see which projects and packages are affected.
π‘ Consistent tooling
A monorepo means that you've the same build tooling and build logic for all projects.
If you want to learn more about monorepo, I recommend this page π
Nx is an intelligent, fast and extensible build system with first-class monorepo support and powerful integrations.
Nx is a build system with a powerful core driven by metadata and extensible by plugins.
Nx works with some concepts like caching or distributed task execution to run your monorepo efficiently and effectively.
The Nx core brings the following features:
- Run tasks
- Cache task results
- Explore the projects graph
- Distribute task execution
- Integration in editors, like VS Code
- Automate updating dependencies
- Enforcing project boundaries
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine.
WebAssembly is a new type of code that can be executed in modern web browsers. It's a low-level language with a compact binary format that runs with near-native performance and provides a compilation target for languages such as C/C++, C#, Go or Rust that can run on the Web. It's also designed to run alongside JavaScript so that the two languages can work together.
With the WebAssembly JavaScript APIs, you can load WebAssembly modules into a JavaScript application and exchange functionality between the two. This allows you to leverage the power and strength of WebAssembly and the expressiveness and flexibility of JavaScript in the same applications, even if you don't know how to write WebAssembly code.
An interesting WebAssembly example comes from Snaplet and Supabase. They've developed a PostgreSQL server that runs inside the browser.
Postgres WASM from Snaplet and Supabase Blog Post:
Running Example π
Heroku has canceled his free plan! Fortunately Fly.io comes to the rescue!
Fly.io, like Heroku, is a global application distribution platform. Fly.io runs its code in Firecracker microVMs around the world.
With Fly.io, you can use Docker to build the container image with your app and its environment. You can also point it to a prebuilt image.
In many cases, you won't need to touch Docker at all. Fly.io can scan your source code and detect which pre-existing buildpack matches the configuration you need, and our remote builder will build your app container image as you deploy.