Ciro Santilli $£ Sponsor €¥ 中国独裁统治 China Dictatorship 新疆改造中心、六四事件、法轮功、郝海东、709大抓捕、2015巴拿马文件 邓家贵、低端人口、西藏骚乱
A language that allows you to talk to and command a computer.
There is only space for two languages at most in the world: the compiled one, and the interpreted one.
For 2020 now, when you have a choice, you must go for:
  • Python as the interpreted one
  • C++ for compiled
Those two are languages not by any means perfect from a language design point of view, and there are likely already better alternatives, they are only chosen due to a pragmatic tradeoff between ecosystem and familiarity.
Ciro predicts that Python will become like Fortran in the future: a legacy hated by most who have moved to JavaScript long ago (which is slightly inferior, but too similar, and with too much web dominance to be replaced), but with too much dominance in certain applications like machine learning to be worth replacing, like Fortran dominates certain HPC applications. We'll see. Maybe non performance critical scripting languages are easier to replace.
C++ however is decent, and is evolving in very good directions in the 2010's, and will remain relevant in the foreseeable future.
Bash can also be used when you're lazy. But if the project goes on, you will sooner or later regret that choice.
The language syntax in itself does not matter. All that matters is how many useful libraries and tooling it has.
This is how other languages compare:
  • C: but cannot make a large codebase DRY without insanity
  • Ruby: the exact same as Python, and only strong in one domain: web development, while Python rules everything else, and is not bad on web either. So just kill Ruby, please.
  • JavaScript: it is totally fine if Node.js destroys Python and becomes the ONE scripting language to rule them all since Python and JavaScript are almost equally crappy (although JavaScript is a bit more of course).
    One thing must be said tough: someobject.not_defined_property silently returning undefined rather than blowing up is bullshit.
  • Go: likely a good replacement for Python. If the ecosystem gets there, will gladly use it more.
  • Java: good language, but has an ugly enterprisey ecosystem, Oracle has made/kept the development process too closed, and API patenting madness on Android just kills if off completely
  • Haskell: many have tried to learn some functional stuff, but too hard. Sounds really cool though.
  • Rust: sounds cool, you will gladly replace C and C++ with it if the ecosystem ramps up.
  • C#: Microsoft is evil
  • Tcl, Perl: Python killed them way back and is less insane
  • R, GNU Octave and any other "numerical computing language": all of this is a waste of society's time as explained at: Section "Numerical computing language"
  • Swift: Ciro would rather stay away from Apple dominated projects if possible since they sell a closed source operating system
Even if we cannot do everything in functional, we should at least strive to clearly extract functional substes in what we do.
Ciro Santilli thinks imperative programming is just a superset of functional programming where you can have state.
C and C++: OK, you're old before the Internet and compiled, forgiven.
Python: OMG, please, just make it work!!! Your are interpreted!!! You are a hot web technology!!! Node.js and Ruby are doing just fine, and Ruby is not newer than you!!! See also: pip.
Interestingly, the very first programming language with an actual implementation was interpreted: Short Code in 1950.
This is not surprising, as interpreters are easier to write than compilers.
And just like modern scripting languages, it reduced execution speed by about 50x.
The for loop is a subcase of the while loop.
One theoretical motivation for its existence is that it has the fundamental property that we are immediately certain it will terminate, unlike while loops with arbitrary conditions.
Primitive recursive functions are the complexity class that divides those two.
The more heavily a project relies on it, the more you start to regret it.
It gets the job done, but cannot make a large codebase DRY without insanity.
As of 2020, C is like Latin, and we are in the Middle Ages, where it has become a lingua franca.
It is interesting to note how late C appeared: 1972, compared e.g. to Fortran which is from 1957. This is basically because C was a "systems programming language", i.e. with focus on pointer manipulation, and because early computers were so weak, there was no operating system or many software layers in the early days. Fortran however was a numerical language, and it ran directly on bare metal, an application that existed before systems programming.
Examples under c.
Exmples under c/posix:
C plus plus is what you get when you want to have all of:
  • ability to write DRY code, which is e.g. impossible in the C
  • low level control, notably not having garbage collection, as possible in the C
  • somewhat backwards compatibility with C
