This commit is contained in:
Miloslav Ciz 2024-02-13 21:57:06 +01:00
parent a5acdddb82
commit 57c8d33e04
15 changed files with 1717 additions and 1668 deletions

View file

@ -4,7 +4,7 @@ ASCII ([American](usa.md) standard code for information interchange) is a relati
The ASCII standard assigns a 7 [bit](bit.md) code to each basic text character which gives it a room for 128 characters -- these include lowercase and uppercase [English](english.md) alphabet, decimal digits, other symbols such as a question mark, comma or brackets, plus a few special control characters that represent instructions such as carriage return which are however often obsolete nowadays. Due to most computers working with 8 bit bytes, most platforms store ASCII text with 1 byte per character; the extra bit creates a room for **extending** ASCII by another 128 characters (or creating a variable width encoding such as [UTF-8](utf8.md)). These extensions include unofficial ones such as VISCII (ASCII with additional Vietnamese characters) and more official ones, most notably [ISO 8859](iso_8859.md): a group of standards by [ISO](iso.md) for various languages, e.g. ISO 88592-1 for western European languages, ISO 8859-5 for Cyrillic languages etc.
The ordering of characters has been kind of cleverly designed to make working with the encoding easier, for example digits start with 011 and the rest of the bits correspond to the digit itself (0000 is 0, 0001 is 1 etc.). Corresponding upper and lower case letters only differ in the 6th bit, so you can easily convert between upper and lower case by negating it as `letter ^ 0x20`. { I think there is a few missed opportunities though, e.g. in not putting digits right before letters. That way it would be very easy to print hexadecimal (and all bases up to a lot) simply as `putchar('0' + x)`. ~drummyfish }
The ordering of characters has been kind of cleverly designed to make working with the encoding easier, for example digits start with 011 and the rest of the bits correspond to the digit itself (0000 is 0, 0001 is 1 etc.). Corresponding upper and lower case letters only differ in the 6th bit, so you can easily convert between upper and lower case by negating it as `letter ^ 0x20`. { I think there is a few missed opportunities though, e.g. in not putting digits right before letters. That way it would be very easy to print hexadecimal (and all bases up to a lot) simply as `putchar('0' + x)`. UPDATE: seen someone ask this on some stack exchange, the answer said ASCII preferred easy masking or something, seems like there was some reason. ~drummyfish }
ASCII was approved as an [ANSI](ansi.md) standard in 1963 and since then underwent many revisions every few years. The current one is summed up by the following table:

View file

@ -36,6 +36,8 @@ Instructions are typically written as three-letter abbreviations and follow some
- **CMP** (compare): compare two numbers and set relevant flags (typically for a subsequent conditional jump).
- ...
[Fun](fun.md) note: `HCF` -- *halt and catch fire* -- is a humorous nickname for instructions that just stop the CPU and wait for restart.
## How To
On [Unices](unix.md) the [objdump](objdump.md) utility from GNU binutils can be used to **disassemble** compiled programs, i.e view the instructions of the program in assembly (other tools like ndisasm can also be used). Use it e.g. as:

4
c.md
View file

