ID photo of Ciro Santilli taken in 2013 right eyeCiro Santilli OurBigBook logoOurBigBook.com  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

Type of programming language

words: 116 articles: 10

Programming paradigm

words: 77 articles: 4

Functional programming

words: 77 articles: 2
Good because unnecessary state is the source of much evil.
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.

Programming language construct

words: 39 articles: 2

for loop

words: 39
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.

List of programming languages

words: 6k articles: 159

awk (1977)

words: 10
Largest programs ever written:

Bash (Unix shell)

words: 15 articles: 1
The more heavily a project relies on it, the more you start to regret it.

C (programming language, 1972)

words: 175 articles: 4
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.

ANSI C

words: 4
A closed standard: stackoverflow.com/questions/81656/where-do-i-find-the-current-c-or-c-standard-documents. Nice.
Tagged

C library

words: 62 articles: 2
Tagged
C POSIX library
words: 62
Quick overview at stackoverflow.com/questions/1780599/what-is-the-meaning-of-posix/31865755#31865755
Exmples under c/posix:

C++

words: 40 articles: 1
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
Tagged
Likely a good replacement for Python. If the ecosystem gets there, Ciro Santilli would gladly use it more.

Haskell

words: 24
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. . Source.

Java (programming language)

words: 84 articles: 5
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.

JAVA_HOME

words: 30
This ultimately determines which Java is used by a bunch of tools.
TODO is there a way to update it sanely in Ubuntu: askubuntu.com/questions/175514/how-to-set-java-home-for-java to always match the default java executable?
Tagged
Tagged

JavaScript

words: 4k articles: 67
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
Tagged
www.google.com/search?q=client-side+storage&oq=Client-side+storage&aqs=chrome.0.0l3j0i22i30l4j69i60.88j0j7&client=ubuntu&sourceid=chrome&ie=UTF-8

JavaScript library

words: 231 articles: 11
Tagged
JavaScript game engine
words: 183 articles: 3
Phaser.js
words: 183 articles: 2
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: photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.ArcadePhysics.html 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 https://github.com/photonstorm/phaser3-examples
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.
A web server is mandatory for assets, unless you embed them in data URLs, file:// access is not possible:
JavaScript physics engine
words: 48 articles: 3
Matter.js
words: 48 articles: 2
To run the demos locally, tested on Ubuntu 22.10:
git clone https://github.com/liabru/matter-js
cd matter-js
git checkout 0.19.0
npm install
npm run dev
and this opens up the demos on the browser.
Hello world adapted from: github.com/liabru/matter-js/wiki/Getting-started/1d138998f05766dc4de0e44ae2e35d03121bb7f2
Also asked at: stackoverflow.com/questions/28079138/how-to-make-minimal-example-of-matter-js-work/76203103#76203103
Renderer questions:
Figure 2. Source.
js/matterjs/hello.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Matter.js hello world</title>
<script src="node_modules/matter-js/build/matter.min.js"></script>
<style>
body {
  background-color: white;
}
</style>
</head>
<body>
<h1>Matter.js hello world</h1>
<p><a href="http://cirosantilli.com/_file/js/matterjs/example.html">More information</a></p>
<script>
window.Matter || document.write('<script src="https://cdnjs.cloudflare.com/ajax/libs/matter-js/0.19.0/matter.min.js" integrity="sha512-0z8URjGET6GWnS1xcgiLBZBzoaS8BNlKayfZyQNKz4IRp+s7CKXx0yz7Eco2+TcwoeMBa5KMwmTX7Kus7Fa5Uw==" crossorigin="anonymous" referrerpolicy="no-referrer"><\/script>');
</script>
<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(engine.world, [boxA, boxB, ground]);

// run the renderer
Render.run(render);

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

// run the engine
Runner.run(runner, engine);
</script>
</body>
</html>
A multi-scenario demo.
js/matterjs/examples.html was not rendered because it is too large (> 2000 bytes)

JavaScript tooling

articles: 2
JavaScript linter
articles: 1

JavaScript language

words: 267 articles: 3
Node.js does have Node.js worker_threads however.
async (JavaScript)
words: 264 articles: 1
developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
async is all present in JavaScript for two reasons:
However, it is also Hell: how to convert async to sync in JavaScript.
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)),
])
Bibliography:
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: madelinemiller.dev/blog/javascript-promise-overhead/. Real world case with a 4x slowdown: github.com/ourbigbook/ourbigbook/tree/async-slow.
Anyways, since you Googled here, you might as well learn the standard pattern to convert callbacks functions into async functions using a promise: stackoverflow.com/questions/4708787/get-password-from-input-using-node-js/71868483#71868483

Node.js

words: 3k articles: 41
This section is present in another page, follow this link to view it.
This section is present in another page, follow this link to view it.
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:

Perl (programming language)

words: 32 articles: 2
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.

Perl HOWTO

