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.
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 returningundefined
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.
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.
Largest programs ever written:
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.
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.
A closed standard: stackoverflow.com/questions/81656/where-do-i-find-the-current-c-or-c-standard-documents. Nice.
Tagged
Quick overview at stackoverflow.com/questions/1780599/what-is-the-meaning-of-posix/31865755#31865755
Exmples under c/posix:
- c/posix/signal_return.c: stackoverflow.com/questions/37063212/where-does-signal-handler-return-back-to
- c/posix/inet/pton.c:
inet_pton
demo. Adapted fromman inet_pton
on Ubuntu 23.04. Usage:Output:./pton.out 192.187.1.42
So we see that the strings was converted to an integer, e.g.:0xc0bb012a
See also: stackoverflow.com/questions/1680622/ip-address-to-integer-c/76520978#76520978- 0xc0 = 192
- 0xbb = 187
- 0x01 = 1
- 0x2a = 42
- c/posix/inet/ntop.c:
inet_ntop
demo. Adapted fromman inet_pton
on Ubuntu 23.04. Usage:Output:./ntop.out 0x01021AA0
./ntop.out 0x01021AA0
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.
There are only two pre-requisites to using Haskell in 2020. You have to be an idealist. And you have to be a genius:
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.
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
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
Tagged
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:but note that that repo is huge, about 4.5 GiB on local disk, as is has tons of assets.
git clone https://github.com/photonstorm/phaser3-examples
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.
- phaser/hello.html: a minimal hello world adapted from web.archive.org/web/20230323212804/https://phaser.io/tutorials/getting-started-phaser3/part5. Not an actual game strictly speaking though, just shows the phaser logo bouncing around the screen.Fully contained in a single HTML file, except that it loads the phaser library and image assets from the web.
- phaser/hello-game.html: an actually hello world game where you have to collect stars and avoid bombs.Based on labs.phaser.io/index.html?dir=games/firstgame/&q=:
- finished version: labs.phaser.io/view.html?src=src/games/firstgame/part10.js
- corresponding tutorial: web.archive.org/web/20230323210501/https://phaser.io/tutorials/making-your-first-phaser-3-game/part10.
A web server is mandatory for assets, unless you embed them in data URLs,
file://
access is not possible:To run the demos locally, tested on Ubuntu 22.10:and this opens up the demos on the browser.
git clone https://github.com/liabru/matter-js
cd matter-js
git checkout 0.19.0
npm install
npm run dev
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:
- follow object on viewport: codepen.io/csims314/pen/goZQvG
- draw text: github.com/liabru/matter-js/issues/321
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)
Node.js does have Node.js
worker_threads
however.async
is all present in JavaScript for two reasons:- you make network requests all the time
- JavaScript is single threaded, so if you are waiting for a network request, the UI freezes, see remarks on the deprecation of synchronous HTTP request at: developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Synchronous_and_Asynchronous_Requests
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:compared to the new infinitely more readable:But now we are in an endless period of transition between both worlds.
myAsync().then(ret => myAsync2(ret).then(ret2 => myAsync3(re3)))
ret = await myAsync()
ret2 = await myAsync2(ret)
ret3 = await myAsync3(ret3)
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:
- stackoverflow.com/questions/21819858/how-to-wrap-async-function-calls-into-a-sync-function-in-node-js-or-javascript
- stackoverflow.com/questions/9121902/call-an-asynchronous-javascript-function-synchronously
- stackoverflow.com/questions/47227550/using-await-inside-non-async-function
- stackoverflow.com/questions/43832490/is-it-possible-to-use-await-without-async-in-js
- stackoverflow.com/questions/6921895/synchronous-delay-in-code-execution
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
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:
- web-cheat/umd_my_lib.js: the library
- web-cheat/umd.js: Node.js user
- web-cheat/umd.html: browser user
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.
stackoverflow.com/questions/5617314/perl-regex-print-the-matched-value/5617355#5617355
perl -lne 'print for /mykey=(\d+)/'
Examples under python.
Ciro Santilli's wife was studying a bit of basic Python for some job interviews, when she noticed:Damn right, girl, damn right.
Wow,in
is so powerful! You can dofor x in list
,for x in dict
andif x in dict
all with that single word!
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/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/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_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)
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/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()
How many stupid bugs. How many stupid bugs do we need to face???
- this fucking train-wreck cannot come up with a unified documented way of specifying dependencies:So basically
- stackoverflow.com/questions/14399534/reference-requirements-txt-for-the-install-requires-kwarg-in-setuptools-setup-py
- stackoverflow.com/questions/26900328/install-dependencies-from-setup-py
- stackoverflow.com/questions/30797124/how-to-use-setup-py-to-install-dependencies-only/63743115
- stackoverflow.com/questions/6947988/when-to-use-pip-requirements-file-versus-install-requires-in-setup-py
requirements.txt
is thepackage-lock.json
. But how to generate it cleanly? You would need to create a virtualenv? pip search
was disabled in 2020: stackoverflow.com/questions/17373473/how-do-i-search-for-an-available-python-package-using-pip. WTF. If server load is a problem, just create a token system! It is hard to understand how such a popular language can't rais enough money to keep such simple server functionality running.
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:and from then on we can do
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
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.shThe best package ever is: pypi.org/project/china-dictatorship/ see also: cirosantilli.com/china-dictatorship/mirrors
python3 -m pip install --user virtualenv
virtualenv .venv
. .venv/bin/activate
pip install -r requirements.txt
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!
Basic class example.
Polymorphism example:
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
}
The people who work on this will go straight to heaven, no questions asked.
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.
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',
)
Output:With our understanding of the discrete Fourier transform we see clearly that:
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
- 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 thatrfft
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()
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.
Examples under python/sklearn
. .venv/bin/activate
pip install sklearn matplotlib seaborn
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:which apparently broke in 3.6: stackoverflow.com/questions/41343263/provide-classcell-example-for-python-3-6-metaclass and
RuntimeError: __class__ not set defining 'AbstractBaseUser' as <class 'django.contrib.auth.base_user.AbstractBaseUser'>. Was __classcell__ propagated to type.__new__?
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
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:
- github.com/shakacode/react_on_rails: webpack and server-side rendering
- github.com/reactjs/react-rails Official on the React side only. Demo app linked from package: github.com/BookOfGreg/react-rails-example-app and how it fails: github.com/BookOfGreg/react-rails-example-app/issues/30... The related projects section has some good links:
- shakacode/react_on_rails
- github.com/hyperstack-org/hyperstack transpiles Ruby to JavaScript + React. What could possibly go wrong? :-)
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
One of the first big interpreted programming languages to go a bit further than Bash' word replacement insanity.
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.