@ -18,6 +18,8 @@ Mainstream consensus acknowledges that C is among the best languages for writing
**Is C low or high level?** This depends on the context. Firstly back in the day when most computers were programmed in [assembly](assembly.md), C was seen as high level, simply because it offered the highest level of abstraction at the time, while nowadays with languages like [Python](python.md) and [JavaScript](js.md) around people see C as very low level by comparison -- so it really depends on if you talk about C in context of "old" or "modern" programming and which languages you compare it to. Secondly it also depends on HOW you program in C -- you may choose to imitate assembly programming in C a lot, avoid using libraries, touch hardware directly, avoid using complex features and creating your own abstractions -- here you are really doing low level programming. On the other hand you can emulate the "modern" high-level style programming in C too, you can even mimic [OOP](oop.md) and make it kind of "C++ with different syntax", you may use libraries that allow you to easily work with strings, heavy macros that pimp the language to some spectacular abomination, you may write your own garbage collector etc. -- here you are basically doing high level programming in C.
**[Fun](fun.md)**: `main[-1u]={1};` is a C [compiler bomb](compiler_bomb.md) :) it's a short program that usually makes the compiler produce a huge binary.
## History and Context
C was developed in 1972 at [Bell Labs](bell_labs.md) alongside the [Unix](unix.md) operating system by [Dennis Ritchie](dennis_ritchie.md) and [Brian Kerninghan](brian_kerninghan.md), as a successor to the [B](b.md) language ([portable](portability.md) language with [recursion](recursion.md)) written by Denis Ritchie and [Ken Thompson](ken_thompson.md), which was in turn inspired by the the [ALGOL](algol.md) language (code blocks, lexical [scope](scope.md), ...).
@ -75,7 +77,7 @@ Nothing is [perfect](perfect.md), not even C; it was one of the first relatively
- **Some things could be made simpler**, e.g. using [reverse polish](reverse_polish.md) notation for expressions, rather than expressions with brackets and operator precedence, would make implementations much simpler, increasing sucklessness (of course readability is an argument).
- **Some things could be dropped entirely** ([enums](enum.md), [bitfields](bitfield.md), possibly also unions etc.), they can be done and imitated in other ways without much hassle.
- **The preprocessor isn't exactly elegant**, it has completely different syntax and rules from the main language, not very suckless -- ideally preprocessor uses the same language as the base language.
- **The syntax is sucky sometimes**, e.g. case with variable inside it HAS TO be enclosed in curly brackets but other ones don't, data type names may consist of multiple tokens (`long long int` etc.), multiplication uses the same symbol as pointer dereference (`*`), also it's pretty weird that the condition after `if` has to be in brackets etc., it could be designed better. Keywords also might be better being single chars, like `?` instead of `if` etc. (see [comun](comun.md)). A shorter, natural-language-neutral source code would be probably better. Both line and block comments could be implemented with a single character (e.g. `#` for line comment, ending with a newline or another `#`, `##` for block comment ending with another `##`?).
- **The syntax is sucky sometimes**, e.g. case with variable inside it HAS TO be enclosed in curly brackets but other ones don't, data type names may consist of multiple tokens (`long long int` etc.), multiplication uses the same symbol as pointer dereference (`*`), many preprocessor commands need to be on separate lines (makes some one liners impossible), also it's pretty weird that the condition after `if` has to be in brackets etc., it could all be designed better. Keywords also might be better being single chars, like `?` instead of `if` etc. (see [comun](comun.md)). A shorter, natural-language-neutral source code would be probably better. Both line and block comments could be implemented with a single character (e.g. `#` for line comment, ending with a newline or another `#`, `##` for block comment ending with another `##`?).
- **Some undefined/unspecified behavior would maybe be better defined/specified** -- undefined behavior isn't bad in general, it is what allows C to be so fast and efficient in the first place, but some of it has shown to be rather cumbersome; for example the unspecified representation of integers, their binary size and behavior of floats leads to a lot of trouble (unknown upper bounds, sizes, undefined behavior of many operators etc.) while practically all computers have settled on using 8 bit bytes, [two's complement](twos_complement.md) and IEEE754 for [floats](float.md) -- this could easily be made a mandatory assumption which would simplify great many things without doing basically any harm. New versions of C actually already settle on two's complement. This doesn't mean C should be shaped to reflect the degenerate "[modern](modern.md)" trends in programming though!
- Some basic things that are part of libraries or extensions, like fixed width types and binary literals and possibly very basic I/O (putchar/readchar), could be part of the language itself rather than provided by libraries.
- All that stuff with *.c* and *.h* files is unnecessary, there should just be one file type -- this isn't part of the language per se, but it's part of its culture.

10
compiler_bomb.md Normal file
View file

