Type systems are a powerful tool for simplifying your life as a developer. Not only do they make the organization of the data in your program clearer, but they also provide excellent debugging capabilities. One problem can be all the boilerplatey code you have to write when working with a bunch of different types. Luckily this article shows us an implementation of a completely abstract union in Scala that can take any types and any number of them, performing specifics actions based on the number of inputs and their types. Sounds complicated? Don’t worry, it starts off simple and builds out.
If you have a smart phone or a voice activated device, you’ll know that often times you’ll have some starter word(s) that signals to the device that you want it to take a command. Well have you ever wondered how that is accomplished? Although it doesn’t focus specifically on these devices, this article takes a look at the Dynamic Time Warping (DTW) data processing technique that is commonly used for comparing two time series sets to one another. This is done in a practical approach by implementing a linear comparison and a DTW algorithm in Python with an example of comparing temperatures in US cities and comparing their results.
Algebraic effects are powerful and versatile abstractions, borrowed primarily from functional programming and set theory. Their general format is made up of two parts, the initial one “introduces an effect” and the following part “handles it”. Remind you of anything? They’re similar to throwing exceptions in most other languages, other than the fact that they don’t stop normal code flow. In this article we’re introduced to a gem called dry-effects, which provides Reader, State, Interrupt, Current Time, Parallel, Resolve, Cache, Env, and Timeout, the first 5 of which are demonstrated with implementations.
All popular languages grow and change considerably over time; it’s the only way to keep up with new programming techniques and best practices. C++ is no exception, with the last few and upcoming 2020 release have some substantial changes that have progressively made using the language easier and the code more understandable. This article highlights the past changes in C++ by implementing the detection idiom (used to “set a constraint on a template parameter or to select a template specialization”) in pre-C++11, C++11, C++17, and finally in C++20 with concepts, demonstrating the progressive improvements in code design and readability.
Being able to quickly scan through code and grok it without any problems is not only dependent on you, but also on how expressively the code is written. Having to go back and forth between code looking up definitions of what functions do because something isn’t clearly written is not only a waste of time, but thoroughly exhausting. This article takes a stab at showing us how to write more expressive code by first thinking about what the code for setting a maximum or minimum value should look like, then implementing it in C++ using strong types to mimic infix syntax.