Programming

This is Words and Buttons Online — a collection of interactive #tutorials, #demos, and #quizzes about #mathematics, #algorithms, and #programming.

If you prefer books to blogs, there is a free book that was originally made from this section.

The Real C++ Killers (Not You, Rust)

All the “C++ killers”, even these which I wholeheartedly love and respect like Rust, Julia, and D, help you write more features with fewer bugs, but they don't much help when you need to squeeze the very last FLOPS from the hardware you rent. As such, they don’t have a competitive advantage over C++. Or, for that matter, even over each other. Most of them, for instance, Rust, Julia, and Clang even share the same backend. You can’t win a car race if you all share the same car. So, which technologies do hold a competitive advantage over C++ or, speaking generally, all the traditional ahead-of-time compilers?

Either your estimates suck or your job does

This page uses polynomial modeling to show why software engineering tasks are often impossible to estimate.

Static typing isn’t free. Where do you think the C++ angry mob comes from?

Type inference works like logic deduction so any program in a statically typed language is two programs. The first one is the thing you sell, and the second – is a model that undergoes some sort of verification every time you run a compiler. This second program, although, often being written unknowingly, is not a free bonus, it’s something you have to pay for in several ways.

Check if your performance intuition still works with CUDA

An interactive quiz about microoptimizations in CUDA. 10 rounds, two pieces of code per each, you get to guess which is the faster.

Redundant stories about redundancy

Component redundancy is used heavily in safety-critical and mission-critical systems for reliability improvement. But outside this niche, it's surprisingly little known in the world of software. Which is a shame since it's a simple but economical idea. It costs nothing to keep in mind, and it saves you a lot on hotfixes and emergency repairs.

Challenge your performance intuition with C++ sine

One more interactive quiz. This time, it's all about the sine function. Which one is faster and when?

Yet another alternative to floating-point numbers

This shows how computable intervals written in rational bounds may not only account for the input error but keep computational error under control as well.

Why is it ok to divide by 0.0?

This explains why dividing by zero in floating-point numbers is ok.

Error codes are not numbers. But they are. Can we exploit that?

An interactive explanation of how we can use floating-point NaNs as error code holders in C++.

Challenge your performance intuition with nanosecond sorting

And yet another interactive quiz where you get to estimate the performance difference between several variants of the same code.

SymPy makes math fun again

An introduction into symbolic computations in Python. Don't worry, it's much simpler than it sounds. It's about making Python do your math for you with very little investment in the technology.

Yet another floating-point tutorial

Most of what you should know about floating-point numbers put together in an interactive tutorial with quests and puzzles.

Lexical differential highlighting instead of syntax highlighting

This type of highlighting is ideal for assembly. With it, the things that shouldn't seem similar usually don't.

Using logical operators for logical operations is good

This is the follow-up for the “Challenge your intuition with C++ operators”. It shows that despite the occasional gains from a better compilation, using the proper operators is still beneficial in the long run.

Challenge your performance intuition with C++ operators

Another interactive quiz where you get to estimate the performance difference between several variants of the same code.

Fortran is still a thing

A short essay about Fortran in the modern world.

Why Erlang is among the few true computer languages

Usually, a language is something that is used for bilateral communication. For programming languages, this is often untrue. Erlang shows how this can be achieved still.

If I were to invent a programming language for the 21st century

A short essay about the evolution of programming languages.

A cheap trick to speed up recursion in C++

More often than not, recursion is not your performance problem, to begin with. But even if it is, you can often avoid recursion altogether. When for some reason you can't, this trick helps.

Logic programming in C++

This shows that there is an invisible Prolog in every C++ compiler. It's up to you what to do with it but it's there.

Tries as the evolution of nothing

Trie is a data structure. Like “tree” but different. This tutorial explains the concept behind the trie, what makes it efficient, and when.

Estimating floating-point error the easy way

An explanation of how to measure computational error while working with floating-point numbers, and why.

APL deserves its renaissance too

APL tutorial explaining the meaning of life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

Playing a game of chance with C++ inline keyword

It's about one particular aspect of C++ compilation that makes programming with the “inline” into a game of chance.

How much math can you do in 10 lines of Python

An interactive introduction into concise Python / basic linear algebra.

Outperforming everything with anything

A 100 lines of Python code that substitute the compiler front-end for a specific computation. This shows that you don't need a “fast” compiling language to write efficient code. In fact, a compilation is only one of the multiple ways to achieve speed.

Vastly outperforming LAPACK with C++ metaprogramming

Still not really about LAPACK. It's a second part of the “outperforming” series explaining how the C++ metaprogramming can appear useful for efficient code generation.

Outperforming LAPACK with C metaprogramming

Ok, it's not really about LAPACK. You can consider it clickbait if you wish. It's about how to tell a compiler to write the code you want with a limited arsenal of tools the C language provides.

Can you tell an assembly language when you see one?

An interactive quiz featuring several obscure high-level languages and assembly variants.

Even if you can't write assembly like a poet, you can read disassembly like a hunter

This is a very concise introduction to x86 disassembly. It shows that you probably have all the skills to start reading disassembly right now even if you thought it was too complicated for you. It really isn't, see it for yourself.

Challenge your performance intuition with C++ magic squares

An interactive quiz where you get to estimate the performance difference between several variants of the same code.

So you think you know C?

It's a C test. If you think you know C, take this test. It only has 5 questions.

Learn you a Lisp in 0 minutes

A short quiz to reveal your hidden knowledge of Lisp.