words: 5 articles: 1
stackoverflow.com/questions/5617314/perl-regex-print-the-matched-value/5617355#5617355
perl -lne 'print for /mykey=(\d+)/'

Python (programming language)

words: 823 articles: 55
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.
Tagged
Python classes
articles: 4
docs.python.org/3/reference/datamodel.html#special-method-names
Python __getitem__
articles: 2
python/getitem.py
#!/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
        else:
            raise IndexError(i)
c = C(1, 2)
assert c[0] == 1
assert c[1] == 2
x0, x1 = c
assert x0 == 1
assert x1 == 2
python/getitem_complex.py
#!/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)

Python standard library

words: 6 articles: 15
Python abc
articles: 1
python/abc_cheat.py
#!/usr/bin/env python3

import abc

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

try:
    c = C()
except TypeError:
    pass
else:
    assert False
Python ast
articles: 1
python/ast_cheat.py
#!/usr/bin/env python

import ast
from ast import *

myast = ast.parse('''def inc(i):
    return i + 1

print(inc(2))
''')
# print(ast.dump(myast, indent=2))
print(ast.unparse(myast))
code = compile(myast, 'mymodule', 'exec')
exec(code)
print()

myast2 = ast.fix_missing_locations(Module(
  body=[
    FunctionDef(
      name='inc',
      args=arguments(
        posonlyargs=[],
        args=[
          arg(arg='i')],
        kwonlyargs=[],
        kw_defaults=[],
        defaults=[]),
      body=[
        Return(
          value=BinOp(
            left=Name(id='i', ctx=Load()),
            op=Add(),
            right=Constant(value=1)))],
      decorator_list=[]),
    Expr(
      value=Call(
        func=Name(id='print', ctx=Load()),
        args=[
          Call(
            func=Name(id='inc', ctx=Load()),
            args=[
              Constant(value=2)],
            keywords=[])],
        keywords=[]))],
  type_ignores=[]))
# print(ast.dump(myast2, indent=2))
print(ast.unparse(myast))
code2 = compile(myast2, 'mymodule', 'exec')
exec(code2)
Python dataclass
articles: 3
Python typing
words: 6 articles: 6
Examples under python/typing_cheat.
The hello world!
python/typing_cheat/hello.py
#!/usr/bin/env python3
i: int
i = 1
# Error:
i = 'a'
python/typing_cheat/infer.py
#!/usr/bin/env python3
i = 1
# Error:
i = 'a'
python/typing_cheat/union.py
#!/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
    else:
        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
    else:
        return str(i)

assert f(1) == '1'
assert f('1') == 2
# Error
assert f(1.0) == '1.0'
Python Protocol
articles: 2
python/typing_cheat/protocol.py
#!/usr/bin/env python3

from typing import Protocol

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

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

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

class FakeBird(CanFly):
    pass

assert Bird().fly() == 'Bird.fly'
assert Bird().fly_fast() == 'Bird.fly_fast'
assert FakeBird().fly() is None
assert FakeBird().fly() == ''
python/typing_cheat/protocol_empty.py
from typing import Protocol

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

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

class FakeBird(CanFly):
    pass

Bird().fly()
FakeBird().fly()
CPython
articles: 1
stackoverflow.com/questions/1294382/what-is-the-global-interpreter-lock-gil-in-cpython

Python package manager

words: 171 articles: 3
How many stupid bugs. How many stupid bugs do we need to face???
Conda
words: 38
Conda is like pip, except that it also manages shared library dependencies, including providing prebuilts.
This has made Conda very popular in the deep learning community around 2020, where using Python frontends like PyTorch to configure faster precompiled backends was extremelly common.
Tested on Ubuntu 20.04:
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-py311_23.11.0-2-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
. ~/.bashrc
and from then on we can do conda commands normally.
At that time, the exact installer under latest appears to have been: repo.anaconda.com/miniconda/Miniconda3-py311_23.11.0-2-Linux-x86_64.sh
pypi.org
The best package ever is: pypi.org/project/china-dictatorship/ see also: cirosantilli.com/china-dictatorship/mirrors

Python virtualization

words: 14 articles: 2
virtualenv
words: 14
python3 -m pip install --user virtualenv
virtualenv .venv
. .venv/bin/activate
pip install -r requirements.txt

Python documentation generator

words: 28 articles: 6
Sphinx (documentation generator)
words: 28 articles: 5
python/sphinx
words: 12
To run each example and see the output run:
./build.sh
xdg-open out/index.html
Minimal example. Gives a hint at how boilerplate heavy Sphinx can be!
stackoverflow.com/questions/34647966/how-to-express-multiple-types-for-a-single-parameter-or-a-return-value-in-docstr/40801906#40801906
Basic class example.
Polymorphism example:

Python library