Likely a good replacement for Python. If the ecosystem gets there, Ciro Santilli would gladly use it more.
There are only two pre-requisites to using Haskell in 2020. You have to be an idealist. And you have to be a genius:
Figure 1. xkcd 1312: Haskell. Source.
Java is good.
Its boilerplate requirement is a pain, but the design is otherwise very clean.
But its ecosystem sucks.
The development process is rather closed, the issue tracker obscure.
And above all, Google LLC v. Oracle America, Inc. killed everybody's trust in it once and for all. Thanks Oracle.
Video 1. Java for the Haters in 100 Seconds by Fireship (2022) Source.
The language all browsers converted to as of 2019, and therefore the easiest one to distribute and most widely implemented programming language.
Hopefully will be killed by WebAssembly one day.
Because JavaScript is a relatively crap/ad-hoc language, it ended up some decent tooling to make up for that, e.g. stuff like linting via ESLint and reformatting through Prettier is much more widespread than in other languages.
JavaScript data structure are also quite a bit anemic, which makes libraries such as lodash incredibly popular. But most of that stuff should be in the stdlib.
Our JavaScript examples can be found at:
  • Node.js example: examples that don't interact with any browser feature. We are just testing those on the CLI which is much more convenient.
  • JavaScript browser example: examples that interact with browser-specific features, notably the DOM
