Skip to main content

Posts

A Finnish web developer works as a consultant

If you ask a random Finnish web developer to detail the projects they have worked on, I bet YLE (Finnish public broadcasting company) comes up. If you further ask to rank the projects, it would likely score high. The devs I've talked to and the Yle talks I've listened to have convinced me that taking a gig in Yle is indeed one of the most remarkable things to do in Finland. I'm not sure, but I think a US developer might not see working for the PBS as their career highlight. As a taxpayer, especially working in IT, it is fantastic that Finnish talent works on major, often publicly funded, megaprojects. The digital services are made well, robustly, and rate among the world's best. The developers enjoy working in such places because that all-knowing mentor colleague is sitting next to you. There are few Twitters or other desirable "web-scale" projects available locally. Not incidentally, this means that the barrier of entry is high to get these jobs. The Finnish ...

Best music of 2021

No recap of lessons learned this year. Instead, here is a collection of some of the best music from 2021. Proud to say that I succeeded in my goal of listening to more Finnish records! Shoutout to Radio Helsinki and its feature programs for keeping me on that path. Albums and EPs Handshaking - Garden Clogs Seeing Fedja Kamari perform live was one of the most memorable experiences this summer. The song "Näin kai taas lankesin" even in a formidable seven-and-a-half minute length, is a masterwork in tension-building and incidentally my most listened tune of the year. Richard Dawson, Circle - Henki Dawsons falsetto started to catch my ear while listening to the Finnish indie Spotify list. Slowly it began to grow on me. The rough, unpolished sound of the Circle with its unbridled energy makes me grin. Ichiko Aoba - Windswept Adan The soothing voice of Aoba's gives me the chills. Her impressive upper range combined with a dreamy flute produces a powerful emotional experience. T...

Note to self: use common collection functions

The Advent of Code in Elixir continues to be a humbling experience year after year. One of my weaknesses in programming puzzles and, in general, is a lack of intuition on which common collection operations to use. Or, to be more precise, since I don't know them intimately, I don't know when to apply them in code. It is way too often I get feedback on a code review on  why do you do this thing with a plain map or reduce while you could use this and that helper function . Often, one can replace a custom function with a more expressive composition of well-known "stock" functions. I think a recap is in order. I enumerate in this post the most useful ones for me - or at least those I get the most feedback from. These are indeed useful even in the basic CRUD app!  I took the names from Scala and Elixir standard libraries and checked that functions with similar names exist in Lodash and Ramda JS external libraries Chunk/Group/Split/Partition Make a list of lists based on a f...

Deciphering yet another mystery parameter - camera picture quality

I don't know much about photography and much less about image formats. The little I know comes mostly from web development. There I use images as semi-static assets, and I know how to work around the potential problems.  That experience was of limited use when I worked on end-user-created images on a React Native app I'm working on. I needed a crash course into JPEGs.  We use react-native-camera to take photos. Snapping one has an elusive option called photo quality . It is an integer in a range between zero and one, and in the example code, it was set to 0.5. Zero point five . What does that mean? Is that good? 0.5 does not feel that good. To me, a modern iPhone is more than 0.5? The default value is 1 though, is that better? I wanted to find out what turning that mystery knob entails. Spoiler alert: the JPEG quality is clearly explained in the JPEG Wikipedia article, but obviously, I needed to jump through some hoops to understand that. I want to go through some generic th...

When React state management is not enough, I use atoms

I'm a fan of Kent C. Dodds. He has an excellent blog , he holds office hours on Youtube  and he manages an active Discord community focused on helping developers make maintainable React apps. I especially appreciate the way he thinks about state management in React apps. It does not have to be so reliant on external libraries. React itself is a library for managing state, so why not depend on its built-in abstractions. On a React Native app I'm building, most (> 95%) of the state management is indeed done with the React primitives: useStates, Contexts, and Refs. It is a big pile of hook compositions, and that's the way I like it. If you are familiar with React and can read its documentation, you can understand the code. There are a handful of places where using the primitives fall short, though. In these spots, plain old React hooks would require excessive glue code and would ultimately be confusing. Also, skipping needless renders in components such as forms can be tric...

100% unit test coverage

I write a lot of stupid and useless unit tests. I confess that I'm aiming towards the elusive 100% test coverage. Sure, I'll never get there, and I realize it is not even a desirable goal. After an assessed threshold, we start to get diminishing returns. Why do I keep writing wrong tests then? Which unit tests should I leave out? My case is that it is tricky to write a large codebase with only valuable tests. I dare say that some (minority) of the essential tests might have outright bad practices where they end up testing how well I can mock stuff. The value of the test is not predetermined; hence I keep writing a lot of seemingly poor ones. There is an argument that high test coverage does not strongly reduce bugs and increase maintainability. That is likely true. Nonetheless, it is not so apparent which tests will avoid the most bugs or are the most useful in refactoring in the long term. The cliché is that requirements change, sometimes towards unknown directions.  It is mor...

Debugging slow VSCode TS project with tsc generateTrace

VS code feels slow. All of a sudden, saving took forever in a TS project. The first suspect was a recently added WallabyJS test runner extension. So I disabled all plugins but still, saving took several seconds. My head then turned towards TS. Arrogantly I blamed some dependency but I had not a clue which one. Github TS wiki has some tips and tricks on what to do, including instructions to run a profiler. Turns out, a new profiling tool was introduced not too long ago in TS 4.1.  The output looks like this. Compiling the slowest source file takes more than 7 seconds! There is one massively slow checkSourceFile call which, as the name says, compiles a single file. To my embarrassment, it was in my code 😱 The profiling output is rather hard to decipher. The UI shows which TS internal functions are called and references a separate JSON file containing the type names. In my case, the slow function(s) included some weird single character type names, so it was not much help. The ...