Plurrrr

week 26, 2021

The Haskell Phrasebook

The Haskell Phrasebook is a free quick-start Haskell guide comprised of a sequence of small annotated programs. It provides a cursory overview of selected Haskell features, jumping-off points for further reading, and recommendations to help get you writing programs as soon as possible.

Source: The Haskell Phrasebook.

Dynamic linking best practices

In this article we’ll learn how to build shared libraries and install them properly on several platforms. For guidance, we’ll examine the goals and history of dynamic linking on UNIX-based operating systems.

Content for the article comes from researching how to create a shared library, wading through sloppy conventions that people recommend online, and testing on multiple Unix-like systems. Hopefully it can set the record straight and help improve the quality of open source libraries.

Source: Dynamic linking best practices, an article by Joe Nelson.

When CSS Isn’t Enough

This articles covers several common components and why CSS isn’t sufficient for covering accessibility by detailing the JavaScript requirements. These requirements are based on the Web Content Accessibility Guidelines (WCAG) and additional research from accessibility experts. I won’t prescribe JavaScript solutions or demo CSS, but rather examine what needs to be accounted for when creating each component. A JavaScript framework can certainly be used but is not necessary in order to add the events and features discussed.

Source: When CSS Isn’t Enough: JavaScript Requirements For Accessible Components, an article by Stephanie Eckles.

Using CSS to Enforce Accessibility

I am a big proponent of the First Rule of ARIA (don’t use ARIA). But ARIA brings a lot to the table that HTML does not, such as complex widgets and state information that HTML does not have natively.

A lot of that information can be hidden to the average developer unless they are checking the accessibility inspectors across browsers or testing with a suite of screen readers. This is one of the reasons I always advocate for making your styles lean on structure and attributes from the DOM, to make it easier to spot when something is amiss.

It is also, in my opinion, a way to reduce the surface area for accessibility bugs. If your sort icon orientation is keyed to the ARIA property that conveys that state programmatically, then getting that ARIA property wrong will have two effects — a broken interface and a weird icon. Addressing the accessibility issue will fix the visual style.

Source: Using CSS to Enforce Accessibility, an article by Adrian Roselli.

YAGNI exceptions

I’m essentially a believer in You Aren’t Gonna Need It — the principle that you should add features to your software — including generality and abstraction — when it becomes clear that you need them, and not before.

However, there are some things which really are easier to do earlier than later, and where natural tendencies or a ruthless application of YAGNI might neglect them.

Source: YAGNI exceptions, an article by Luke Plant.

PAGNIs: Probably Are Gonna Need Its

YAGNI—You Ain’t Gonna Need It—is a rule that says you shouldn’t add a feature just because it might be useful in the future—only write code when it solves a direct problem.

When should you over-ride YAGNI? When the cost of adding something later is so dramatically expensive compared with the cost of adding it early on that it’s worth taking the risk. On when you know from experience that an initial investment will pay off many times over.

Source: PAGNIs: Probably Are Gonna Need Its, an article by Simon Willison.

Stop Using ‘Pop-up’

As you embark on a design, build, or specification, it is important you, the stakeholders, and the team understand what you are producing and why. When you say pop-up, which one of the following terms or concepts do you mean? What about your client? Your designer? Your developer? The user (who calls the help line)? The screen reader? The voice control software?

Source: Stop Using ‘Pop-up’, an article by Adrian Roselli.

Hash maps that don’t hate you

The map data-structure is incredibly useful when programming. The first time I used Perl the thing that most impressed me was how easy it was to use hashes, as they call them. I used them for everything! Map is a central feature in Go too — it’s one of the built-in object types with syntax support and generics. I think most people who program in Python have a similar experience. They call them dictionaries, and they are everywhere. In JavaScript, too, every object is a sort of a hash map. When I worked on V8 we had to go to huge lengths to hide the performance consequences of that decision, but I’m still a fan of easy-to-use hash maps in languages.

Source: Hash maps that don’t hate you, an article by Erik Corry.

Compressing JSON: gzip vs zstd

Compressing files adds an overhead. It takes time to compress the file, and it takes time again to uncompress it. However, it may be many times faster to send over the network a file that is many times smaller. The benefits of compression go down as the network bandwidth increases. Given the large gains we have experienced in the last decade, compression is maybe less important today. Having fast decompression is important.

Source: Compressing JSON: gzip vs zstd, an article by Daniel Lemire.

Why inheritance never made any sense

There are three different types of inheritance going on.

  1. Ontological inheritance is about specialisation: this thing is a specific variety of that thing (a football is a sphere and it has this radius)
  2. Abstract data type inheritance is about substitution: this thing behaves in all the ways that thing does and has this behaviour (this is the Liskov substitution principle)
  3. Implementation inheritance is about code sharing: this thing takes some of the properties of that thing and overrides or augments them in this way. The inheritance in my post On Inheritance is this type and only this type of inheritance.

These are three different, and frequently irreconcilable, relationships. Requiring any, or even all, of them, presents no difficulty. However, requiring one mechanism support any two or more of them is asking for trouble.

Source: Why inheritance never made any sense, an article by Graham Lee.

Typeclasses in Python

Today I am going to introduce a new concept for Python developers: typeclasses. It is a concept behind our new dry-python library called classes.

I will tell you in advance, that it will look very familiar to what you already know and possibly even use. Moreover, we reuse a lot of existing code from Python’s standard library. So, you can call this approach “native” and “pythonic”. And it is still going to be interesting: I am showing examples in 4 different languages!

But, before discussing typeclasses themselves, let’s discuss what problem they do solve.

Source: Typeclasses in Python, an article by Nikita Sobolev.

How Imports Work in Python

The Python import system is pretty straightforward... to a point. Importing code present in the same directory you’re working in is very different from importing between multiple files present in multiple directories. Through this post, I try to analyse the different import scenarios that one might encounter, hopefully making it easier to create your own packages.

Source: How Imports Work in Python, an article by Aniruddha Karajgi.

Functools - The Power of Higher-Order Functions in Python

Python standard library includes many great modules that can help you make your code cleaner and simpler and functools is definitely one of them. This module offers many useful higher order functions that act on or return other functions, which we can leverage to implement function caching, overloading, creating decorators and in general to make our code a bit more functional, so let's take a tour of it and see all the things it has to offer...

Source: Functools - The Power of Higher-Order Functions in Python, an article by Martin Heinz.

How JIT Compilers are Implemented and Fast

This post goes into details of 5+ JITs and various optimization strategies and discuss how they work with different JITs. Information in this blog post is more depth-first, thus there are many important concepts that may be skipped. That also means that this blogpost is not enough information to draw meaningful conclusions on any comparisons of implementations/languages.

Source: How JIT Compilers are Implemented and Fast: Pypy, LuaJIT, Graal and More an article by Carol Chen.

Maximize your concurrent web server connections

For production web servers, most people assume scaling means needing faster (and more expensive) hardware. Before spending more money on servers, first make sure your web server process is using the maximum available connections supported by your Linux kernel. There are 3 layers you need to check and configure:

  1. Kernel file-max
  2. Process file-max (ulimit)
  3. Systemd/Server config file-max (LimitNOFILE)

Any one of these layers can limit the number of max connections your web server process is allowed.

Source: Maximize your concurrent web server connections, an article by Alan Hamlett.