In the afternoon I finished Eyes of the Void. I did like the book although a little less compared to the first one in the trilogy.
Don’t write a Rust linked list library: they are hard to do well, and usually useless.
VecDeque, which is great. If you actually need more than
VecDequecan do, use one of the handful of libraries that actually offer a significantly more useful API.
If you are writing your own data structure, check if someone has done it already, and consider
generation_arena, (or maybe
Every so often, I need to kill the odd unresponsive process. While I really like
proced(check out Mickey Petersen's article), I somehow find myself using macOS's Activity Monitor to this purpose. Kinda odd, considering I prefer to do these kinds of things from Emacs.
Source: Emacs: quickly killing processes, an article by Álvaro Ramírez.
A prequel, set before the events of Army of the Dead, which focuses on German safecracker Ludwig Dieter leading a group of aspiring thieves on a top secret heist during the early stages of the zombie apocalypse.
In the evening Alice, Esme, and I watched Army of Thieves. I liked the movie and give it a 7.5 out of 10.
In this post, we’ll develop a deeper understanding of CSS by diving into the underlying issues that make it difficult to scale.
We’ll understand the evolution of the various CSS best practices that have emerged and changed over time.
By the end, we’ll have a good grasp on past approaches to scaling CSS on large projects, and how popular tools like Tailwind and a range of others address these issues in counter-intuitive ways.
Source: The evolution of scalable CSS.
This isn't an article about how to use regexes; you've probably seen plenty of those already. It's about how you would write a regex package from scratch, in a language like C that doesn't already have regexes.
I'll demonstrate a new module,
Regex.pm, which implements regexes from nothing, in Perl. This will give you an idea of how regex matching is possible, although the details differ rather substantially from what Perl actually does.
Source: How Regexes Work, an article by Mark-Jason Dominus.
Python is one of the world’s beloved programming languages. Dynamic typing makes it easy to learn and fast to build with. Its popularity has led to its use in some of the most advanced AI systems and web applications on the planet.
However, traditional dynamically typed Python code struggles at scale. Specifically:
- Refactoring is painful. It is challenging to refactor any large dynamically typed codebase. This is because dynamically typed code can’t be processed with the sort of static analysis and refactoring tools widely available in statically typed languages (e.g. Java, C#). These tools support automatic symbol renaming, reference lookup, edit-time type-checking etc.
- It’s hard to ensure correctness. Dynamically typed Python code is difficult to check for correctness. The best available method is to write comprehensive automated tests, but writing and maintaining a large test suite is expensive. Tests are also often too slow to provide feedback while editing in the same way as static analysis tools, allowing errors to compound for longer.
Source: Adding types to a large Python codebase, an article by Sean Mackesey.
I am going to show you how to filter your Django QuerySets. There are lots of tips and tricks to write more powerful Django queries. By applying the skills in the examples, you will build your confidence using Django ORM and writing better queries for your projects.
Source: How to Filter Django QuerySets - 15 Examples For Beginners, an article by Alice Ridgway.
Compared to other programming languages such as Python and Go, Rust's standard library is very small, including only core data structures in the standard library with all other functionality farmed out to 3rd party ecosystem crates, and a common complaint from new Rust developers is that they don't know where to start: which crates they ought to use and which crates they ought to trust. This list attempts to answer those questions.
A post about Haskell vs. Python readability came onto my radar the other day. It compares the implementation of a trie structure, and after looking upon the Python version I wanted to make my own attempt. I didn't make it to necessarily compare or "battle" against the other solutions, it's more of an exercise in the vein of "how would I do it".
Source: Trie in Python, an article by Ivan Sagalaev.
A gentle introduction to Haskell for beginners.
The prerequisite for this series of tutorials is some knowledge of imperative programming, whether C++, Java, Pascal, you name it. If you have some familiarity with functional programming, that's even better.
Source: Basics of Haskell, an article by Bartosz Milewski.
One of the world's top bodyguards gets a new client, a world class hitman who must testify at the International Criminal Court. They must put their differences aside and work together to make it to the trial alive and on time.
Not too long ago, we walked you through setting up bhyve on FreeBSD 13.1. Today, we’re going to take a look specifically at how bhyve stacks up against the Linux Kernel Virtual Machine—but before we can do that, we need to talk about the best performing configurations under bhyve itself.
This is a public domain implementation of make which follows the POSIX standard.
If you've got here I assume you know what make is and why you might want to use it. If not, Chris Wellons has a nice Tutorial on Portable Makefiles.
Source: Public domain POSIX make, an article by Ron Yorston.
In my last post, I talked about how Haskell
newtypesare great tools for modeling JSON data when writing API clients in Haskell, and I included some examples on how to write custom
FromJSONmethods that incorporated these
newtypes. That post generated some discussion on Lobsters, from which I learned about this interesting library called autodocodec. Given the advantages laid out in that discussion, I decided to give that library a try on my project’s codebase, and it worked so well that, so I ended up refactoring basically all of my types to use autodocodec to generate JSON parsers for my types. In fact, I enjoyed the experience of using autodocodec so much that I thought it was worth blogging about.
Source: Improving the experience of JSON in Haskell with autodocodec and bifunctors, an article by Dylan Martin.
I want to create a personal web crawler. As I download each page, I collect a new list of URLs. To increase the likelihood that I am downloading the most important pages first, I want to keep the list of URLs to visit sorted by length (shorter URLs are more likely to be closer to the front page). That presents a problem though, because I'm also adding URLs.
A naïve list (
Vec<T>in Rust), won't be very efficient. After every batch of inserts, I would need to re-sort the list. Wouldn't it be good if there were a data structure that could maintain the sort order itself? Yes! It's called a binary heap.
Source: Creating a priority queue with a custom sort order using a binary heap in Rust, an article by Tim McNamara.
I’m an idiot. And git is hard. A lot of places use a rebase-based Git workflow, and I’ve made git less hard with a set of handy aliases. Put these in your
~/.gitconfigand turn git into an actually less painful command line tool to use.
Source: Idiot proof git, an article by Doug Turnbull.
In this post, you will learn about the need for mocking in unit testing and the difference between dependency injection and mocking. You will also get acquainted with mocking in Jest. Furthermore, you will see an example script with two classes and mock the dependent class to test the other class with a full code example using module factory and Jest SpyOn. Let’s get rolling!
A trait is a basic language concept for defining shared behavior on types. Traits describe an interface that types can implement.
This article will show you how to use traits in Rust. After reading it, you’ll be able to answer these questions:
- What is a trait?
- Why do we use traits in Rust?
- How to implement and define traits in Rust?
- What does it mean to derive a trait, and when can we do it?
Source: Traits in Rust, an article by Yevhenii Zelenskyi.
A short summary of the major themes of work that the Faster CPython plans to land in 3.12.
Introductions to functional programming are usually targeted at people who are already accustomed to programming, and they typically present the perks of the paradigm by comparing it to imperative or object-oriented programming. This often leaves the reader with the impression that they have to unlearn practices and concepts they already know to adopt this new paradigm.
In this post I would like to try a different approach, not requiring any programming knowledge, but only the most basic intuition. We will build on high school mathematics, in the form of sets and functions, to provide a learning path to understanding functional programming1.
Source: Functional programming from sets and functions, an article by Marco Perone.
Framed for murder after uncovering a privacy scandal, an ethical hacker must evade the police while trying to track down the criminals blackmailing her.
In the evening Esme and I watched the Dutch movie The Takeover. It suffers a lot from the typical "hacker" nonsense like slow scrolling source code etc. While I liked to see some parts of Rotterdam, where I have lived for a while in the 90's, I didn't like the movie much and give it a 5 out of 10.
This weekend on /r/programming someone posted a nice introduction to tries using Python. A while ago, I had implemented a mini web server to do completion and correction of words using Ternary Search Tries in Haskell, and since the trie post generated a lot of interest I decided to post mine too.
Then, someone else posted a blog article commenting on the readability of Python and Haskell based on my web server code and the trie example, concluding that the Python version was much more readable.
Source: Haskell, Python, and Readability, an article by Francesco Mazzoli.
A few weeks ago I released pyastgrep, a tool for grepping Python code at the syntax level (using AST - Abstract Syntax Trees), and today I released some more improvements.
It builds on an earlier tool, astpath which now appears to be abandoned, and also had quite a few bugs. I’ve fixed lots of things and re-written quite a bit internally in backwards incompatible ways, so a fork was the easiest way forward. I’ve also been able to make lots of improvements to default behaviour, inspired by tools like ripgrep. For example, it automatically exclude paths that match discovered
.gitignorefiles, which can make a massive performance improvement in some cases (looking at you,
Source: Better Python code grepping with pyastgrep, an article by Luke Plant.
Python's list comprehensions (and generators) are an awesome feature that can greatly simplify your code. Most of the time however, we only use them to write a single
forloop, maybe with addition of one
ifconditional and that's it. If you start poking around a bit though, you will find out that there are many more features of Python's comprehensions that you don't know about, but can learn a lot from...
Source: Python List Comprehensions Are More Powerful Than You Might Think, an article by Martin Heinz.
As front-end developers, we’ve wished for a lot of things over the years — ways to center things in CSS, encapsulate styles, set an element’s aspect ratio, get finer-grained control over our colors, select an element based on its children’s properties, manage layers of specificity, allow elements to respond to the width of their parents… the list goes on and on.
And now that we got all we wished for and more, some of us are asking — do we now have too much CSS?
Source: Is There Too Much CSS Now?, an article by Sacha Greif.