words: 481 articles: 12
Tagged
Python scientific library
words: 373 articles: 8
Jupyter Notebook
words: 48 articles: 1
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.
Some other basic hits due to how bad Jupyter is:
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
}
NumPy
words: 251 articles: 3
The people who work on this will go straight to heaven, no questions asked.
numpy.fft
words: 236 articles: 2
numpy.org/doc/1.24/reference/routines.fft.html
Generates numpy/fft_plot.svg, the plot of with 25 points and its DFT.
The output was also uploaded to: commons.wikimedia.org/wiki/File:DFT_2sin(t)_%2B_sin(4t).svg and added to en.wikipedia.org/w/index.php?title=Discrete_Fourier_transform&oldid=1176616763 only to be later removed of course: Deletionism on Wikipedia.
Figure 3.
DFT of with 25 points
. Source code at: numpy/fft_plot.py.
numpy/fft_plot.py
#!/usr/bin/env python
# Python 3.12.3, Ubuntu 24.04.

import math

import matplotlib.pyplot as plt
import numpy as np

N = 25
x = np.array([2 * math.sin(i * 2 * math.pi / N) + math.cos(i * 2 * math.pi * 4 / N) for i in range(N)])
X = np.fft.fft(x)

fig, axs = plt.subplots(3, 1)
fig.suptitle('X = DFT(x)')
fig.tight_layout(rect=[0, 0.03, 1, 0.94])

ax = axs[0]
ax.set_title('x(t) = 2 sin(2 $\\pi$ t / 25) + cos(8 $\\pi$ t / 25)')
#ax.set_title('x(t) = 2 sin(t) + sin(4t) = $-25 e^{1 \\times 2\\pi i t/25} -12.5 e^{4 \\times 2\\pi i t/25} + 12.5 e^{21 \\times 2\\pi i t/25} + -25 e^{24 \\times 2\\pi i t/25}$')
ax.plot(np.arange(0., N, 1.), x, '.')
ax.axis([-0.5, N, -3.5, 3.5])
ax.set_yticks([-3, 0, 3], minor=False)
ax.grid()

ax = axs[1]
ax.set_title('Re(X(t))')
ax.plot(np.arange(0., N, 1.), np.real(X), '.')
ax.axis([-0.5, N, -30, 30])
ax.set_yticks([-25.0, -12.5, 0.0, 12.5, 25.0], minor=False)
ax.grid()

ax = axs[2]
ax.set_title('Im(X(t))')
ax.plot(np.arange(0., N, 1.), np.imag(X), '.')
ax.axis([-0.5, N, -30, 30])
ax.set_yticks([-25, -12.5, 0.0, 12.5, 25], minor=False)
ax.grid()

plt.savefig(
    'fft_plot.svg',
    format='svg',
    dpi=1000/plt.gcf().get_size_inches()[1],
    bbox_inches='tight',
)
numpy/fft.py
words: 191
Output:
sin(t)
fft
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
rfft
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)
fft
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
rfft
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
numpy/fft.py
#!/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)
    print('fft')
    printi(X)

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

N = 20

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

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)])
analyze(x)
print()
SageMath
words: 65
A Python wrapper over a bunch of numeric and computer algebra system packages to try and fully replace MATLAB et. al.
Quickstart tutorial at: www.sagemath.org/tour-quickstart.html 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.
Scikit-learn
words: 9
Examples under python/sklearn
. .venv/bin/activate
pip install sklearn matplotlib seaborn
Python web framework
words: 108 articles: 2
Django (web-framework)
words: 108 articles: 1
React setups:
One problem with Django is that it does not expose its ORM as an external library: stackoverflow.com/questions/33170016/how-to-use-django-1-8-5-orm-without-creating-a-django-project 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: stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass 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")'
Tagged

Ruby (programming language)

words: 208 articles: 3

Ruby on Rails

words: 208 articles: 2
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.
Ruby on Rails React integration
words: 120 articles: 1
Integrations React integration:
Uses Redux, while reactjs/react-rails appears to do that more manually
Lots of focus on Heroku deployability, which is fantastic: shakacode.gitbooks.io/react-on-rails/content/docs/additional-reading/heroku-deployment.html
Live instance: www.reactrails.com/ with source at: github.com/shakacode/react-webpack-rails-tutorial Not the most advanced web-app (a gothinkster/realworld-level would be ideal). Also has clear dependency description, which is nice.
Trying at github.com/shakacode/react-webpack-rails-tutorial/tree/8e656f97d7a311bbe999ceceb9463b8479fef9e2 on Ubuntu 20.10. Got some failures: github.com/shakacode/react-webpack-rails-tutorial/issues/488 Finally got a version of it working at: github.com/shakacode/react-webpack-rails-tutorial/issues/488#issuecomment-812506821
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 twitter.com/railsonmaui/status/1377515748910755851, Ciro Santilli was jealous of him.
Tagged

Tcl

words: 54
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.

Ancestors (6)

  1. Software
  2. Computer
  3. Information technology
  4. Area of technology
  5. Technology
  6. Home