Update
This commit is contained in:
parent
32455c0cd7
commit
47934a4bdb
6 changed files with 45 additions and 17 deletions
11
c.md
11
c.md
|
@ -2,12 +2,18 @@
|
||||||
|
|
||||||
{ We have a [C tutorial](c_tutorial.md)! ~drummyfish }
|
{ We have a [C tutorial](c_tutorial.md)! ~drummyfish }
|
||||||
|
|
||||||
C is a [low level](low_level.md), statically typed imperative compiled language, the go-to language of most [less retarded software](lrs.md). It is the absolutely preferred language of the [suckless](suckless.md) community as well as of most true experts, for example the [Linux](linux.md) and [OpenBSD](openbsd.md) developers, because of its good minimal design, level of control, uncontested performance and a greatly established and tested status.
|
C is a [low level](low_level.md), [statically typed](static_typing.md) [imperative](imperative.md) compiled [programming language](programming_language.md), the go-to language of most [less retarded software](lrs.md). It is the absolutely preferred language of the [suckless](suckless.md) community as well as of most true experts, for example the [Linux](linux.md) and [OpenBSD](openbsd.md) developers, because of its good minimal design, level of control, uncontested performance and a greatly established and tested status.
|
||||||
|
|
||||||
C is usually not considered an easy language to learn because of its low level nature: it requires good understanding of how a computer actually works and doesn't prevent the programmer from shooting himself in the foot. Programmer is given full control (and therefore responsibility). There are things considered "tricky" which one must be aware of, such as undefined behavior of certain operators and raw pointers. This is what can discourage a lot of modern "coding monkeys" from choosing C, but it's also what inevitably allows such great performance -- undefined behavior allows the compiler to choose the most efficient implementation.
|
C is usually not considered an easy language to learn because of its low level nature: it requires good understanding of how a computer actually works and doesn't prevent the programmer from shooting himself in the foot. Programmer is given full control (and therefore responsibility). There are things considered "tricky" which one must be aware of, such as undefined behavior of certain operators and raw pointers. This is what can discourage a lot of modern "coding monkeys" from choosing C, but it's also what inevitably allows such great performance -- undefined behavior allows the compiler to choose the most efficient implementation.
|
||||||
|
|
||||||
## History and Context
|
## 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), ...).
|
||||||
|
|
||||||
|
In 1973 Unix was rewritten in C. In 1978 Keninghan and Ritchie published a book called *The C Programming Language*, known as *K&R*, which became something akin the C specification. In 1989, the [ANSI C](ansi_c.md) standard, also known as C89, was released by the American ANSI. The same standard was also adopted a year later by the international ISO, so C90 refers to the same language. In 1999 ISO issues a new standard that's known as C99.
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
## Standards
|
## Standards
|
||||||
|
|
||||||
C is not a single language, there have been a few standards over the years since its inception in 1970s. The notable standards and versions are:
|
C is not a single language, there have been a few standards over the years since its inception in 1970s. The notable standards and versions are:
|
||||||
|
@ -143,6 +149,7 @@ RETURN_TYPE myFunction (TYPE1 param1, TYPE2 param2, ...)
|
||||||
|
|
||||||
## See Also
|
## See Also
|
||||||
|
|
||||||
- [C pitfalls](c_pitfalls.md)
|
|
||||||
- [C tutorial](c_tutorial.md)
|
- [C tutorial](c_tutorial.md)
|
||||||
|
- [C pitfalls](c_pitfalls.md)
|
||||||
|
- [C programming style](programming_style.md)
|
||||||
- [IOCCC](ioccc.md)
|
- [IOCCC](ioccc.md)
|
|
@ -4,7 +4,7 @@ Left and right are two basic opposing political sides that roughly come down to
|
||||||
|
|
||||||
- The (true) **left is pro social equality**, i.e. against social hierarchies. This includes equality of all living beings, period. Note that social equality does NOT imply people being made (or being made to appear) equal in other ways, e.g. physically -- true left accepts difference between people and [races](race.md) and doesn't hide them. Even if the perfectly ideally leftist society can't be completely achieved, true left tries to get **as close to it as possible**. The values of true left are for example sharing, [love](love.md), [selflessness](selflessness.md), [altruism](altruism.md), forgiveness and nonviolence. Groups and movements that are at least highly truly leftist include [anarcho pacifism](anpac.md), [free software](free_software.md), [free culture](free_culture.md) and of course [LRS](lrs.md).
|
- The (true) **left is pro social equality**, i.e. against social hierarchies. This includes equality of all living beings, period. Note that social equality does NOT imply people being made (or being made to appear) equal in other ways, e.g. physically -- true left accepts difference between people and [races](race.md) and doesn't hide them. Even if the perfectly ideally leftist society can't be completely achieved, true left tries to get **as close to it as possible**. The values of true left are for example sharing, [love](love.md), [selflessness](selflessness.md), [altruism](altruism.md), forgiveness and nonviolence. Groups and movements that are at least highly truly leftist include [anarcho pacifism](anpac.md), [free software](free_software.md), [free culture](free_culture.md) and of course [LRS](lrs.md).
|
||||||
- The **right is pro social hierarchy**, i.e. against social equality. This means some people standing above others, be it by strength, power, wealth, social status, privileges etc. The rightist values are mostly those associated with [evil](evil.md), i.e. violence, oppression, conflict, war, revenge, survival of the fittest etc. Among rightism can be included [fascism](fascism.md), [capitalism](capitalism.md), US republican party, states, the military etc.
|
- The **right is pro social hierarchy**, i.e. against social equality. This means some people standing above others, be it by strength, power, wealth, social status, privileges etc. The rightist values are mostly those associated with [evil](evil.md), i.e. violence, oppression, conflict, war, revenge, survival of the fittest etc. Among rightism can be included [fascism](fascism.md), [capitalism](capitalism.md), US republican party, states, the military etc.
|
||||||
- The **pseudoleft** is pretending to be left while in fact being right due to e.g. using non-leftist means (such as violence) or even having non-leftist goals (e.g. benefit of specific minority as opposed to benefit of everyone). Among pseudoleftist movements are [feminism](feminism.md), [LGBT](lgbt.md), [Antifa](antifa.md) or [Marxism](marxism.md).
|
- The **pseudoleft** is pretending to be left while in fact being right due to e.g. using non-leftist means (such as violence) or even having non-leftist goals (e.g. benefit of specific minority as opposed to benefit of everyone). Among pseudoleftist movements are [feminism](feminism.md), [LGBT](lgbt.md), [Antifa](antifa.md) or [Marxism](marxism.md). This fact is also supported by the [naming](name_matters.md) of these movements.
|
||||||
|
|
||||||
There exists a "theory" called a horse shoe. It says that the extremes of the left-right spectrum tend to be alike (violent, hating, radical), just as the two ends of a horse shoe. This is only an illusion caused by ignoring the existence of pseudoleft. The following diagram shows the true situation:
|
There exists a "theory" called a horse shoe. It says that the extremes of the left-right spectrum tend to be alike (violent, hating, radical), just as the two ends of a horse shoe. This is only an illusion caused by ignoring the existence of pseudoleft. The following diagram shows the true situation:
|
||||||
|
|
||||||
|
|
10
lil.md
10
lil.md
|
@ -2,8 +2,14 @@
|
||||||
|
|
||||||
Little interpreted language (LIL) is a very nice [suckless](suckless.md), yet practically unknown interpreted [programming language](programming_language.md) by Kostas Michalopoulos which can very easily be embedded in other programs. In this it is similar to [Lua](lua.md) but is even more simple: it is implemented **in just two [C](c.md) source code files** (lil.c and lil.h) that together count about 3700 [LOC](loc.md). It is provided under [zlib](zlib.md) [license](license.md). More information about it is available at http://runtimeterror.com/tech/lil.
|
Little interpreted language (LIL) is a very nice [suckless](suckless.md), yet practically unknown interpreted [programming language](programming_language.md) by Kostas Michalopoulos which can very easily be embedded in other programs. In this it is similar to [Lua](lua.md) but is even more simple: it is implemented **in just two [C](c.md) source code files** (lil.c and lil.h) that together count about 3700 [LOC](loc.md). It is provided under [zlib](zlib.md) [license](license.md). More information about it is available at http://runtimeterror.com/tech/lil.
|
||||||
|
|
||||||
{ LIL is amazing. I've been able to make it work on such low-specs hardware as Pokitto (32kb RAM embedded). ~drummyfish }
|
{ LIL is relatively amazing. I've been able to make it work on such low-specs hardware as Pokitto (32kb RAM embedded). ~drummyfish }
|
||||||
|
|
||||||
LIL has two implementations, one in [C](c.md) and one in [Free Pascal](free_pascal.md), and also comes with some kind of [GUI](gui.md) and [API](api.md).
|
LIL has two implementations, one in [C](c.md) and one in [Free Pascal](free_pascal.md), and also comes with some kind of [GUI](gui.md) and [API](api.md).
|
||||||
|
|
||||||
The language design is very nice, its interesting philosophy is that **everything is a string**, for example arithmetic operations are performed with a function `expr` which takes a string of an arithmetic expression and returns a string representing the result number.
|
The language design is very nice, its interesting philosophy is that **everything is a string**, for example arithmetic operations are performed with a function `expr` which takes a string of an arithmetic expression and returns a string representing the result number.
|
||||||
|
|
||||||
|
For its simplicity there is no [bytecode](bytecode.md) which would allow for more efficient execution and [optimization](optimization.md).
|
||||||
|
|
||||||
|
TODO: example
|
||||||
|
|
||||||
|
{ I've been looking at the source and unfortunately there are some imperfections. The code uses [goto](goto.md) (may not be bad but I dunno). Also unfortunately stdlib, stdio, string and other standard libraries are used as well as [malloc](malloc.md). The code isn't really commented and I find the style kind of hard to read. }
|
9
myths.md
Normal file
9
myths.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Myths
|
||||||
|
|
||||||
|
This is a list of myths and common misconceptions.
|
||||||
|
|
||||||
|
- **"[Java](java.md) is highly [portable](portability.md)"**; FALSE: While Java runs on several platforms, it's inefficiency and overhead of its extremely high level programming makes it unusable on devices with limited resources such as [embedded systems](embedded.md). Its [bloated](bloat.md) nature and high number of dependencies limit it to running on a few types of **mainstream** devices that are privileged to have the Java virtual machine implemented.
|
||||||
|
- **"[C](c.md) is not [portable](portability.md)"**; FALSE: C is extremely portable if written [correctly](lrs.md) (e.g. without dependencies), in fact it is probably the **most portable language in history** because firstly a C compiler is available for almost any platform -- a C compiler is one of the most essential things to have -- and secondly because C is extremely efficient and will run even on devices with extremely limited resources such as [embedded systems](embedded.md).
|
||||||
|
- **"[Capitalism](capitalism.md) fuels progress"**; FALSE: Monopolies that inevitably arise in capitalism want to forever prevent others from creating innovations that would make the subject of their business obsolete (e.g. fossil fuel businessmen will want to prevent electric cars). Of course, small businesses cannot compete with large corporations, therefore corporations win and keep the status quo. Small businesses can mostly only succeed in creating [bullshit](bullshit.md) that exists for its own sake (there is e.g. an online store selling literal shit) -- this we would not call a progress. Furthermore capitalism is against the important kind of progress such as social progress or education, because of course educated, independent and mature people would engage less in consumerism and even realize that capitalism is bad.
|
||||||
|
- **Feminism, LGBT, Antifa and similar are leftist movements**; FALSE: These are in fact [pseudoleftist](pseudoleft.md), fascist movements who don't care about true equality but rather privileges for a certain minority, just as the Italian fascist or Nazis did. This is proven by their [naming](name_matters.md) and means of operation such as violence, censorship, bullying etc. which are anti-equality.
|
||||||
|
- TODO
|
|
@ -27,6 +27,7 @@ There are many terms that are very similar and are sometimes used interchangeabl
|
||||||
- **[coherence](coherence.md)** vs **[consistency](consistency.md)**
|
- **[coherence](coherence.md)** vs **[consistency](consistency.md)**
|
||||||
- **[convolution](convolution.md)** vs **[correlation](correlation.md)**
|
- **[convolution](convolution.md)** vs **[correlation](correlation.md)**
|
||||||
- **[copyright](copyright.md)** vs **[patent](patent.md)** vs **[trademark](trademark.md)**
|
- **[copyright](copyright.md)** vs **[patent](patent.md)** vs **[trademark](trademark.md)**
|
||||||
|
- **[crossplatform/multiplatform](multiplatform.md)** vs **[portable](portability.md)**
|
||||||
- **[cryptography](cryptography.md)** vs **[security](security.md)**
|
- **[cryptography](cryptography.md)** vs **[security](security.md)**
|
||||||
- **[data](data.md)** vs **[information](information.md)**
|
- **[data](data.md)** vs **[information](information.md)**
|
||||||
- **[data structure](data_structure.md)** vs **[data type](data_type.md)**
|
- **[data structure](data_structure.md)** vs **[data type](data_type.md)**
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
# Programming Style
|
# Programming Style
|
||||||
|
|
||||||
Here we discuss a good programming style (formatting, conventions etc.). Remember that nothing is set in stone here, the most important thing is to be consistent and actually think about why you're doing things the way you're doing them.
|
Here we discuss a good programming style (formatting, conventions etc.). Remember that nothing is set in stone, the most important thing is to be consistent and actually think about why you're doing things the way you're doing them. Think from the point of view of a programmer who gets just your source code without any way to communicate with you, make his life as easy as possible.
|
||||||
|
|
||||||
## Recommended Style
|
## Recommended C Programming Style
|
||||||
|
|
||||||
This is "our" recommendation or perhaps just a suggestion/guide on the [C](c.md) programming style.
|
This is our recommendation or perhaps just a suggestion/guide on the [C](c.md) programming style.
|
||||||
|
|
||||||
|
- Respect the [LRS](lrs.md) principles.
|
||||||
|
- Use **two spaces** for indentation. **Do not use [tabs](tab.md)!** Tabs are ugly, tricky non-standard behaving characters.
|
||||||
|
- **Format to 80** columns or a similar width. Keep in mind the source may be edited on computers with small screens (like old [thinkpads](thinkpad.md)) with a screen split vertically.
|
||||||
|
- Write **opening and closing curly brackets on its own line, in the same columns**, e.g.:
|
||||||
|
|
||||||
- Use **two spaces** for indentation. **Do not use tabs!** Tabs are ugly, tricky non-standard behaving chars.
|
|
||||||
- **Formal to 80** columns or a similar width.
|
|
||||||
- Write **opening and closing curly brackets on the same level**, e.g.:
|
|
||||||
```
|
```
|
||||||
if (a == b)
|
if (a == b)
|
||||||
{
|
{
|
||||||
|
@ -16,15 +18,17 @@ if (a == b)
|
||||||
doSomethingElse();
|
doSomethingElse();
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- Prefer not writing curly brackets if you don't have to (e.g. with a single command in the block). You may still do it in tricky cases like nested branches.
|
- Prefer not writing curly brackets if you don't have to (e.g. with a single command in the block). You may still do it in tricky cases like nested branches.
|
||||||
- **naming**:
|
- **naming**:
|
||||||
- **camelCase for variables and functions** (like `myVariable`). Global and big-scope variables should have a descriptive, self-documenting name (e.g. `getTicksSinceStart`), local/short-scope ones can be just one letter.
|
- **camelCase for variables and functions** (like `myVariable`). Global and big-scope variables should have a descriptive, self-documenting name (e.g. `getTicksSinceStart`), local/short-scope ones can be just one letter.
|
||||||
- **CapitalCamelCase for data types** (like `ImaginaryNumber`).
|
- **CapitalCamelCase for data types** (like `ImaginaryNumber`).
|
||||||
- **ALL_CAPS_SNAKE_CASE for macros** (like `PI` or `MIN`).
|
- **ALL_CAPS_SNAKE_CASE for macros and constants** (like `PI` or `MY_MACRO`).
|
||||||
- It is advised that for your project you come up with a **three letter namespace prefix** that will come in front of your global identifiers. (E.g. [small3dlib](small3dlib.md) uses the prefix `S3L_`). If you choose a prefix `XYZ_`, put it at the start of every global identifier, it will prevent name clashes and help readability.
|
- It is advised that for your project you come up with a **three letter namespace prefix** that will come in front of your global identifiers. (E.g. [small3dlib](small3dlib.md) uses the prefix `S3L_`, [SDL](sdl.md) uses `SDL` etc.). If you choose a prefix `XYZ_`, prepend it to all global identifiers, it will prevent name clashes and help readability.
|
||||||
- **Prefix private global identifiers with `_`**, e.g. `_myInternalVar`.
|
- **Prefix private global identifiers with `_`**, e.g. `_myInternalVar`.
|
||||||
- **Use spaces** to make code more readable, so e.g. `int x = 10, y = 20;` instead of `int x=10,y=20;`, write space between `if` and its condition etc.
|
- **Use spaces** to make code more readable, so e.g. `int x = 10, y = 20;` instead of `int x=10,y=20;`, write space between `if` and its condition etc.
|
||||||
- **Use blank lines** to logically group relevant lines of code. E.g.:
|
- **Use blank lines** to logically group relevant lines of code. E.g.:
|
||||||
|
|
||||||
```
|
```
|
||||||
int a = x;
|
int a = x;
|
||||||
char b = y;
|
char b = y;
|
||||||
|
@ -35,10 +39,11 @@ d -= b;
|
||||||
if (c < d)
|
if (c < d)
|
||||||
a = b;
|
a = b;
|
||||||
```
|
```
|
||||||
- Each file shall have a **global [comment](comment.md)** with at least: short description of the file's purpose, license, the author(s) and year of creation.
|
|
||||||
|
- Each file shall have a **global [comment](comment.md)** with at least: short description of the file's purpose (this is almost always missing), [license](license.md), the author(s) and year of creation.
|
||||||
- **Use [comments](comment.md)** to make your code better readable and searchable (add keywords to relevant parts of code etc.).
|
- **Use [comments](comment.md)** to make your code better readable and searchable (add keywords to relevant parts of code etc.).
|
||||||
- **Don't use `enum`s**, use `#define`s.
|
- **Don't use [enums](enum.md)**, use `#define`s.
|
||||||
- **Global variables are great**, use them. **Long functions are fine**.
|
- **Global variables are great**, use them. **Long functions are fine**.
|
||||||
- **Adhere to C99 standard**. You may consider adhering to C89 standard for even better portability (i.e. no declarations in the middle of the code etc.).
|
- **Adhere to C99 or C89 standard**.
|
||||||
- Try to not create many source files, many times your project can very well be in a single file which is the ideal case. If you have multiple files, keep them in the same directory and try to have just a single compilation unit (only one .c file with several .h files). Try to make files no longer than 10k lines.
|
- **Try to not create many source files**, many times your project can very well be in a single file which is the ideal case. Create **[header only libraries](header_only.md)** If you have multiple files, keep them in the same directory and try to have just a **[single compilation unit](single_compilation_unit.md)** (only one .c file with several .h files). Try to make files no longer than 10k lines.
|
||||||
- **Do not use non-ASCII characters in the source code**.
|
- **Do not use non-ASCII characters in the source code**.
|
Loading…
Reference in a new issue