Programming Leftovers
-
How to use a fork of the Go compiler with Nix
Sometimes God is dead and you need to build something with a different version of Go than upstream released. Juggling multiple Go toolchains is possible, but it's not very elegant.
However, we're in Nix land. We can do anything*.
I got accepted to Gophercon EU and a lot of it involves doing weird things with WebAssembly and messing with assumptions people make about how filesystems work. Given that most of my audience is going to be Go programmers and that I'm already going to be cognitively complicating how core assumptions about filesystems work, I want to show my code examples in Go when at all possible.
Go doesn't currently support WASI, but there is a CL in progress that adds the port under the name
GOARCH=wasm GOOS=wasip1
. I wanted to pull this into my monorepo's Nix flake so that I can rungowasi build foo.go
and getfoo.wasm
in the same folder to experiment with. -
Why you should use Python and Rust together
Python and Rust are very different languages, but they actually go together rather well. But before discussing how to combine Python with Rust, I want to introduce Rust itself. You've likely heard of the language but may not have heard details about how it works.
What is Rust?
Rust is a low-level language. This means that the things the programmers deal with are close to the way computers "really" work.
For example, integer types are defined by bit size and correspond to CPU-supported types. While it is tempting to say that this means
a+b
in Rust corresponds to one machine instruction, it does not mean quite that!Rust's compiler's chain is non-trivial. It is useful as a first approximation to treat statements like that as "kind of" true.
Rust is designed for zero-cost abstraction, meaning many of the abstractions available at the language level are compiled away at runtime.
For example, objects are allocated on the stack unless explicitly asked for. The result is that creating a local object in Rust has no runtime cost (though initialization might).
Finally, Rust is a memory-safe language. There are other memory-safe languages and other zero-cost abstraction languages. Usually, those are different languages.
Memory safety does not mean it is impossible to have memory violations in Rust. It does mean that there are only two ways that memory violations can happen:
- A bug in the compiler.
- Code that's explicitly declared unsafe.
Rust standard library code has quite a bit of code that is marked unsafe, though less than what many assume. This does not make the statement vacuous though. With the (rare) exception of needing to write unsafe code yourself, memory violations result from the underlying infrastructure.
-
Everything's an API
Hi Everybody,
April Cools is this weekend! A bunch of people who normally write tech stuff will be writing about a bunch of other topics. If you’ve got a blog and find April Fools to be eye-rollingly trite, come join us! You don’t need to pour your heart and soul into a 10,000 epic, just write something fun and genuine and out of character for you.
I’ve got a lot on my plate this week, so I’ll keep this newsletter short and sweet. Hyrum’s law:
With a sufficient number of users of an API, it does not matter what you promise in the contract: all observable behaviors of your system will be depended on by somebody.
Fair enough, but what do we mean by “API”? We always use “API” to mean the official designated interfaces, but when you get down to it, you can use anything as an interface!
-
The APNIC Hackathon is back!
The APNIC Hackathon at APRICOT 2023 produced some impressive results on the topic 'IPv6 Diagnostics Framework'.
-
Peter Hutterer: New gitlab.freedesktop.org spamfighting abilities
As of today, gitlab.freedesktop.org allows anyone with a GitLab Developer role or above to remove spam issues. If you are reading this article a while after it's published, it's best to refer to the damspam README for up-to-date details. I'm going to start with the TLDR first.
-
How to use Podman in GitLab Runners
A GitLab Runner is an application that works with GitLab CI/CD to run jobs in a pipeline on GitLab's infrastructure. They're often used to automatically compile applications after code has been committed or to run tests on a code base. You can think of them as cloud-based Git hooks.
The main public GitLab instance provides many easily accessible shared runners ready for use in your CI pipeline. You can find a list of shared runners in your repository's Settings -> CI/CD -> Runners on GitLab.
-
Bug fixes for AppImage Installer
Alfons reported that in the "Other" category, the "Online Information" button didn't work. Fixed.
https://forum.puppylinux.com/viewtopic.php?p=85384#p85384
Forum member Airdale reported liking Ungoogled Chromium and looked forward to the update feature. I replied that cannot update it:
https://forum.puppylinux.com/viewtopic.php?p=85386#p85386
I have fixed that also; however, do have a problem with updating at some repositories, so have had to hard-code to download just one version. Last night I discovered this:
-
Jonathan Dowland: daily log
The solution I've adopted for now is another Vim plugin, taskwiki, which synchronises tasks with Taskwarrior3, an external task-management tool.
If I mark a task as "done", Taskwiki updates all references to that task to reflect the new state. I can also construct queries to list all tasks matching some criteria. I have a special Vimwiki page named "Backlog" which runs the query "all tasks tagged 'redhat' in state 'pending'" (Linked from the boilerplate at the top of every page I write, for quick access):
= Backlog | +redhat status:pending = * [ ] buy milk (still todo)
Much like the base Vimwiki plugin, Taskwiki is very opinionated, and I've had to tame it by disabling several of its features. I've also hit a couple of mildly frustrating bugs (#368, #425). I might one day have a go at writing an alternative, simpler plugin in Lua (Neovim's native scripting language), but for now it works well enough and I don't have the time.
There's very little in this current workflow for managing scheduling tasks, and that's probably where the focus should be for my next iterative improvement efforts. I think Taskwarrior, the underlying tool, has some good support for that. I'd particularly like some more visual approaches for managing the backlog, such as something Kanban-style.
-
How to Validate Email Address in JavaScript
Email validation is a crucial part of any application that requires user registration or input of email addresses. Validating email addresses ensures that the input data is accurate, which helps prevent spam, reduces errors, and ensures that messages are delivered to the correct recipients.
-
10 Bash Tricks Every Developer Should Know
Bash is a popular shell scripting language used in Unix-based operating systems like Linux and macOS. It is widely used by developers, system administrators, and power users for automating tasks and managing systems. Bash offers many powerful features and shortcuts that can make your life easier and improve your productivity.