initial commit
This commit is contained in:
commit
f8869cb84e
22 changed files with 636 additions and 0 deletions
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# wiki
|
||||||
|
This is the main location of this wiki, until I get some proper hosting.
|
||||||
|
|
||||||
|
[Main page is here](articles/main_page.md).
|
||||||
|
|
||||||
|
Everything on this wiki is released to the public domain ([CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) license).
|
18
articles/bloat.md
Normal file
18
articles/bloat.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Bloat
|
||||||
|
Bloat is the collective name for unnecessary, redundant and most of time plainly useless "features".
|
||||||
|
|
||||||
|
This article is more about bloat in the software sense, but it could also be extended into hardware or other fields.
|
||||||
|
|
||||||
|
- Eye candy (animations, etc.)
|
||||||
|
- Useless colors (as opposed to meaningful colors carrying a semantic value)
|
||||||
|
- Animations (waste of CPU power)
|
||||||
|
- Monolithic programs (as opposed to the [Unix philosophy](/articles/unix_philosophy.html))
|
||||||
|
- [Frameworks](/articles/frameworks.html)
|
||||||
|
- [OOP (object oriented programming)](/articles/oop.html)
|
||||||
|
- [C++](/articles/cpp.html)
|
||||||
|
- [JavaScript](/articles/javascript.html)
|
||||||
|
- [Rust](/articles/rust.html)
|
||||||
|
- ...
|
||||||
|
|
||||||
|
## See also
|
||||||
|
- [Minimalism](/articles/minimalism.html)
|
18
articles/bsd.md
Normal file
18
articles/bsd.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# BSD
|
||||||
|
BSD, standing for **B**erkeley **S**oftware **D**istribution, is a family of libre (BSD license) Unix-like operating systems.
|
||||||
|
|
||||||
|
The BSDs are a direct descendant of the original Unix operating system, unlike [Linux](/articles/linux.html) which could
|
||||||
|
be considered as a "clean room" implementation of Unix.
|
||||||
|
|
||||||
|
Compared to Linux, BSDs have managed to keep the bloat in check and a reasonable codebase.
|
||||||
|
|
||||||
|
{ I've yet to try a BSD, so anything written here (as of now) is from an "outsider" perspective, forgive any erroneous statements ~tocariimaa }
|
||||||
|
|
||||||
|
## Main BSD distros
|
||||||
|
- [FreeBSD](https://www.freebsd.org/): the most popular, quite "Linuxy".
|
||||||
|
- [NetBSD](https://netbsd.org/): focus on portability.
|
||||||
|
- [OpenBSD](https://www.openbsd.org/): quite hysterical with "security features", but quite functional as its contributors actually daily drive it.
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
- [Linux](/articles/linux.html)
|
||||||
|
- [Unix](/articles/unix.html)
|
101
articles/c.md
Normal file
101
articles/c.md
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
# C
|
||||||
|
C is a procedural, compiled programming language created by Dennis Ritchie in 1973 for use in the Unix operating system.
|
||||||
|
Despite being an "old" language, it remains very relevant and it will stay that way for the next 100 years and more.
|
||||||
|
|
||||||
|
When compared with "modern" programming languages, C is a simple and minimal language, since it lacks "modern" features such as
|
||||||
|
generics, "memory safety", standard data structures and other high-level constructs, for that it is generally considered a "low-level"
|
||||||
|
language, even though strictly is a high-level language, since it abstracts over the platform dependent assembly language, effectively
|
||||||
|
turning C into a "portable assembly". C detractors are quick to point nonsense such as "C can't be a portable assembly because it forces
|
||||||
|
an abstracts model", ignoring the fact that C being so influential that any CPU architecture meant to be taken seriously has a C compiler
|
||||||
|
(therefore a CPU made to efficiently execute C, incidentally or not). Additionally, it is quite unforgiving and does not handhold the
|
||||||
|
programmer at all, in part this is good since it forces to actually think what one is doing, unlike in "modern" languages.
|
||||||
|
|
||||||
|
C was created in 1973 by Dennis Ritchie, then working in the [Unix](/articles/unix.html) operating system, which up to that point was
|
||||||
|
exclusively written in PDP-11 assembly (thus non portable) as a programming language suitable for systems programming.
|
||||||
|
|
||||||
|
The name "C" comes from the fact that C is a successor of the earlier B programming language (made by Ritchie and Ken Thompson)
|
||||||
|
which was in turn based in another programming language called BCPL.
|
||||||
|
|
||||||
|
Copies of Dennis Ritchie's original C compiler can be found here: <https://github.com/mortdeus/legacy-cc>
|
||||||
|
and here: <http://cm.bell-labs.co/who/dmr/primevalC.html> (also includes a brief history of the beginnings of C).
|
||||||
|
|
||||||
|
In 1978 the first edition of *The C Programming Language* was released, describing pre-ANSI C nowadays known as "K&R C".
|
||||||
|
This version had slight syntax differences, one of them being a different function parameter syntax and extensive use of
|
||||||
|
the explicit `int` type.
|
||||||
|
|
||||||
|
In 1979 C was defiled by Bjarne Stroustrup and turned into the abomination nowadays known as [C++](/articles/cpp.html).
|
||||||
|
|
||||||
|
In 1989 the first standardized version of C was released, C89 also known as *ANSI C*, a standard that remains relevant today, being
|
||||||
|
considered as a baseline for maximum portable C code.
|
||||||
|
|
||||||
|
The next major (and last relatively good version) version, C99 was released in the year 2000. Notably this standard is the first one
|
||||||
|
that formally allowed the declaration of a variable in any place of a block, although most compilers supported it already
|
||||||
|
as an extension. Also adds C++ style `//` comments, the `stdint.h` (fixed integer types) header and a boolean type.
|
||||||
|
|
||||||
|
Currently there are multiple independent compilers (non exhaustive list):
|
||||||
|
- GCC (GNU compiler collection)
|
||||||
|
- Clang: based in [LLVM](/articles/llvm.html).
|
||||||
|
- [TCC](/articles/tcc.html) (Tiny C Compiler): by Fabrice Bellard, a small compiler with fast compile times, implements modern C standards.
|
||||||
|
- [chibicc](https://github.com/rui314/chibicc): "toy" compiler by Rui Ueyama.
|
||||||
|
- [SubC](https://www.t3x.org/reload/index.html): educational compiler by Nils M Holm, public domain.
|
||||||
|
- [cproc](https://sr.ht/~mcf/cproc/): uses the [QBE](/articles/qbe.html) backend.
|
||||||
|
- [pcc](https://web.archive.org/web/20231212090621/http://pcc.ludd.ltu.se/)
|
||||||
|
(Portable C Compiler): classic portable compiler from the Unix days, successor of Ritchie's C compiler.
|
||||||
|
- [OpenWatcom](https://openwatcom.org/): a C compiler from the DOS days, proprietary.
|
||||||
|
- MSVC: proprietary compiler from [Micro$oft](/articles/microsoft.html), notable for being stuck in ANSI C for decades.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
### Hello world
|
||||||
|
```c
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
puts("Hello, world!");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Compiling
|
||||||
|
On Unix systems, `cc` is symlinked to the "default" C compiler, usually GCC.
|
||||||
|
```
|
||||||
|
cc -o hello hello.c
|
||||||
|
```
|
||||||
|
|
||||||
|
### Factorial
|
||||||
|
Technically C99, because of the `long long`.
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include <stdio.h> /* printf */
|
||||||
|
#include <stdlib.h> /* atoi */
|
||||||
|
|
||||||
|
long long /* a long long is 64 bits wide in Linux */
|
||||||
|
fact(int n)
|
||||||
|
{
|
||||||
|
long long res = 1;
|
||||||
|
while (n > 0) {
|
||||||
|
res *= n;
|
||||||
|
--n;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc < 2)
|
||||||
|
return 1;
|
||||||
|
/* in "real" code you want to use the strtol/strtoul functions */
|
||||||
|
int n = atoi(argv[1]);
|
||||||
|
printf("fact(%i) = %lli\n", n, fact(n));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
- *The C Programming Language* by Brian Kernighan and Dennis Ritchie, covers the ANSI C version.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
- [C tutorial](/articles/c_tutorial.html)
|
||||||
|
- [Pointer](/articles/pointer.html)
|
25
articles/cpp.md
Normal file
25
articles/cpp.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# C++
|
||||||
|
C++ was created in a in 1979 as a "C with Classes" ([Simula](/articles/simula.html) kind of OOP) by Bjarne Stroustrup. Formally
|
||||||
|
released in 1985, it has grown out of control since then.
|
||||||
|
|
||||||
|
A bloated programming language, one of its main features aside from [OOP](/articles/oop.html) is the STL (standard template library) implementing basic generic
|
||||||
|
data types, arrays, hash tables, etc. Famous for producing almost unintelligible error messages, due to extensive use of templates, which
|
||||||
|
add generic programming capabilities (but in a crippled and slow way) and also slow down compilation, since C++ still uses C headers, even
|
||||||
|
though C++20 introduced modules, almost no compiler at the time of writing this have implemented them properly (or even at all).
|
||||||
|
|
||||||
|
Up to a certain degree, C++ is backwards-compatible with C. A notable diversion from the C standard is that C++ does not allow implicit
|
||||||
|
casting from `void` pointers to a typed pointer, requiring an explicit cast instead.
|
||||||
|
|
||||||
|
Common file extensions for C++ code are .cpp (C with poop) and .cc (crippled C).
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
### Hello world
|
||||||
|
```cpp
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
std::cout << "Hello, world!\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
14
articles/drummyfish.md
Normal file
14
articles/drummyfish.md
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Drummyfish
|
||||||
|
Drummyfish (Miloslav Číž) is a Moravian programmer, anarchopacifist, free software/culture advocate and polymath (?).
|
||||||
|
|
||||||
|
## Notable Drummyfish works
|
||||||
|
- Anarch
|
||||||
|
- Licar
|
||||||
|
- [Less Retarded Wiki](https://www.tastyfish.cz/lrs/main.html)
|
||||||
|
- [comun](/articles/comun.html)
|
||||||
|
- raycastlib
|
||||||
|
- ...
|
||||||
|
|
||||||
|
## See also
|
||||||
|
- [His homepage](https://www.tastyfish.cz)
|
||||||
|
- [His article about himself in the LRS wiki.](https://www.tastyfish.cz/lrs/drummyfish.html)
|
24
articles/free_software.md
Normal file
24
articles/free_software.md
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# Free Software
|
||||||
|
Free Software is software that is licensed under a free (as in freedom) license, allowing anyone to access, modify, study and share
|
||||||
|
the source code, without restrictions or permission from their authors.
|
||||||
|
|
||||||
|
A common mistake is conflating the "free" as in no price, when it actually refers to free as in freedom. To avoid ambiguity, the term
|
||||||
|
*libre* is used instead, and *gratis* as in free beer (no price).
|
||||||
|
|
||||||
|
# Free Software Movement
|
||||||
|
The Free Software Movement was founded by Richard Matthew Stallman (RMS) in 1983, along with the GNU operating system project, which
|
||||||
|
initially consisted of free versions of common UNIX utilities, including a compiler, [GCC](/articles/gcc.html).
|
||||||
|
|
||||||
|
For software to be considered free software it must grant the following rights (unconditionally and irrevocable) also known as the
|
||||||
|
*Four essential freedoms*:
|
||||||
|
- The freedom to run the program as you wish, for any purpose (freedom 0)
|
||||||
|
- The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1).
|
||||||
|
- The freedom to redistribute copies so you can help others (freedom 2).
|
||||||
|
- The freedom to distribute copies of your modified versions to others (freedom 3).
|
||||||
|
|
||||||
|
The first freedom is absolute, no software calling itself "free" can restrict its use in any way, even if such use may go against the principles
|
||||||
|
of its authors (because it doesn't imply endorsement of such actions).
|
||||||
|
The freedom 1 implies having complete and unrestricted access to the source code.
|
||||||
|
|
||||||
|
Free software prevents the use of abusive practices common in the world of proprietary and [open $source](/articles/open_source.html)
|
||||||
|
software, by allowing anyone to study the source code and promoting ethics.
|
37
articles/golang.md
Normal file
37
articles/golang.md
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# Go
|
||||||
|
Go (also Golang) is a compiled programming language created by Rob Pike, Ken Thompson and others at [Google](/articles/google.html), released in 2009.
|
||||||
|
In contrast with other "modern" languages (such as Rust, etc.) Go is relatively simple, with the spec being about 130 pages.
|
||||||
|
|
||||||
|
Go generated executables are bloated (>1 MiB), since everything is statically linked. Using flags
|
||||||
|
like `-ldflags "-s -w"` can aid with the executable size by stripping debug symbols, but getting it under 1 MiB
|
||||||
|
is almost impossible with the default compiler. However, alternative implementations such as TinyGo compile to small
|
||||||
|
executables, mainly targeted for embedded use.
|
||||||
|
|
||||||
|
Furthermore, Go's runtime is quite heavy by having a [garbage collector](/articles/gc.html) and a weird stack layout for
|
||||||
|
supporting the builtin concurrency system, goroutines, which makes C interop slow and cumbersome compared to other
|
||||||
|
languages.
|
||||||
|
|
||||||
|
Go being a Google project, depends on it financially, also it has a [code of censorship](/articles/coc.html).
|
||||||
|
|
||||||
|
## Compilers
|
||||||
|
Due to Go having a formal spec (and being simple enough), Go has more than one compiler:
|
||||||
|
- The main compiler, written in Go itself. { no idea if it has a name ~tocariimaa }
|
||||||
|
- [gccgo](https://gcc.gnu.org/onlinedocs/gccgo/): GNU Compiler Collection's Go compiler
|
||||||
|
- [TinyGo](https://tinygo.org/): targeted at embedded systems.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
### Hello world
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello, world!")
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Compiling and running:
|
||||||
|
```
|
||||||
|
go run hello.go
|
||||||
|
```
|
22
articles/gopher.md
Normal file
22
articles/gopher.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Gopher
|
||||||
|
Gopher is an hypertext protocol, similar to [HTTP](/articles/http.html) but far more simpler and [KISS](/articles/kiss.html).
|
||||||
|
|
||||||
|
Pages using the Gopher protocol are known as "Gopherholes". As of writing this, there are about 200~300 active gopherholes.
|
||||||
|
|
||||||
|
## Protocol
|
||||||
|
TODO
|
||||||
|
|
||||||
|
```sh
|
||||||
|
printf '\n' | nc 'khzae.net' 70
|
||||||
|
```
|
||||||
|
|
||||||
|
## Accesing
|
||||||
|
"Modern" web browsers are so advanced that can't bother implementing such a trivial protocol, so if you're using a web browser you
|
||||||
|
can use a proxy like <https://gopher.floodgap.com/gopher/> that works over HTTP.
|
||||||
|
But for the true experience, you want a text based browser with native support for Gopher such as [Lynx](https://lynx.invisible-island.net/)
|
||||||
|
or [Bitreich's](/articles/bitreich.md) [sacc](gopher://bitreich.org/1/scm/sacc) browser.
|
||||||
|
|
||||||
|
## Notable Gopherholes
|
||||||
|
- [Bitreich](gopher://bitreich.org/1)
|
||||||
|
- [Veronica-2](gopher://gopher.floodgap.com/1/v2): a search engine for the gopherspace, indexing is limited to titles, however.
|
||||||
|
- <gopher://khzae.net>
|
61
articles/lua.md
Normal file
61
articles/lua.md
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
# Lua
|
||||||
|
[Lua](https://lua.org) is a libre, scripting programming language created in 1993 by the Brazilian programmer Roberto Ierusalimschy.
|
||||||
|
|
||||||
|
Lua is notable for its efficiency (faster than [Python](/articles/python.html)), minimal features, extensibility and a small,
|
||||||
|
non bloated implementation, making it a excellent choice for embedding into programs.
|
||||||
|
|
||||||
|
Lua has only has 5 datatypes: numbers, tables, functions, strings and `nil`. Tables are specially important in Lua,
|
||||||
|
implementing arrays and hash tables in a single type and enabling metaprogramming though the use of metamethods and metatables.
|
||||||
|
|
||||||
|
The main reference implementation is written in [ANSI C](/articles/c.html) (about 32000 LOC) and uses a register-based bytecode virtual machine for execution.
|
||||||
|
Another notable implementation is [LuaJIT](https://luajit.org), which speeds up execution speed by JIT compiling the Lua code.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
### Hello world
|
||||||
|
```lua
|
||||||
|
print('Hello, world!') -- Can also use double quotes
|
||||||
|
|
||||||
|
-- Lua allows you to skip the parentheses if a single argument is supplied:
|
||||||
|
print 'Hello, world!'
|
||||||
|
-- Raw string literal:
|
||||||
|
print [[Hello, world!]]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Factorial
|
||||||
|
#### Iterative
|
||||||
|
```lua
|
||||||
|
function fact(n)
|
||||||
|
local res = 1
|
||||||
|
for i = 1, n do
|
||||||
|
-- Lua has no operator-assignment operators
|
||||||
|
res = res * i
|
||||||
|
end
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Functions and variables are global by default, use the `local`
|
||||||
|
-- specifier to make them local.
|
||||||
|
local n = 16
|
||||||
|
-- `..` is the string concatenation operator
|
||||||
|
print('Factorial of ' .. n .. ':', fact(n))
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Tail recursive
|
||||||
|
```lua
|
||||||
|
function fact(n, acc)
|
||||||
|
-- Unsupplied arguments default to a `nil` value
|
||||||
|
-- With the `or` operator we can emulate default arguments:
|
||||||
|
acc = acc or 1
|
||||||
|
|
||||||
|
if n == 0 then
|
||||||
|
return acc
|
||||||
|
end
|
||||||
|
return fact(n - 1, acc * n)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
- [Documentation and Reference](https:/articles//lua.org/docs.html)
|
||||||
|
- [Lua Programming Gems](https://lua.org/gems)
|
||||||
|
- [Online Lua bytecode explorer](https://www.luac.nl)
|
||||||
|
- [lua-users](https://www.lua-users.org/) Unofficial Lua Users group, has a wiki about Lua with useful resources.
|
5
articles/main_page.md
Normal file
5
articles/main_page.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Welcome!
|
||||||
|
Welcome to this wiki (I'm yet to give it a name). Inspired by [drummyfish's](/articles/drummyfish.html)
|
||||||
|
[LRS wiki](https://www.tastyfish.cz/lrs/main.html). Mostly a dump of what I know.
|
||||||
|
|
||||||
|
Everything on this wiki is released to the public domain ([CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) license).
|
22
articles/ohms_law.md
Normal file
22
articles/ohms_law.md
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
# Ohm's Law
|
||||||
|
One of the fundamental laws of electronics and electricity, relating voltage (V [E, sometimes]), resistance (R) and intensity (I).
|
||||||
|
|
||||||
|
```
|
||||||
|
V = I * R
|
||||||
|
R = V / I
|
||||||
|
I = V / R
|
||||||
|
|
||||||
|
where
|
||||||
|
V = Voltage, R = Resistance (in ohms), I = Current (intensity, in amperes)
|
||||||
|
|
||||||
|
Graphical mnemonic:
|
||||||
|
_
|
||||||
|
/ \
|
||||||
|
/ V \
|
||||||
|
/--+--\
|
||||||
|
/ I | R \
|
||||||
|
*----+----*
|
||||||
|
```
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
- [Watt's Law](/articles/watts_law.html)
|
16
articles/open_source.md
Normal file
16
articles/open_source.md
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Open $ource
|
||||||
|
*Not to be confused with Free Software*
|
||||||
|
|
||||||
|
Open Source (also open $ource) is a neoliberal and capitalist perversion of the [Free Software Movement](/articles/free_software.html)
|
||||||
|
that abandons the main principles of Free Software: freedom and ethics, in exchange of maximum profit and exploit of programmers and users.
|
||||||
|
|
||||||
|
Megacorporations love "open source" since it gives them positive PR: "see our source code is OPEN!" but due to the lack of ethics, this
|
||||||
|
software is almost the same as proprietary software in terms of abuse to their users.
|
||||||
|
|
||||||
|
The Open Source movement promotes permissive licenses (and not the GPL) so they can profit from code written by unpaid programmers, for example
|
||||||
|
see the sad case with the BSDs operating systems, Apple and Sony has been making billions of dollars from the gratis effort of FreeBSD
|
||||||
|
developers, while giving NOTHING in exchange, NOT EVEN source code, NOT EVEN a USD penny in donations.
|
||||||
|
|
||||||
|
Average Open $ource program: bloated, has DRM, autoupdates, constant influx of "new" features and business-oriented features,
|
||||||
|
uses proprietary chat/forum software (Discord, Slack, etc.), promotes proprietary software as something that is "not that bad",
|
||||||
|
walled gardens, codes of censorship, etc.
|
75
articles/pascal.md
Normal file
75
articles/pascal.md
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
# Pascal
|
||||||
|
Pascal is a procedural programming language created by [Niklaus Wirth](/articles/niklaus_wirth.html) in 1970.
|
||||||
|
|
||||||
|
Pascal was a popular choice for microcomputers in the 70's and 80's, even more popular than C initially (C was still quite an UNIX-only language)
|
||||||
|
due to its simple design, which allowed fast simple single-pass compilers.
|
||||||
|
|
||||||
|
## Compilers
|
||||||
|
- [FPC](https://www.freepascal.org/) (Free Pascal Compiler): currently the most popular Pascal compiler with wide support
|
||||||
|
for different OSes and architectures, libre software.
|
||||||
|
- Turbo Pascal: old compiler for DOS systems, proprietary
|
||||||
|
- Delphi: proprietary, adds [OOP](/articles/oop.html) bloat
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
### Hello world
|
||||||
|
```pascal
|
||||||
|
program HelloWorld;
|
||||||
|
|
||||||
|
begin
|
||||||
|
WriteLn('Hello, World!');
|
||||||
|
end.
|
||||||
|
```
|
||||||
|
|
||||||
|
And then compile:
|
||||||
|
```
|
||||||
|
fpc hellopascal.pas
|
||||||
|
```
|
||||||
|
|
||||||
|
### Factorial
|
||||||
|
```pascal
|
||||||
|
{
|
||||||
|
Calculate a factorial on multiple languages: Pascal version
|
||||||
|
Compile with: fpc -O3 -S2 fact.pas
|
||||||
|
}
|
||||||
|
program Factorials;
|
||||||
|
|
||||||
|
{ qword = 64 bit unsigned type }
|
||||||
|
function FactorialRec(n, acc: qword): qword;
|
||||||
|
begin
|
||||||
|
if n <= 0 then
|
||||||
|
Result := acc
|
||||||
|
else
|
||||||
|
Result := FactorialRec(n - 1, acc * n);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function FactorialIter(n: qword): qword;
|
||||||
|
begin
|
||||||
|
Result := 1;
|
||||||
|
while n > 0 do
|
||||||
|
begin
|
||||||
|
{ The usage of C-like arithmetic assignment operators is possible with -Sc: }
|
||||||
|
{ Result *= n; }
|
||||||
|
Result := Result * n;
|
||||||
|
Dec(n); { equivalent to C's `--` operator }
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
n: qword;
|
||||||
|
values: array of qword = (14, 5, 2, 10, 1, 18, 4);
|
||||||
|
begin
|
||||||
|
Assert((FactorialIter(0) = 1) and (FactorialRec(0, 1) = 1));
|
||||||
|
for n in values do
|
||||||
|
begin
|
||||||
|
WriteLn('Factorial of ', n, ' = ', FactorialRec(n, 1));
|
||||||
|
end;
|
||||||
|
end.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Resources
|
||||||
|
- [Free Pascal Wiki](https://wiki.freepascal.org/Main_Page)
|
||||||
|
- *Why Pascal is Not My Favorite Programming Language* by Brian Kernighan, mostly of historic interest as almost all of the
|
||||||
|
flaws described in the article has been fixed by modern Pascal compilers. <https://www.lysator.liu.se/c/bwk-on-pascal.html>
|
||||||
|
|
||||||
|
## See also
|
||||||
|
- [Oberon](/articles/oberon.html)
|
60
articles/pointer.md
Normal file
60
articles/pointer.md
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
# Pointer
|
||||||
|
In a very simple sense, a pointer represents the memory address of a certain block of data (also can be a single byte) in memory.
|
||||||
|
|
||||||
|
```
|
||||||
|
Here, the pointer `str` has the value of 0xdecade, therefore pointing to the memory at
|
||||||
|
that address (here a C string):
|
||||||
|
|
||||||
|
address | data
|
||||||
|
-----------------
|
||||||
|
uint16_t *n ---> 0xdecadb | 0x27
|
||||||
|
0xdecadc | 0x7f
|
||||||
|
0xdecadd | 0xff
|
||||||
|
char *str -----> 0xdecade | 'H'
|
||||||
|
0xdecadf | 'e'
|
||||||
|
0xdecae0 | 'l'
|
||||||
|
0xdecae1 | 'l'
|
||||||
|
0xdecae2 | 'o'
|
||||||
|
char *end -----> 0xdecae3 | 0x00
|
||||||
|
0xdecae4 | 0x27
|
||||||
|
|
||||||
|
char c = *str; /* dereferencing, reading the first element */
|
||||||
|
char c4 = *(str + 4); /* with pointer arithmetic we can access the 4th element, 'o' */
|
||||||
|
char c4 = str[4]; /* array indexing is syntax sugar for *(arr + index) in C */
|
||||||
|
|
||||||
|
*str = 'h'; /* dereferencing, here we're modifying the first element */
|
||||||
|
str[0] = 'h'; /* equivalent in C */
|
||||||
|
```
|
||||||
|
|
||||||
|
In C (and almost all languages that have pointers), a pointer is an integer type, big enough to hold the entire valid
|
||||||
|
address space of the host system.
|
||||||
|
|
||||||
|
```c
|
||||||
|
/* This is a common pattern in embedded programming, usually the address being some
|
||||||
|
kind of MMIO I/O address. */
|
||||||
|
char *str = (char *)0xdecade;
|
||||||
|
```
|
||||||
|
|
||||||
|
If you have an start and end pointer (this pointing past the end of the data) you can iterate over
|
||||||
|
strings without an index counter:
|
||||||
|
```c
|
||||||
|
char *s = "a looooooooooooong string"
|
||||||
|
char *send = s + 25;
|
||||||
|
int len = send - s; /* and the length, if you need it */
|
||||||
|
|
||||||
|
while (s < send) {
|
||||||
|
putchar(*s);
|
||||||
|
++s; /* increment memory address */
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Null pointer
|
||||||
|
A null pointer is a special case, which points to an invalid memory address (nowadays almost 0).
|
||||||
|
Usually a null pointer is meaningful only in hosted environments, in that case reading or writing from
|
||||||
|
a null pointer will case a segmentation fault error, in which the OS will immediately kill the offending
|
||||||
|
process. On embedded systems (without a MMU), a null pointer may represent a valid memory address.
|
||||||
|
|
||||||
|
## Function pointers
|
||||||
|
Function pointers are more special. On most systems, just like a regular pointer, a function pointer is simply
|
||||||
|
a memory address to the start of the function code. Formally in C, dereferencing a function pointer is undefined
|
||||||
|
behavior.
|
25
articles/programming_language.md
Normal file
25
articles/programming_language.md
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Programming language
|
||||||
|
A programming language is a computer language in which programs can be written, they can either be compiled into native machine code or interpreted.
|
||||||
|
Different programming languages offers distinct amount of abstraction over the machine (low-level and high-level),
|
||||||
|
being the so called "scripting languages" the ones with the higher level of abstraction, for example.
|
||||||
|
|
||||||
|
In some ways, assembly can be considered a (low-level) programming language, since it abstracts the numerical opcodes of the machine with mnemonics
|
||||||
|
(such as `mov`, `call`, `mul`, etc.) and most offer macro capabilities.
|
||||||
|
|
||||||
|
## List of acceptable and non-acceptable (harmful) languages
|
||||||
|
- Assembly: yes, but non portable.
|
||||||
|
- [C](/articles/c.html): yes, the first and natural choice for writing programs. The Unix language.
|
||||||
|
- [Lua](/articles/lua.html): yes, good for embedding and quick scripts.
|
||||||
|
- [Lisp](/articles/lisp.html): yes, flexible and relatively fast, prefer Scheme over the more bloated Common Lisp (still better than C++ however).
|
||||||
|
- Forth: yes, niche, but it is a nice exercise on minimalism.
|
||||||
|
- Pascal (no OOP): yes, old school and quite verbose, but small and fast compared to, say C++ or Rust; comparable to C in terms
|
||||||
|
of features.
|
||||||
|
- (POSIX) [Shell Script](/articles/shell_script.html): yes, has its quirks.
|
||||||
|
- Perl: acceptable, could be used as a replacement for more complex shell scripts, since it is commonly installed in most
|
||||||
|
modern unixes.
|
||||||
|
- Go: acceptable but beware of the big executable sizes.
|
||||||
|
- PHP (no OOP): acceptable, if you need interactive web pages but stay away from [frameworks](/articles/frameworks.html).
|
||||||
|
- Python: Slow and bloated, avoid
|
||||||
|
- C++: No.
|
||||||
|
- JavaScript: No.
|
||||||
|
- Rust: NO
|
3
articles/qbe.md
Normal file
3
articles/qbe.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# QBE
|
||||||
|
[QBE](https://c9x.me/compile/) is an optimizing compiler backend with a simple implementation in C, compared to
|
||||||
|
huge and slower backends such as [LLVM](/articles/llvm.md). Supports codegen for the x86, ARM and RISC-V architectures.
|
30
articles/rust.md
Normal file
30
articles/rust.md
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
# Rust
|
||||||
|
Rust is a [bloated](/articles/bloat.html) and [open $ource](/articles/open_source.html) programming language. It was created out of frustration that
|
||||||
|
[C++](/articles/cpp.html) wasn't bloated and shitty enough.
|
||||||
|
|
||||||
|
The main "feature" of Rust is the so called borrow checker which will reject any code that considers as "unsafe", even rejecting completely
|
||||||
|
"safe" and valid code that Rust users have to resort to workarounds such as heap allocating everything and wrapping objects under a matroska
|
||||||
|
of `Box`, `Rc` and `dyn` objects. In the end, any non trivial Rust codebase will have a half-baked and buggy garbage collector (leaking).
|
||||||
|
|
||||||
|
Rust is noteworthy for bringing the web development "culture" into systems programming. That is, a ridiculous amount of dependencies
|
||||||
|
(even for extremely simple things to implement), constant influx of new "features" (including breaking changes) and an extremely toxic SJW community.
|
||||||
|
|
||||||
|
Currently the main use of Rust is doing rewrites that no one asked for of classic Unix tools (such as `ls`, `cat`, `find` or `grep`), but adding
|
||||||
|
piles of dependencies, colors or other useless eye candy bloat, see: <https://github.com/sharkdp/bat>.
|
||||||
|
|
||||||
|
It has to be noted that the "main" and "recommended" way of infecting your computer with Rust is by executing a random shell script from the internet LMAO.
|
||||||
|
|
||||||
|
Due to its extreme complexity and lack of formal specification, theres only the official compiler. Other independent attempts of implementing a Rust compiler
|
||||||
|
(such as gccrs) can't even compile a hello world yet.
|
||||||
|
|
||||||
|
## The #RustDependencyChallenge
|
||||||
|
Go to your average non trivial rust project `Cargo.lock` file and when you find one that is less than 100 lines long you win.
|
||||||
|
|
||||||
|
## Less harmful alternatives
|
||||||
|
- [C](/articles/c.html)
|
||||||
|
- [Lisp](/articles/lisp.html)
|
||||||
|
- Even [Go](/articles/golang.html) is preferable.
|
||||||
|
- Learning how to use [pointers](/articles/pointer.html) properly.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
- [drummyfish's take on Rust](https://www.tastyfish.cz/lrs/rust.html)
|
31
articles/systemd.md
Normal file
31
articles/systemd.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# SystemD
|
||||||
|
*This article is part of the bloat and vomit inducing series*
|
||||||
|
|
||||||
|
SystemD (also known as SoystemD) is a bloated and predatory init system for [Linux](/articles/linux.html) made by Micro$oft employee Lennart Poettering
|
||||||
|
(then working for RedHat) as a mean of bringing the *Embrace, Extend and Extinguish* and update culture movements into Linux.
|
||||||
|
|
||||||
|
A notable backdoor (thwarted) attempt in 2024 on liblzma was facilitated by a completely redundant SystemD dependency added by Debian maintainers to OpenSSH.
|
||||||
|
Had the backdoor attempt succeeded, it would have given full root access to millions of Linux servers.
|
||||||
|
|
||||||
|
## Distros without soystemd
|
||||||
|
- Artix Linux (basically Arch Linux without Systemd)
|
||||||
|
- Gentoo
|
||||||
|
- Devuan (fork of Debian)
|
||||||
|
- Slackware
|
||||||
|
- Linux From Scratch
|
||||||
|
- OpenWRT
|
||||||
|
- Guix
|
||||||
|
- ...
|
||||||
|
|
||||||
|
## See also
|
||||||
|
- [suckless view on systemd](https://suckless.org/sucks/systemd/)
|
||||||
|
- [Without Systemd](https://without-systemd.org/wiki/index_php/Main_Page/)
|
||||||
|
- [Laurent Bercot's (s6 creator) take on Systemd](https:/articles//skarnet.org/software/systemd.html)
|
||||||
|
|
||||||
|
## Alternatives
|
||||||
|
- s6
|
||||||
|
- runit
|
||||||
|
- OpenRC (from Gentoo)
|
||||||
|
- SysVinit
|
||||||
|
- BSD-style rc init systems
|
||||||
|
- [suckless sinit](https://core.suckless.org/sinit/)
|
12
articles/tcc.md
Normal file
12
articles/tcc.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# TCC (Tiny C Compiler)
|
||||||
|
[TCC](https://www.bellard.org/tcc/) is a [C](/articles/c.html) [compiler](/compiler.html) written by Fabrice Bellard,
|
||||||
|
notable for having a simple implementation (< 40k LOC) and very fast compile times compared to more heavy duty
|
||||||
|
compilers such as GCC or Clang. Originally it only supported the x86 (and x86-64) architecture,
|
||||||
|
but ARM and RISC-V codegen have been implemented.
|
||||||
|
|
||||||
|
TCC is self-contained since it also implements its own linker, assembler and preprocessor.
|
||||||
|
|
||||||
|
Due to its simple implementation, TCC does not implement optimizations other than constant folding,
|
||||||
|
however it stays relevant as a compiler for fast debug builds and for bootstrapping purposes.
|
||||||
|
|
||||||
|
Currently development happens at <https://repo.or.cz/tinycc.git>.
|
4
articles/tocariimaa.md
Normal file
4
articles/tocariimaa.md
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# tocariimaa
|
||||||
|
{ my main email is tocariimaa AT firemail DOT cc ~tocariimaa }
|
||||||
|
|
||||||
|
tocariimaa is a programmer, hermit, and the author of this wiki.
|
27
articles/transistor.md
Normal file
27
articles/transistor.md
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# Transistor
|
||||||
|
Semiconductor electronic component, used for switching and current amplification. Also considered one of the most important inventions, since
|
||||||
|
it is superior to its predecesor, i.e. vacuum tubes, which are bulky, inefficient (a lot of heat dissipation), have high current consumption
|
||||||
|
and high unreliability for fast switching applications (such as digital circuits).
|
||||||
|
|
||||||
|
The invention of the transistor (at Bell Labs) made faster, cheaper, more reliable and smaller computers possible, including the invention
|
||||||
|
of integrated circuits.
|
||||||
|
|
||||||
|
## Bipolar transistors (BJT)
|
||||||
|
BJTs are current controlled.
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
```
|
||||||
|
| C | C
|
||||||
|
+-----+ +-----+
|
||||||
|
| N | | P |
|
||||||
|
B +-----+ B +-----+
|
||||||
|
----| P | ----| N |
|
||||||
|
+-----+ +-----+
|
||||||
|
| N | | P |
|
||||||
|
+-----+ +-----+
|
||||||
|
| E | E
|
||||||
|
```
|
||||||
|
|
||||||
|
## Field effect transistors (FET, MOSFET)
|
||||||
|
TODO
|
Loading…
Add table
Reference in a new issue