Likely the best JavaScript 2D game engine as of 2023.
Uses Matter.js as a physics engine if enabled. There's also an alternative (in-house?) "arcade" engine: but it appears to be simpler/less robust (but also possibly faster).
TODO any 2D first person examples a bit like Ciro's 2D reinforcement learning games?
The examples are present under:
git clone
but note that that repo is huge, about 4.5 GiB on local disk, as is has tons of assets.
The demos also include a Monaco-editor based sandbox mode where you can edit code directly on the web and see the game update which is a really sweet addition.
To run the demos locally, tested on Ubuntu 22.10:
git clone
cd matter-js
git checkout 0.19.0
npm install
npm run dev
and this opens up the demos on the browser.
This section is about the file: js/matterjs/hello.html
Renderer questions:
Figure 2. Source.
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<title>Matter.js hello world</title>
<script src="node_modules/matter-js/build/matter.min.js"></script>
body {
  background-color: white;
<h1>Matter.js hello world</h1>
<p><a href="">More information</a></p>
window.Matter || document.write('<script src="" integrity="sha512-0z8URjGET6GWnS1xcgiLBZBzoaS8BNlKayfZyQNKz4IRp+s7CKXx0yz7Eco2+TcwoeMBa5KMwmTX7Kus7Fa5Uw==" crossorigin="anonymous" referrerpolicy="no-referrer"><\/script>');
// module aliases
var Engine = Matter.Engine,
    Render = Matter.Render,
    Runner = Matter.Runner,
    Bodies = Matter.Bodies,
    Composite = Matter.Composite;

// create an engine
var engine = Engine.create();

// create a renderer
var render = Render.create({
    element: document.body,
    engine: engine

// create two boxes and a ground
var boxA = Bodies.rectangle(400, 200, 80, 80);
var boxB = Bodies.rectangle(450, 50, 80, 80);
var ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true });

// add all of the bodies to the world
Composite.add(, [boxA, boxB, ground]);

// run the renderer;

// create runner
var runner = Runner.create();

// run the engine, engine);
This section is about the file: js/matterjs/examples.html
A multi-scenario demo.
js/matterjs/examples.html was not rendered because it is too large (> 2000 bytes)
Node.js does have Node.js worker_threads however.
async is all present in JavaScript for two reasons:
God, it's impossible! You just have to convert the entire fucking call stack all the way up to async functions. It could mean refactoring hundreds of functions.
To be fair, there is a logic to this, if you put yourself within the crappiness of the JavaScript threading model. And Python is not that much better with its Global Interpreter Lock.
The problem is that async was introduced relatively late, previously we just had to use infinitely deep callback trees, which was worse:
myAsync().then(ret => myAsync2(ret).then(ret2 => myAsync3(re3)))
compared to the new infinitely more readable:
ret = await myAsync()
ret2 = await myAsync2(ret)
ret3 = await myAsync3(ret3)
But now we are in an endless period of transition between both worlds.
It is also worth mentioning that callbacks are still inescapable if you really want to fan out into a non-linear dependency graph, usually with Promise.all:
await Promise.all([
  myAsync(1).then(ret => myAsync2(ret)),
  myAsync(2).then(ret => myAsync2(ret)),
And then, after many many hours of this work, you might notice that the new code is way, way way slower than before, because making small functions async has a large performance impact: Real world case with a 4x slowdown:
Anyways, since you Googled here, you might as well learn the standard pattern to convert callbacks functions into async functions using a promise:
Since JavaScript devs are incapable of defining an unified import standard, this design pattern emerged where you just check every magic global one by one. Here's a demo where a Js library works on both the browser and from Node.js:
TODO why did Python kill it? They are very similar and existed at similar times, and possibly Perl was more popular early on.
Perl likely killed Tcl.
Examples under python.
Ciro Santilli's wife was studying a bit of basic Python for some job interviews, when she noticed:
Wow, in is so powerful! You can do for x in list, for x in dict and if x in dict all with that single word!
Damn right, girl, damn right.
Ciro remembers hearing about Python online briefly. It seemed like a distant thing from the Java/C dominated (and outdated) university courses. Then some teaching assistant mentioned during some course when Ciro was at École Polytechnique that Python was a great integration tool. That sounded cool.
Then finally, when the École Polytechnique mathematics department didn't let Ciro Santilli do his internship of choice due to grades and Ciro was at an useless last moment backup internship, he learned more Python instead of doing his internship job, and was hooked.
This section is about the file: python/
#!/usr/bin/env python3
class C:
    def __init__(self, x0, x1):
        self.x0 = x0
        self.x1 = x1

    def __getitem__(self, i):
        if i == 0:
            return self.x0
        elif i == 1:
            return self.x1
            raise IndexError(i)
c = C(1, 2)
assert c[0] == 1
assert c[1] == 2
x0, x1 = c
assert x0 == 1
assert x1 == 2
This section is about the file: python/
#!/usr/bin/env python

class C(object):
    def __getitem__(self, k):
        return k

# Single argument is passed directly.
assert C()[0] == 0

# Multiple indices generate a tuple.
assert C()[0, 1] == (0, 1)

# Slice notation generates a slice object.
assert C()[1:2:3] == slice(1, 2, 3)

# Empty slice entries become None.
assert C()[:2:] == slice(None, 2, None)

# Ellipsis notation generates the Ellipsis class object.
# Ellipsis is a singleton, so we can compare with `is`.
assert C()[...] is Ellipsis

# Everything mixed up.
assert C()[1, 2:3:4, ..., 6, :7:, ..., 8] == \
       (1, slice(2,3,4), Ellipsis, 6, slice(None,7,None), Ellipsis, 8)
This section is about the file: python/
#!/usr/bin/env python3

import abc

class C(metaclass=abc.ABCMeta):
    def m(self, i):

    c = C()
except TypeError:
    assert False
Examples under python/typing_cheat.
This section is about the file: python/typing_cheat/
The hello world!
#!/usr/bin/env python3
i: int
i = 1
# Error:
i = 'a'
This section is about the file: python/typing_cheat/
#!/usr/bin/env python3
i = 1
# Error:
i = 'a'
This section is about the file: python/typing_cheat/
#!/usr/bin/env python3

from typing import Union

def f(i: Union[int,str]) -> Union[int,str]:
    if type(i) is str:
        return int(i) + 1
        return str(i)

assert f(1) == '1'
assert f('1') == 2
# Error
assert f(1.0) == '1.0'

def f_or(i: int | str) -> int | str:
    if type(i) is str:
        return int(i) + 1
        return str(i)

assert f(1) == '1'
assert f('1') == 2
# Error
assert f(1.0) == '1.0'
This section is about the file: python/typing_cheat/
#!/usr/bin/env python3

from typing import Protocol

class CanFly(Protocol):
    def fly(self) -> str:

    def fly_fast(self) -> str:
        return 'CanFly.fly_fast'

class Bird(CanFly):
    def fly(self):
        return ''
    def fly_fast(self):
        return 'Bird.fly_fast'

class FakeBird(CanFly):

assert Bird().fly() == ''
assert Bird().fly_fast() == 'Bird.fly_fast'
assert FakeBird().fly() is None
assert FakeBird().fly() == ''
This section is about the file: python/typing_cheat/
from typing import Protocol

class CanFly(Protocol):
    def fly(self) -> None:
        raise NotImplementedError()

class Bird(CanFly):
    def fly(self):
        return None

class FakeBird(CanFly):

How many stupid bugs. How many stupid bugs do we need to face???
python3 -m pip install --user virtualenv
virtualenv .venv
. .venv/bin/activate
pip install -r requirements.txt
This section is about the directory: python/sphinx
To run each example and see the output run:
xdg-open out/index.html
This section is about the directory: python/sphinx/hello
Minimal example. Gives a hint at how boilerplate heavy Sphinx can be!
This section is about the directory: python/sphinx/union
This section is about the directory: python/sphinx/class
Basic class example.
This section is about the directory: python/sphinx/virtual_method
A waste of time. Output in my source files pollutes git and prevents me from editing it in Vim. Just let me run the freacking code and render images as standalone PNGs which I can include from Markdown.
This section is about the file: python/jupyter/hello.ipynb
 "cells": [
   "cell_type": "code",
   "execution_count": null,
   "id": "a221e409",
   "metadata": {},
   "outputs": [],
   "source": [
    "1 + 1"
   "cell_type": "code",
   "execution_count": null,
   "id": "acdb4068",
   "metadata": {},
   "outputs": [],
   "source": []
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.7"
 "nbformat": 4,
 "nbformat_minor": 5
The people who work on this will go straight to heaven, no questions asked.
Figure 3. DFT of with 25 points. Source. Source code at: numpy/
This section is about the file: numpy/
real 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10
real 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 0 0 0 0 0 0 0

sin(t) + sin(4t)
real 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 -10 0 0 0 0 0 0 0 0 0 0 0 10 0 0 10
real 0 0 0 0 0 0 0 0 0 0 0
imag 0 -10 0 0 -10 0 0 0 0 0 0
With our understanding of the discrete Fourier transform we see clearly that:
  • the signal is being decomposed into sinusoidal components
  • because we are doing the Discrete Fourier transform of a real signal, for the fft, so there is redundancy in the. We also understand that rfft simply cuts off and only keeps half of the coefficients
#!/usr/bin/env python
import math
import numpy as np

def printi(X):
    # Round to int otherwise there is a lot of small numerical noise.
    print('real ' + ' '.join(str(int(np.real(x))) for x in X))
    print('imag ' + ' '.join(str(int(np.imag(x))) for x in X))

def analyze(x):
    # FFT
    X = np.fft.fft(x)

    # Real FFT
    Xr = np.fft.rfft(x)

N = 20

x = np.array([math.sin(i * 2 * math.pi / N) for i in range(N)])

print('sin(t) + sin(4t)')
x = np.array([math.sin(i * 2 * math.pi / N) + math.sin(i * 2 * math.pi * 4 / N) for i in range(N)])
A Python wrapper over a bunch of numeric and computer algebra system packages to try and fully replace MATLAB et. al.
Quickstart tutorial at: From this we see that they are very opinionated, you don't need to import anything, everything has a pre-defined global name, which is convenient, e.g.:
is the 3D vector space over the rationals. This also suggests that they are quite focused on computer algebra as opposed to numerical.
Examples under python/sklearn
. .venv/bin/activate
pip install sklearn matplotlib seaborn
One problem with Django is that it does not expose its ORM as an external library: which is wasteful of development time.
As of 2021, last updated 2016, and python 3.5 appears to be mandatory or else:
RuntimeError: __class__ not set defining 'AbstractBaseUser' as <class 'django.contrib.auth.base_user.AbstractBaseUser'>. Was __classcell__ propagated to type.__new__?
which apparently broke in 3.6: and pyenv install fails on Ubuntu 20.10, so... fuck. Workarounds at:
but am I in the mood considering that the ancient Django version would require an immediate port anyways? Repo is at Django 1.0, while newest is now already Django 3. The Rails one is broken for the same reason. Fuck 2.
Ubuntu 23.04 install:
sudo apt install rbase
Hello world:
R -e 'print("hello world")'
Install a package, e.g. Bookdown:
sudo R -e 'install.packages("bookdown")'
The only reason why Ruby exists.
This web framework is pretty good as of 2020 compared to others, because it managed to gain a critical community size, and there's a lot of basic setup already done for you.
it is just big shame it wasn't written in Python or even better, Node.js, because learning Ruby is completely useless for anything else. As of 2020 for example, most Node.js web frameworks feel like crap compared to Rails, you just have to debug so much there.
Used in GitLab, which is why Ciro Santilli touched it.
Integrations React integration:
Uses Redux, while reactjs/react-rails appears to do that more manually
Live instance: with source at: Not the most advanced web-app (a gothinkster/realworld-level would be ideal). Also has clear dependency description, which is nice.
Oh, and the guy behind that project lives in Hawaii (Ciro Santilli's ideal city to live in), has an Asian-mixed son, and two Kinesis Advantage 2 keyboards as seen at, Ciro Santilli was jealous of him.
One of the first big interpreted programming languages to go a bit further than Bash' word replacement insanity.
To the modern viewer, it feels like a middle ground between Bash and Python.
It was completely insane however, and it just died: Python is much saner, and Bash, although totally insane still golfs better, especially on the file manipulation context.


  1. Software
  2. Computer
  3. Information technology
  4. Area of technology
  5. Technology
  6. Ciro Santilli's Homepage