@ -0,0 +1,10 @@
# Compiler Bomb
TODO
{ Found here: https://codegolf.stackexchange.com/questions/69189/build-a-compiler-bomb. ~drummyfish }
Compiler bombs in various languages:
- [C](c.md): `main[-1u]={1};`, creates 16 GB executable, works by defining a huge array an initializes its first element so the whole array will be explicitly stored in the executable.
- ...

View file

@ -4,6 +4,8 @@ So called esoteric programming languages (esolangs) are highly experimental and
There is a great [wiki](wiki.md) for esolangs, the Esolang Wiki (https://esolangs.org). If you want to behold esolangs in all their beauty, see https://esolangs.org/wiki/Hello_world_program_in_esoteric_languages_(nonalphabetic_and_A-M). The Wiki is published under [CC0](cc0.md)!
Many esolangers seem to be [code golfers](golf.md), i.e. people who do various programming challenges while aiming for the shortest code which often requires a wise choice of language... or perhaps making a completely new language just for the job :) Codegolf stack exchange is therefore one place to see many esolangs in action.
Some notable ideas employed by esolangs are:
- Using images instead of text as [source code](source_code.md) (e.g. *Piet*).

View file

@ -51,6 +51,7 @@ A great many commonly used tricks in programming could be regarded as hacks even
- **[bit hacks](bit_hack.md)**: Clever manipulations of [bits](bit.md) -- for example it is possible to swap two variable without a temporary variables by using the [xor](xor.md) function. Another simplest example is implementing division by 2 as binary shift by 1 (this hack is used in real life by people for quickly dividing by 10, we just remove the last digit).
- **[copyleft](copyleft.md)**: A legal hack by [Richard Stallman](rms.md), connected to [free software](free_software.md), working on the basis of the following idea: "If [copyright](copyright.md) lets me put any conditions on my work, I may impose a condition on my work that says that any modified version must not impose any restrictive conditions".
- In minimalist [C](c.md) programming mainly two standards of the language are used: C89 and C99. To distinguish between them in source code one can e.g. exploit the fact that C99 introduced line comments (starting with `//`) and make such code that C99 sees part of it commented out while C89 doesn't. For example the following two lines: `int isC89 = 1 //**/ 2`, `; isC89 = !isC89;`.
- **[fast inverse square root](fast_inverse_sqrt.md)**: Famous hack that was used in the [game](game.md) Quake, it [approxmates](approximation.md) an inverse of [square root](sqrt.md) of a [floating point](float.md) number by treating it as an integer and bashing it with a [magic constant](magic_constant.md), which is about four times faster than computing the value with the obvious floating point division.
- **memory [rape](rape.md) in [C](c.md)**: E.g. instead of doing proper memory allocation with potentially inefficient and bloated `malloc` one may try to do a custom memory allocation without any libraries by abusing allocation on stack -- allocate a variable size array in main, set some global pointer to it and then manage this chunk of memory with your own allocation functions.
- **actually portable executable** (https://justine.lol/ape.html): Justine Tunney found a way to create an executable format that passes as a valid NATIVE executable on all major systems including [GNU](gnu.md)/[Linux](linux.md), [Windows](windows.md) and [Mac](mac.md), i.e. it is possible to compile a native program (e.g. with [C](c.md)) and then have it natively run on any major OS.
@ -60,6 +61,7 @@ A great many commonly used tricks in programming could be regarded as hacks even
- **[quine](quine.md)**: A cleverly constructed self-replicating program in [programming language](programming_language.md) that prints its own source code -- this is a common exercise of language hackers.
- **MetaGolfScript [esoteric languages](esolang.md)**: rather than being a nicely designed [code golfing](code_golf.md) language MetaGolfScript invents infinitely many languages, each of which solves one problem with a zero-length program, making it possible to win any golfing contest that allows arbitrary choice of language just by choosing the correct MetaGolfScript language.
- **Appending "in Minecraft" to avoid legal responsibility**: some people try to avoid legal responsibility for threats by talking about the situation as if it was harmlessly happening in a video game such as Minecraft, for example "Bitch I'm going to come to your house and murder you in sleep, in Minecraft." Though this is a nice hack and should work, the dystopian governments can do whatever they want and still arrest you for this -- this happened e.g. in New Jersey when one guy threatened to kill a sheriff like this.
- **[polyglot](polyglot.md) programs**: another fun activity by programming language enthusiasts; a polyglot is source code that's a valid in more than one programming language.
- [Richard Stallman](rms.md) called some musical compositions hacks, specifically 4'33 (just silence) and Ma Fin Est Mon Commencement ([palindromic](palindrome.md) music).
- TODO: moar

View file

@ -29,4 +29,8 @@ And let us also mention a few winning entries:
- [X11](x11.md) Minecraft-like game
- [web browser](web_browser.md)
- self-replicating programs
- ...
- ...
## See Also
- C [compiler bombs](compiler_bomb.md)

View file

@ -14,13 +14,20 @@ In the past JavaScript was only a **[client](client.md) side** scripting languag
TODO: some more shit
TODO
## JavaScript Fun
Here let be recorded funny code in this glorious language.
**This kills the JavaScript**:
```
"11" + 1 // "111"
"11" - 1 // 10
clear(this);
```
That's right, the above code just make JavaScript commit [suicide](suicide.md) by deleting its whole global thing.
{ Found here: https://codegolf.stackexchange.com/questions/61115/make-your-language-unusable. ~drummyfish }
Here is how to **make your page work only with JavaScript turned off**:
```
@ -68,4 +75,11 @@ function go()
</body>
</html>
```
TODO: some JS nonsense like below
```
"11" + 1 // "111"
"11" - 1 // 10
```

View file

@ -92,7 +92,8 @@ Are you a noob but see our ideas as appealing and would like to join us? Say no
- That [LGBT](lgbt.md), [feminism](feminism.md) and similar movements are not truly leftist but rather [pseudoleftist](pseudoleft.md) and therefore [fascist](fascism.md)?
- That there is no simple formula for calculating the perimeter of an [ellipse](ellipse.md)?
- In 3rd world [pigeons carrying SD cards](ip_over_pigeon.md) are still much faster and reliable way of transferring data than [internet service providers](isp.md)? This also avoids [censorship](censorship.md).
- That throughout [history](history.md) one of the most common patterns is appearance of new lucrative technology or trend which is labeled safe by [science](soyence.md), then officially recommended, promoted, adopted by the industry and heavily utilized for many years to decades before being found harmful, which is almost always greatly delayed by the industry trying to hide this fact? This was the case e.g. with [asbestos](asbestos.md), [freons](freon.md) (responsible for ozone layer depletion), [x rays](x_ray.md), [plastics](plastic.md), smoking and great many prescription drugs among which used to be even cocaine. Yet when you question safety of a new lucrative invention, such as [5G](5g.md), antidepressants or some quickly developed [vaccines](vax.md), you are labeled insane.
- That [compiler bomb](compiler_bomb.md) is a very short source code that makes the language compiler produce gigantic executable?
- That throughout [history](history.md) one of the most common patterns is appearance of new lucrative technology or trend which is labeled safe by [science](soyence.md), then officially recommended, promoted, adopted by the industry and heavily utilized for many years to decades before being found harmful, which is almost always greatly delayed by the industry trying to hide this fact? This was the case e.g. with [asbestos](asbestos.md), [freons](freon.md) (responsible for ozone layer depletion), [x rays](x_ray.md), radioactive paint (see *radium girls*), [plastics](plastic.md), smoking and great many prescription drugs among which used to be even cocaine. Yet when you question safety of a new lucrative invention, such as [5G](5g.md), antidepressants or some quickly developed [vaccines](vax.md), you are labeled insane.
## Topics

View file

@ -129,4 +129,8 @@ int main(void)
return 0;
}
```
```
## See Also
- [Buddhabrot](buddhabrot.md)

View file

@ -73,7 +73,7 @@ Now that we have a specification, i.e. the idea, someone has to realize it, i.e.
A new language comes to existence just as other things do -- when there is a reason for it. I.e. if someone feels there is no good language for whatever he's doing or if someone has a brilliant idea and want to write a PhD thesis or if someone smokes too much weed or if a corporation wants to control some software platform etc., a new language may be made. This often happen gradually (again, like with many things), i.e. someone just starts modifying an already existing language -- at first he just makes a few macros, then he starts making a more complex preprocessor, then he sees it's starting to become a new language so he gives it a name and makes it a new language -- such language may at first just be transpiled to another language (often [C](c.md)) and over time it gets its own full compiler. At first a new language is written in some other language, however most languages aim for **[self hosted](self_hosting.md) implementation**, i.e. being written in itself. This is natural and has many advantages -- a language written in itself proves its maturity, it becomes independent and as it itself improves, so does its own compiler. Self hosting a language is one of the greatest milestones in its life -- after this the original implementation in the other language often gets deletes as it would just be a burden to keep [maintaining](maintenance.md) it.
**So can a language be inherently fast, [bloated](bloat.md) etc.?** When we say a language is fast, bloated, memory efficient and so on, we often refer to its implementations because, as mentioned, a language is just an idea which can be implemented in many ways with different priorities and tradeoffs, so just keep in mind that talking about languages like this usually refers to the implementations. But on the other hand yes, a language CAN itself be seen as inherently having a similar property because it's simply such that its implementations more or less have to have this property. A very complicated language just cannot be implemented in a simple, non-bloated way, an extremely high level and flexible language cannot be implemented to be among the fastest -- so referring to language implementations we also a little bit refer to the language itself as an implementation reflects the abstract language's properties. **How to tell if language is bloated?** One can get an idea from several things, e.g. list of features, [paradigm](paradigm.md), size of its implementations, size of the specification, year of creation (newer mostly means more bloat) and so on. However be careful, many of these are just clues, for example small specification may just mean it's vague. Even a small self hosted implementation doesn't have to mean the language is small -- imagine e.g. a language that just does what you write in plain English; such language will have just one line self hosted implementation: "Implement yourself." But to actually [bootstrap](boot.md) the language will be immensely difficult and will require a lot of bloat.
**So can a language be inherently fast, [bloated](bloat.md) etc.?** When we say a language is fast, bloated, memory efficient and so on, we often refer to its implementations because, as mentioned, a language is just an idea which can be implemented in many ways with different priorities and tradeoffs, so just keep in mind that talking about languages like this usually refers to the implementations. But on the other hand yes, a language CAN itself be seen as inherently having a similar property because it's simply such that its implementations more or less have to have this property. A very complicated language just cannot be implemented in a simple, non-bloated way, an extremely high level and flexible language cannot be implemented to be among the fastest -- so referring to language implementations we also a little bit refer to the language itself as an implementation reflects the abstract language's properties. **How to tell if language is bloated?** One can get an idea from several things, e.g. list of features, [paradigm](paradigm.md), size of its implementations, number of implementations, size of the specification, year of creation (newer mostly means more bloat) and so on. However be careful, many of these are just clues, for example small specification may just mean it's vague. Even a small self hosted implementation doesn't have to mean the language is small -- imagine e.g. a language that just does what you write in plain English; such language will have just one line self hosted implementation: "Implement yourself." But to actually [bootstrap](boot.md) the language will be immensely difficult and will require a lot of bloat.
**Can you use multiple programming languages for one project?** Yes, though it may be a burden, so don't do it just because you can. Combining languages is possible in many ways, e.g. by embedding a [scripting](scripting.md) language into a compiled language, linking together object files produces by different languages, creating different programs that communicate over network etc.

View file

@ -1,9 +1,11 @@
# Quine
Quine is a nonempty [program](program.md) which prints its own source code. It takes no input, just prints out the [source code](source_code.md) when run (without [cheating](cheating.md) such as reading the source code file). Quine is basically a [self-replicating](self_replication.md) program, just as [in real world](irl.md) we may construct robots capable of creating copies of themselves (afterall we humans are such robots). The name *quine* refers to the philosopher Willard Quine and his paradox that shows a structure similar to self-replicating programs. Quine is one of the standard/[fun](fun.md)/[interesting](interesting.md) programs such as [hello world](hello_world.md), [99 bottles of beer](99_bottles.md) or [fizzbuzz](fizzbuzz.md).
Quine is a nonempty [program](program.md) which prints its own source code. It takes no input, just prints out the [source code](source_code.md) when run (without [cheating](cheating.md) such as reading the source code file). Quine is basically a [self-replicating](self_replication.md) program, just as [in real world](irl.md) we may construct robots capable of creating copies of themselves (afterall we humans are such robots). The name *quine* refers to the philosopher Willard Quine and his paradox that shows a structure similar to self-replicating programs. Quine is one of the standard/[fun](fun.md)/[interesting](interesting.md) programs such as [hello world](hello_world.md), [compiler bomb](compiler_bomb.md), [99 bottles of beer](99_bottles.md) or [fizzbuzz](fizzbuzz.md).
From [mathematical](math.md) point of view quine is a fixed point of a [function](function.md) (not to be confused with [fixed_point arithmetic](fixed_point.md)) represented by the [programming language](programming_language.md). I.e. if we see the programming language as a function f(x), where *x* is source code and the function's output is the program's output, quine is such *x* that *f(x) = x*.
Similar efforts include e.g. making self matching [regular expressions](regex.md) (for this task to be non-trivial the regex has to e.g. be enclosed between `/`s).
Quine can be written in any [Turing complete](turing_completeness.md) [language](programming_language.md) (according to [Wikipedia](wikipedia.md)), the challenge is in the [self reference](self_reference.md) -- normally we cannot just single-line print a string literal containing the source because that string literal would have to contain itself, making it [infinite](infinity.md) in length. The idea commonly used to solve this problem is following:
1. On first line start a definition of string *S*, later copy-paste to it the string on the second line.
@ -32,7 +34,7 @@ This is a quine in [comun](comun.md):
TODO: more langs?
Yet a stronger quine is so called *radiation hardened quine*, a quine that remains quine even after any one character from the program has been deleted (found here in [Ruby](ruby.md): https://github.com/mame/radiation-hardened-quine).
Yet a stronger quine is so called *radiation hardened quine*, a quine that remains quine even after any one character from the program has been deleted (found here in [Ruby](ruby.md): https://github.com/mame/radiation-hardened-quine). Other plays on the theme of quine include e.g. a program that produces a bigger program which will again produce yet bigger program etc.
In the [Text](plaintext.md) [esoteric programming language](esolang.md) every program is a quine (and so also a radiation hardened one).

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -2,9 +2,9 @@
This is an autogenerated article holding stats about this wiki.
- number of articles: 553
- number of commits: 689
- total size of all texts in bytes: 2965186
- number of articles: 555
- number of commits: 690
- total size of all texts in bytes: 2983057
longest articles:
@ -24,6 +24,23 @@ longest articles:
latest changes:
```
Date: Tue Feb 13 17:12:51 2024 +0100
100r.md
c.md
game_of_life.md
history.md
how_to.md
internet.md
langtons_ant.md
mandelbrot_set.md
pedophilia.md
pi.md
programming_language.md
random_page.md
resnicks_termite.md
wiki_pages.md
wiki_stats.md
xxiivv.md
Date: Mon Feb 12 20:36:38 2024 +0100
art.md
ascii_art.md
@ -40,23 +57,6 @@ Date: Mon Feb 12 12:09:17 2024 +0100
anarch.md
bloat.md
bootstrap.md
chess.md
communism.md
competition.md
css.md
left_right.md
math.md
prime.md
privacy.md
shader.md
tas.md
thrembo.md
usa.md
woman.md
Date: Sun Feb 11 21:31:18 2024 +0100
random_page.md
wiki_pages.md
wiki_stats.md
```
most wanted pages: