week 50, 2021

Accurate mental model for Rust's reference types

Rust's ownership and borrowing system involves the use of references to operate on borrowed data, and the type system distinguishes two different fundamental reference types. In code they are spelled &T and &mut T.

&mut T is commonly known as a "mutable reference" to data of type T. By juxtaposition, &T is then an "immutable reference" or "const reference" to T. These names are fine and reasonably intuitive for Rust beginners, but this article lays out the motivation for preferring the names "shared reference" and "exclusive reference" as you grow beyond the beginner stage and get into library design and some more advanced aspects of the language.

Source: Accurate mental model for Rust's reference types.

Designing a new PRNG

Rust needs a better non-cryptographic prng for its rand crate. This is an explanation of how I went about designing one. I hope it will not only demonstrate that the resulting algorithm is worthy of consideration, but be useable as a guide for others who want to build a PRNG.

Source: Designing a new PRNG, an article by Tom Kaitchuck.

On the potential of Transformers in Reinforcement Learning

Transformers architectures are the hottest thing in supervised and unsupervised learning, achieving SOTA results on natural language processing, vision, audio and multimodal tasks. Their key capability is to capture which elements in a long sequence are worthy of attention, resulting in great summarisation and generative skills. Can we transfer any of these skills to reinforcement learning? The answer is yes (with some caveats). I will cover how it’s possible to refactor reinforcement learning as a sequence problem and reflect on potential and limitations of this approach.

Source: On the potential of Transformers in Reinforcement Learning, an article by Lorenzo Pieri.

Seven habits of effective text editing

If you spend a lot of time typing plain text, writing programs or HTML, you can save much of that time by using a good editor and using it effectively. This paper will present guidelines and hints for doing your work more quickly and with fewer mistakes.

The open source text editor Vim (Vi IMproved) will be used here to present the ideas about effective editing, but they apply to other editors just as well. Choosing the right editor is actually the first step towards effective editing. The discussion about which editor is the best for you would take too much room and is avoided. If you don't know which editor to use or are dissatisfied with what you are currently using, give Vim a try; you won't be disappointed.

Source: Vim: Seven habits of effective text editing, an article by Bram Moolenaar.

A Beginner's Guide to Parsing in Rust

Parsers are crucial for many data processing tasks. Contrary to what appearances might imply, writing a parser from scratch is not difficult given the right starting point. This article presents a flexible system for writing custom parsers for a wide range of languages. It assumes some experience with Rust, but no experience with language theory. More experienced readers might want to skip directly to the Lyn crate.

Source: A Beginner's Guide to Parsing in Rust, an article by Richard L. Apodaca.

Rust Error Handling

Error handling in Rust has been a topic of discussion for years. There's a working group devoted to it (announcement here) that seems active, but to be honest I haven't heard a lot from them (naturally, a few days after I wrote this, they popped-up on Reddit). There has, however, been a steady stream of articles & posts about best practices in this regard. I surveyed them while reconsidering my own error-handling strategy for mpdpopm & found myself taking pieces from each, but no one author really captured my thinking. With this, I throw my own thoughts on the pile.

Source: Rust Error Handling.

Django Web Framework

Django is an extremely popular and fully featured server-side web framework, written in Python. This module shows you why Django is one of the most popular web server frameworks, how to set up a development environment, and how to start using it to create your own web applications.

Source: Django Web Framework.

Swift Playgrounds 4 is here, and it’s a thing of beauty

At WWDC21 Apple revealed that Swift Playgrounds was getting a huge upgrade to allow us to build complete SwiftUI apps, including not only a live preview of our work but also the ability to ship direct to the App Store.

Well, Playgrounds 4 just arrived and I’m really pleased to say they nailed it: this is a landmark release for Swift Playgrounds, introducing instant interactive previews, lightning-fast code completion, complete integration for Swift Package Manager repositories, and so much more…

Source: Swift Playgrounds 4 is here, and it’s a thing of beauty, an article by Paul Hudson.

How not to learn Rust

I've seen too many good programmers struggle learning Rust, or even give up.

Here are the mistakes I've seen which may make you fail at learning Rust. I hope this list will help you avoid them.

Source: How not to learn Rust, an article by Denys Séguret.

Tutorial: Getting started with generics

This tutorial introduces the basics of generics in Go. With generics, you can declare and use functions or types that are written to work with any of a set of types provided by calling code.

In this tutorial, you’ll declare two simple non-generic functions, then capture the same logic in a single generic function.

Source: Tutorial: Getting started with generics.

::before vs :before

Note the double-colon ::before versus the single-colon :before. Which one is correct?

Technically, the correct answer is ::before. But that doesn’t mean you should automatically use it.

Source: ::before vs :before, an article by Chris Coyier.

It’s time to stop using Python 3.6

Upgrading to new software versions is work, and work that doesn’t benefit your software’s users. Users care about features and bug fixes, not how up-to-date you are.

But there is only so much time you can delay upgrading, and for Python 3.6, the time to upgrade is right now. Python 3.6 is reaching its end of life as of December 2021.

Source: It’s time to stop using Python 3.6, an article by Itamar Turner-Trauring.

Do You Know Where Haskell Is Used?

Haskell is a general-purpose purely functional programming language. Its distinctive features include strict static typing, lazy evaluations, algebraic data types, and a serious theoretical background. This language is relatively young, it emerged in 1990 but has already produced a big impact on other languages and programming language theory on the whole.

One of our recent posts described useful Haskell-based utilities, but all of them are intended to be used by tech-savvy people. Today we’re going to give some examples of practical use in various industries.

Source: Do You Know Where Haskell Is Used?, an article by Catherine Galkina.