From 01ab666f9436719275008549abc87c712b7cd97e Mon Sep 17 00:00:00 2001 From: Miloslav Ciz Date: Sat, 22 Oct 2022 16:12:50 +0200 Subject: [PATCH] Update --- body_shaming.md | 3 + cheating.md | 4 +- fork.md | 11 ++- gay.md | 4 +- interplanetary_internet.md | 2 +- lgbt.md | 6 +- optimization.md | 21 ++--- portability.md | 159 +++++++++++++++++++++++++++++++++++++ prime.md | 2 +- wikipedia.md | 5 +- 10 files changed, 194 insertions(+), 23 deletions(-) create mode 100644 body_shaming.md create mode 100644 portability.md diff --git a/body_shaming.md b/body_shaming.md new file mode 100644 index 0000000..0cbdd1b --- /dev/null +++ b/body_shaming.md @@ -0,0 +1,3 @@ +# Body Shaming + +*Your body sucks.* \ No newline at end of file diff --git a/cheating.md b/cheating.md index a3c2844..3dd7d6c 100644 --- a/cheating.md +++ b/cheating.md @@ -4,4 +4,6 @@ Cheating means circumventing or downright violating rules, usually while trying The truth is that **cheating is only an issue in a shitty society** that's driven by competition. In such society there is a huge motivation for cheating (sometimes literally physical survival) as well as potentially disastrous consequences of it. Under the tyranny of capitalism we are led to worship heroes and high achievers and everyone gets pissed when we get fooled. Corporations go "OH NOES our multi bilion dollar entertainment industry is going to go bankrupt if consoomers get annoyed by cheaters! People are gonna lose their bullshit jobs! Someone is going to get money he doesn't deserve! Our customers may get butthurt!!!" (as if corporations themselves weren't basically just stealing money and raping people lol). So they start a huge brainwashing propaganda campaign, a cheater witch hunt. States do the same, communities do the same, everyone wants to stone cheaters to death but at the same time the society pressures all of us to compete to death with others or else we'll starve. We reward winners and torture the losers, then bash people who try to win -- and no, many times there is no other choice than to cheat, the top of any competition is littered with cheaters, most just don't get caught, so in about 99% of cases the only way to the top is to cheat and try to not get caught, just to have a shot at winning against others. It is proven time after time, legit looking people in the top leagues of sports, business, science and other areas are constantly being revealed as cheaters. Cheater detection systems are (and always will be) imperfect and try to minimize [false positives](false_positive.md), so only the most obvious cheaters get caught, the smart cheaters stay and take the top places in the competitive system, just as surely as natural selection leads to the evolution of organisms that best adapt to the environment. How to solve this enormously disgusting mess? We simply have to stop desperately holding to the system itself, we have to ditch it. -In a good society, such as [LRS](less_retarded_society.md), cheating is not an issue at all, there's no motivation for it (people don't have to prove their worth by their skills, there are no money, people don't worship heroes, ...) and there are no negative consequences of cheating worse than someone [ragequitting](ragequit.md) an online game -- which really isn't an issue of cheating anyway but simply a consequence of unskilled player facing a skilled one (whether the pro's skill is natural or artificial doesn't play a role, the nub will ragequit anyway). In a good society cheating can become a mild annoyance at worst, and it can really be a positive thing, it can be [fun](fun.md) -- seeing for example a skilled pro face and potentially even beat a cheater is a very interesting thing. If someone wants to win by cheating, why not let him? Valid answers to this can only be given in the context of a shit society. In a good society choosing to cheat in a game is as if someone chooses to fly to the top of a mountain by helicopter rather than climbing it -- the choice is everyone's to make. \ No newline at end of file +In a good society, such as [LRS](less_retarded_society.md), cheating is not an issue at all, there's no motivation for it (people don't have to prove their worth by their skills, there are no money, people don't worship heroes, ...) and there are no negative consequences of cheating worse than someone [ragequitting](ragequit.md) an online game -- which really isn't an issue of cheating anyway but simply a consequence of unskilled player facing a skilled one (whether the pro's skill is natural or artificial doesn't play a role, the nub will ragequit anyway). In a good society cheating can become a mild annoyance at worst, and it can really be a positive thing, it can be [fun](fun.md) -- seeing for example a skilled pro face and potentially even beat a cheater is a very interesting thing. If someone wants to win by cheating, why not let him? Valid answers to this can only be given in the context of a shit society. In a good society choosing to cheat in a game is as if someone chooses to fly to the top of a mountain by helicopter rather than climbing it -- the choice is everyone's to make. + +The fact that cheating isn't really an issue is supported by the hilariously vastly different double standards applied e.g. by chess platforms in this matter, on one hand they state in their TOS they have absolutely 0% tolerance of any kind of cheating/assistance and will lifeban players for the slightest suspicion of cheating yelling WE HAVE TO [FIGHT](fight.md) CHEATING, on the other hand they allow streamers literally cheat on a daily basis on live stream where everyone is seeing it, of course because streamers bring them money -- ALL top chess streamers (chessbrah, Nakamura, ...), including the world champion Magnus Carlsen himself, have videos of themselves getting advice on moves from the chat or even from high level players present during the stream, Magnus Carlsen is filmed taking over his friend's low rated account and winning a game which is the same as if the friend literally just used an engine to win the game, and Magnus is also filmed getting an advice from a top grandmaster on a critical move in a tournament that won him the game and granted him a FINANCIAL PRIZE. **World chess champion is literally filmed winning money by cheating and no one cares** because it was done as part of a highly lucrative stream "in a fun/friendly mood". Chessbrah streams frequently consist of many people in the room just giving advice on moves to the one who is currently playing, of course they censor all comments that try to bring up the fact that this is 100% cheating directly violating the platform's TOS. People literally have no brains, they only freak out about cheating when they're told to by the industry, when cheating is good for business people are told to shut up because it's okay and indeed they just shut up and keep consuming. \ No newline at end of file diff --git a/fork.md b/fork.md index d399e74..5c2340e 100644 --- a/fork.md +++ b/fork.md @@ -1,6 +1,6 @@ # Fork -Fork is a branch that splits from the main branch of a project and continues to develop in a different direction as a separate version of that project, possibly becoming a completely new one. This may happen with any "intellectual work" or idea such as [software](software.md), movement, theory, literary universe or, for example, [database](database.md). Forks may later be *merged* back into the original project or continue and diverge far away, forks of different projects may also combine into a single project as well. +Fork is a branch that splits from the main branch of a project and continues to develop in a different direction as a separate version of that project, possibly becoming a completely new one. This may happen with any "intellectual work" or idea such as [software](software.md), movement, theory, literary universe or, for example, a [database](database.md). Forks may later be *merged* back into the original project or continue and diverge far away, forks of different projects may also combine into a single project as well. For example the [Android](android.md) [operating system](os.md) and [Linux-libre](linux_libre.md) [kernel](kernel.md) have both been forked from [Linux](linux.md). [Linux distributions](distro.md) highly utilize forking, e.g. [Devuan](devuan.md) or [Ubuntu](ubuntu.md) and [Mint](mint.md) are forked from [Debian](debian.md). [Free software movement](free_software.md) was forked into [open source](open_source.md), [free culture](free_culture.md) and [suckless](suckless.md), and suckless was more or less forked into [LRS](lrs.md). [Wikipedia](wikipedia.md) also has forks such as [Metapedia](metapedia.md). [Memes](meme.md) evolve a lot on the basis of forking. @@ -8,6 +8,11 @@ Forking takes advantage of the ability to freely duplicate [information](informa In software development temporary forking is used for implementing individual features which, when completed, are merged back into the main branch. This is called **[branching](branch.md)** and is supported by [version control systems](vcs.md) such as [git](git.md). -**Is forking good?** Yes, to create anything new it is basically necessary to build on top of someone else's work, stand on someone else's shoulders. Some people criticize too much forking; for example some cry about [Linux](linux.md) [distro](distro.md) fragmentation, they say there are too many of them and that people should rather focus their energy on creating a single or at least fewer good operating system. [LRS](lrs.md) supports any kind of wild forking and experimentation, we believe the exploration of many directions to be necessary in order to find the right one. +There are two main kinds of forks: -In fact we think forking should be incorporated on a much more basic level, in the way that the [suckless](suckless.md) community popularized. In suckless **everyone's copy of software is a personal fork**, i.e. software is distributed in source form and is so extremely easy to compile and modify that every user is supposed to do this as part of the installation process (even if he isn't a programmer). Before compilation user applies his own selected patches, custom changes and specific configuration (which is done in the source code itself) that are unique to that user and which form source code that is the user's personal fork. Some of these personal forks may even become popular and copied by other users, leading to further development of these forks and possible natural rise of very different software. This should lead to natural selection, survival and development of the good and useful forks. \ No newline at end of file +- **soft forks**: Soft fork introduces changes that somehow stay compatible with the original project and can potentially even be merged back later, the fork exists as a different but synchronized version of the original project and as the original gets updates, the fork automatically gets these updates as well. Temporary [git](git.md) forks during development are soft forks, also for example [Linux-libre](linux_libre.md) is a soft fork of [Linux](linux.md) as it adds a set of scripts that automatically remove proprietary blobs from the current version of Linux; [patches](patch.md) of [suckless](suckless.md) software can also be seen as soft forks. It is typical that a soft fork somehow maintains just a set of changes against the original, e.g. in a form of a [diff](diff.md) or [script](script.md), i.e. soft fork is kind of a lightweight fork for which the original project stays a [dependency](dependency.md). +- **hard forks**: Hard fork splits from the original project in such a way that it can no longer be easily merged back, it diverges in a very different way and stops being synchronized with the original. For example [darkplaces](darkplaces.md) is a hard fork of the [Quake](quake.md) 1 engine. Hard fork typically just copies all the data of the original project to a new repository and start modifying them freely. This has the disadvantage of having to repeat work on the original and the fork (e.g. if a new bug is discovered in the original after the split, it has to be manually fixed in both versions). This is one of the reasons why hard forks very often split off of projects that aren't actively developed anymore. + +**Is forking good?** Yes, to create anything new it is basically necessary to build on top of someone else's work, stand on someone else's shoulders. Some people criticize too much forking; for example some cry about [Linux](linux.md) [distro](distro.md) fragmentation, they say there are too many of distros and that people should rather focus their energy on creating a single or at least fewer good operating systems, i.e. that forking is kind of "wasting effort". [LRS](lrs.md) supports any kind of wild forking and experimentation, we believe the exploration of many directions to be necessary in order to find the right one, in a [good society](less_retarded_society.md) waste of work won't be happening -- that's an issue of a [competitive society](capitalism.md), not forking. + +In fact we think that (at least soft) forking should be incorporated on a much more basic level, in the way that the [suckless](suckless.md) community popularized. In suckless **everyone's copy of software is a personal fork**, i.e. software is distributed in source form and is so extremely easy to compile and modify that every user is supposed to do this as part of the installation process (even if he isn't a programmer). Before compilation user applies his own selected patches, custom changes and specific configuration (which is done in the source code itself) that are unique to that user and which form source code that is the user's personal fork. Some of these personal forks may even become popular and copied by other users, leading to further development of these forks and possible natural rise of very different software. This should lead to natural selection, survival and development of the good and useful forks. \ No newline at end of file diff --git a/gay.md b/gay.md index 5875dfd..c95033a 100644 --- a/gay.md +++ b/gay.md @@ -1,10 +1,8 @@ # Gay -{ No, this article is NOT offensive, we do NOT advocate any discrimination, in fact we advocate the exact opposite, the need for love towards all living beings. Stop being an idiot and getting offended by truth. ~drummyfish } - Homosexuality is a sexual orientation and disorder which makes individuals sexually attracted primarily to the same sex. A homosexual individual is called gay, homo or even faggot ([females](woman.md) are called lesbians). About 4% of people suffer from homosexuality. -Unlike e.g. [pedophilia](pedophilia.md) and probably also [bisexuality](bisexual.md), **pure homosexuality is NOT normal**, it is a disorder -- of course the meaning of the word disorder is highly debatable, but pure homosexuality is firstly pretty rare, and secondly from the nature's point of view gay people wouldn't naturally reproduce, their condition is therefore equivalent to any other kind of sterility, which we most definitely would call a defect. +Unlike e.g. [pedophilia](pedophilia.md) and probably also [bisexuality](bisexual.md), **pure homosexuality is NOT normal**, it is a disorder -- of course the meaning of the word disorder is highly debatable, but pure homosexuality is firstly pretty rare (being gay is as rare as e.g. having [IQ](iq.md) < 75), and secondly from the nature's point of view gay people wouldn't naturally reproduce, their condition is therefore equivalent to any other kind of sterility, which we most definitely would call a defect. Gay behavior is also usually pretty weird, male homos are very feminine and talk in high pitched voice, lesbians are masculine, have short pink hair, often also aggressive nature and identity crisis manifested by [tattoos](tattoo.md) etc. Most normal people naturally find this disgusting but are afraid to say it because of [political correctness](political_correctness.md) and fear of being [lynched](cancel_culture.md). You can usually safely tell someone's gay just from his body language and/or appearance. Gay people also more inclined towards [art](art.md) and other sex's activities, for example gay guys are often hair dressers or even ballet dancers. diff --git a/interplanetary_internet.md b/interplanetary_internet.md index d619ad3..b213dec 100644 --- a/interplanetary_internet.md +++ b/interplanetary_internet.md @@ -1,6 +1,6 @@ # Interplanetary Internet -Interplanetary Internet is at this time still hypothetical extension of the [Internet](internet.md) to multiple planets. As mankind is getting closer to starting living on other planets and bodies such as [Mars](mars.md) and [Moon](moon.md), we have to start thinking about the challenges of creating a communication network between all of them. The greatest challenge is posed by the vast distances that increase the communication delay (which arises due to the limited [speed of light](speed_of_light.md)) and make errors such as [packet loss](packet_loss.md) much more painful. Two-way communication (i.e. request-response) to Moon and Mars can take even 2 seconds and 40 minutes respectively. Also things like planet motions, eclipses etc. pose problems to solve. +Interplanetary Internet is at this time still a hypothetical extension of the [Internet](internet.md) to multiple planets. As mankind is getting closer to starting living on other planets and bodies such as [Mars](mars.md) and [Moon](moon.md), we have to start thinking about the challenges of creating a communication network between all of them. The greatest challenge is posed by the vast distances that increase the communication delay (which arises due to the limited [speed of light](speed_of_light.md)) and make errors such as [packet loss](packet_loss.md) much more painful. Two-way communication (i.e. request-response) to Moon and Mars can take even 2 seconds and 40 minutes respectively. Also things like planet motions, eclipses etc. pose problems to solve. We can see that e.g. [real time](real_time.md) [Earth](earth.md)-Mars communication (e.g. [chat](chat.md) or videocalls) are physically impossible, so not only do we have to create new [network](network.md) [protocols](protocol.md) that minimize the there-and-back communication (things such as [handshakes](handshakes.md) are out of question) and implement great [redundancy](redundancy.md) for reliable recovery from loss of data traveling through space, we also need to design **new [user interfaces](ui.md)** and communication paradigms, i.e. we probably need to create a new messaging software for "interplanetary chat" that will for example show the earliest time at which the sender can expect an answer etc. [Interesting](interesting.md) shit to think about. diff --git a/lgbt.md b/lgbt.md index 1ba779b..fc743df 100644 --- a/lgbt.md +++ b/lgbt.md @@ -4,10 +4,12 @@ LGBT, LGBTQ+, LGBTQIKKAWTFJJJKKSSMMMAAK (lesbian [gay](gay.md), [bisexual](bisexual.md), [transsexual](tranny.md), [queer](queer.md) and whatever else they're gonna invent) is a [fascist](fascist.md) political group of terrorists whose gospel preaches superiority of certain selected minority sexual orientations. They are a highly [violent](violence.md), [bullying](bully.md) movement (not surprisingly centered in the [US](us.md)) practicing [censorship](censorship.md), Internet lynching ([cancel culture](cancel_culture.md)), discrimination, spread of extreme [propaganda](propaganda.md), [political correctness](political_correctness.md) and other [evil](evil.md). -Note that **not all gay people support LGBT**, even though LGBT wants you to think so and media treat e.g. the terms *gay* and *LGBT* as synonyms (this is part of [propaganda](propaganda.md), either conscious or subconscious). The relationship gay-LGBT is the same as e.g. the relationship German-Nazi: Nazis were a German minority that wanted more privileges for Germans (as the felt oppressed by Jews), LGBT is a gay minority who want more privileged for gay people (because they feel oppressed by non-gay people). LGBT isn't just about being gay but about approving of a very specific ideology that doesn't automatically come with being gay. LGBT frequently comments on issues that go beyond simply being gay (or whatever), for example LGBT openly stated disapproval of certain other orientation (e.g. [pedophilia](pedophilia.md)) and refuses to admit homosexuality is a disorder, which aren't necessarily stances someone has to take when simply being gay. +LGBT is related to the ideas of equality in a similar way in which crusade wars were related to the nonviolent teaching of [Jesus](jesus.md), it shows how an idea can be completely twisted around and turned on its head so that it's directly contradicting its original premise. + +Note that **not all gay people support LGBT**, even though LGBT wants you to think so and media treat e.g. the terms *gay* and *LGBT* as synonyms (this is part of [propaganda](propaganda.md), either conscious or subconscious). The relationship gay-LGBT is the same as e.g. the relationship German-Nazi: Nazis were a German minority that wanted to fight for more privileges for Germans (as they felt oppressed by Jews), LGBT is a gay minority who wants to [fight](fight_culture.md) for more privileged for gay people (because they feel oppressed by non-gay people). LGBT isn't just about being gay but about approving of a very specific ideology that doesn't automatically come with being gay. LGBT frequently comments on issues that go beyond simply being gay (or whatever), for example LGBT openly stated disapproval of certain other orientation (e.g. [pedophilia](pedophilia.md)) and refuses to admit homosexuality is a disorder, which aren't necessarily stances someone has to take when simply being gay. LGBT works towards establishing [newspeak](newspeak.md) and [though crime](though_crime.md), their "pride" parades are not unlike military parades, they're meant to establish fear of their numbers. LGBT targets children and young whom their propaganda floods every day with messages like *"being gay makes you cool and more interesting"* so that they have a higher probability of developing homosexuality to further increase their ranks in the future. They also push the idea of children having same sex parents for the same reason. They oppose [straight](straight.md) people as they solely focus on gaining more and more rights and power only for their approved orientations. They also highly bully other, unpopular sexual orientations such as [pedophiles](pedophilia.md) (not necessarily child rapists), [necrophiles](necro.md) and [zoophiles](zoophilia.md), simply because supporting these would hurt their popularity and political power. They label the non-approved orientations a "disorder", they push people of such orientations to [suicide](suicide.md) and generally just do all the bad things that society used to do to gay people in the past -- the fact that these people are often gay people who know what it's like to be bullied like that makes it this even much more sad and disgusting. To them it doesn't matter you never hurt anyone, if they find some [loli](loli.md) images on your computer, you're gonna get lynched mercilessly. -In the world of technology they are known for supporting [toxic](toxic.md) [codes of conduct](coc.md) in [FOSS](foss.md) projects (so called [tranny software](tranny_sw.md)), they managed to push them into most mainstream projects, even [Linux](linux.md) etc. Generally they just killed [free speech](free_speech.md) online, every platform now has some kind of surveillance and censorship justified by "offensive speech". They canceled [Richard Stallman](rms.md) for merely questioning a part of their gospel. They also managed to establish things like "diversity" quotas in Hollywood that only allow Oscars to be given to movies made by specific number of gays, lesbians etc. xD Apparently in the software development industry it is now standard to pretend to be a tranny on one's resume so as to greatly increase the chance of being hired xD WTF if I didn't live in this shitty world I wouldn't believe that's even possible, in a dystopian horror movie this would feel like crossing the line of believability too far [lmao](lmao.md). \ No newline at end of file +In the world of technology they are known for supporting [toxic](toxic.md) [codes of conduct](coc.md) in [FOSS](foss.md) projects (so called [tranny software](tranny_sw.md)), they managed to push them into most mainstream projects, even [Linux](linux.md) etc. Generally they just killed [free speech](free_speech.md) online as well as [in real life](irl.md), every platform now has some kind of surveillance and censorship justified by "offensive speech". They canceled [Richard Stallman](rms.md) for merely questioning a part of their gospel. They also managed to establish things like "diversity" quotas in Hollywood that only allow Oscars to be given to movies made by specific number of gays, lesbians etc. xD Apparently in the software development industry it is now standard to pretend to be a tranny on one's resume so as to greatly increase the chance of being hired xD WTF if I didn't live in this shitty world I wouldn't believe that's even possible, in a dystopian horror movie this would feel like crossing the line of believability too far [lmao](lmao.md). \ No newline at end of file diff --git a/optimization.md b/optimization.md index 3aa1572..aba1701 100644 --- a/optimization.md +++ b/optimization.md @@ -7,11 +7,12 @@ Optimization means making a program more efficient in terms of consumption of so These are mainly for [C](c.md), but may be usable in other languages as well. - **Tell your compiler to actually optimize** (`-O3`, `-Os` etc.). -- **gprof is a utility you can use to profile your code**. +- **[gprof](gprof.md) is a utility you can use to profile your code**. - **`` has fast type nicknames**, types such as `uint_fast32_t` which picks the fastest type of at least given width on given platform. - **Keywords such as `inline`, `static` and `const` can help compiler optimize well**. - **Optimize the [bottlenecks](bottleneck.md)!** Optimizing in the wrong place is a complete waste of time. If you're optimizing a part of code that's taking 1% of your program's run time, you will never speed up your program by more than that 1% even if you speed up the specific part by 10000%. Bottlenecks are usually inner-most loops of the main program loop, you can identify them with [profiling](profiling.md). Generally initialization code that runs only once in a long time doesn't need much optimization -- no one is going to care if a program starts up 1 millisecond faster (but of course in special cases such as launching many processes this may start to matter). - **You can almost always trade space (memory usage) for time (CPU demand) and vice versa** and you can also fine-tune this. You typically gain speed by precomputation (look up tables, more demanding on memory) and memory with compression (more demanding on CPU). +- **[Static](static.md) things are faster and smaller than [dynamic](dynamic.md) things.** This means that things that are somehow fixed/unchangeable are better in terms of performance (and usually also safer and better testable) than things that are allowed to change during [run time](runtime.md) -- for example calling a function directly (e.g. `myVar = myFunc();`) is both faster and requires fewer instructions than calling a function by pointer (e.g. `myVar = myFuncPointer();`): the latter is more flexible but for the price of performance, so if you don't need flexibility (dynamic behavior), use static behavior. This also applies to using [constants](constant.md) (faster/smaller) vs [variables](variable.md), static vs dynamic [typing](typing.md), normal vs dynamic [arrays](array.md) etc. - **Be smart, use [math](math.md)**. Example: let's say you want to compute the radius of a zero-centered [bounding sphere](bounding_sphere.md) of an *N*-point [point cloud](point_cloud.md). Naively you might be computing the Euclidean distance (*sqrt(x^2 + y^2 + z^2)*) to each point and taking a maximum of them, however you can just find the maximum of squared distances (*x^2 + y^2 + z^2*) and return a square root of that maximum. This saves you a computation of *N - 1* square roots. - **Learn about [dynamic programming](dynamic_programming.md)**. - **Avoid branches (ifs)** if you can (remember [ternary operators](ternary_operator.md), loop conditions etc. are branches as well). They break prediction in CPU pipelines and instruction preloading and are often source of great performance losses. Don't forget that you can many times compare and use the result of operations without using any branching (e.g. `x = (y == 5) + 1;` instead of `x = (y == 5) ? 2 : 1;`). @@ -23,20 +24,20 @@ These are mainly for [C](c.md), but may be usable in other languages as well. - **Write [cache-friendly](cache-friendly.md) code** (minimize long jumps in memory). - **Compare to [0](zero.md) rather than other values**. There's usually an instruction that just checks the zero flag which is faster than loading and comparing two arbitrary numbers. - **Consider moving computation from run time to compile time**. E.g. if you make a resolution of your game constant (as opposed to a variable), the compiler will be able to partially precompute expressions with the display dimensions and so speed up your program (but you won't be able to dynamically change resolution). -- On some platforms such as ARM the first **arguments to a function may be passed via registers**, so it may be better to have fewer parameters in functions. -- **Optimize when you already have a working code**. As Donald Knuth put it: "premature optimization is the root of all evil". Nevertheless you should get used to simple nobrainer efficient patterns by default and just write them automatically. -- **Use your own caches where they help**, for example if you're frequently working with some database item you better pull it to memory and work with it there, then write it back once you're done (as opposed to communicating with the DB there and back). -- **[Single compilation unit](single_compilation_unit.md) (one big program without linking) can help compiler optimize better** because it can see the whole code at once, not just its parts. It will also make your program compile faster. +- On some platforms such as [ARM](arm.md) the first **arguments to a function may be passed via registers**, so it may be better to have fewer parameters in functions. +- **Optimize when you already have a working code**. As [Donald Knuth](knuth.md) put it: "premature optimization is the root of all evil". Nevertheless you should get used to simple nobrainer efficient patterns by default and just write them automatically. +- **Use your own [caches](cache.md) where they help**, for example if you're frequently working with some database item you better pull it to memory and work with it there, then write it back once you're done (as opposed to communicating with the DB there and back). +- **[Single compilation unit](single_compilation_unit.md) (one big program without [linking](linking.md)) can help compiler optimize better** because it can see the whole code at once, not just its parts. It will also make your program compile faster. - Search literature for **algorithms with better [complexity class](complexity_class.md)** (sorts are a nice example). -- For the sake of embedded platforms **avoid [floating point](floating_point.md)** as that is often painfully slowly emulated in software. Use [fixed point](fixed_point.md). -- **Early branching can create a speed up** (instead of branching inside the loop create two versions of the loop and branch in front of them). This is a kind of space-time tradeoff. +- For the sake of simple computers such as [embedded](embedded.md) platforms **avoid [floating point](floating_point.md)** as that is often painfully slowly emulated in software. Use [fixed point](fixed_point.md), or at least offer it as a [fallback](fallback.md). This also applies to other hardware requirements such as [GPU](gpu.md) or sound cards: while such hardware accelerates your program on computers that have the hardware, making use of it may lead to your program being slower on computers that lack it. +- **[Early branching](early_branching.md) can create a speed up** (instead of branching inside the loop create two versions of the loop and branch in front of them). This is a kind of space-time tradeoff. - **Reuse variable to save space**. A warning about this one: readability may suffer, mainstreamers will tell you you're going against "good practice", and some compilers may do this automatically anyway. Be sure to at least make this clear in your comments. Anyway, on a lower level and/or with dumber compilers you can just reuse variables that you used for something else rather than creating a new variable that takes additional RAM; the only prerequisite for "merging" variables is that the variables aren't used at the same time. -- **What's fast on one platform may be slow on another**. This depends on the instruction set as well as on compiler, operating system, quirks of the hardware and other details. You always need to test on the hardware itself. -- **You can optimize critical parts of code in [assembly](assembly.md)**, i.e. manually write the assembly code that takes most of the running time of the program, with as few and as inexpensive instructions as possible (but beware, popular compilers are very smart and it's often hard to beat them). But note that such code loses portability! So ALWAYS have a C (or whatever language you are using) [fallback](fallback.md) code for other platforms, use [ifdefs](ifdef.md) to switch to the fallback version on platforms running on different assembly languages. +- **What's fast on one platform may be slow on another**. This depends on the instruction set as well as on compiler, operating system, available hardware, [driver](driver.md) implementation and other details. In the end you always need to test on the specific platform to be sure about how fast it will run. +- **You can optimize critical parts of code in [assembly](assembly.md)**, i.e. manually write the assembly code that takes most of the running time of the program, with as few and as inexpensive instructions as possible (but beware, popular compilers are very smart and it's often hard to beat them). But note that such code loses [portability](portability.md)! So ALWAYS have a C (or whatever language you are using) [fallback](fallback.md) code for other platforms, use [ifdefs](ifdef.md) to switch to the fallback version on platforms running on different assembly languages. ## When To Actually Optimize? -Nubs often ask this. Generally fine, sophisticated optimization should come as one of the last steps in development, when you actually have a working thing. These are optimizations requiring significant energy/time to implement -- you don't want to spend resources on this at the stage when they may well be dropped in the end, or they won't matter because they'll be outside the bottleneck. However there are two "exceptions". +Nubs often ask this and this can also be a very nontrivial question. Generally fine, sophisticated optimization should come as one of the last steps in development, when you actually have a working thing. These are optimizations requiring significant energy/time to implement -- you don't want to spend resources on this at the stage when they may well be dropped in the end, or they won't matter because they'll be outside the bottleneck. However there are two "exceptions". The highest-level optimization is done as part of the initial design of the program, before any line of code gets written. This includes the choice of data structures and mathematical models you're going to be using, the very foundation around which you'll be building your castle. This happens in your head at the time you're forming an idea for a program, e.g. you're choosing between [server-client](server_client.md) or [P2P](p2p.md), [monolithic or micro kernel](kernel.md), [raytraced](ray_tracing.md) or [rasterized](rasterization.md) graphics etc. These choices affect greatly the performance of your program but can hardly be changed once the program is completed, so they need to be made beforehand. **This requires wide knowledge and experience** as you work by intuition. diff --git a/portability.md b/portability.md new file mode 100644 index 0000000..d94aca9 --- /dev/null +++ b/portability.md @@ -0,0 +1,159 @@ +# Portability + +Portable [software](software.md) is software that is easy to [port](port.md) to (make run on) other platforms. Platforms here mean anything that serves as an environment enabling software to run, i.e. [hardware](hardware.md) platforms ([CPUs](cpu.md), [ISAs](isa.md), game consoles, ...), different [operating systems](os.md) vs [bare metal](bare_metal.md), [fantasy consoles](fantasy_console.md) etc. **Portability is an extremely important attribute of [good software](lrs.md)** as it allows us to write the program once and then run it on many different computers with little effort -- without portability we'd be constantly busy rewriting old programs to run on new computers, portability allows us to free our programs from being tied to specific computers and exist abstractly and independently and so become [time proof](time_proof.md). Examples of highly portable programs include [Anarch](anarch.md), [Simon Tatham's Portable Puzzle Collection](stppc.md), [sbase](sbase.md) (suckless) implementation of Unix tools such as [cat](cat.md) and [cmp](cmp.md) etc. + +**Portability is different from mere [multiplatformness](multiplatform.md)**: multiplatform software simply runs on more than one platform without necessarily being designed with high portability in mind; portable software on the other hand possesses the inherent attribute of being designed so that very little effort is required to make it run on wide range of general platforms. Multiplatformness can be achieved cheaply by using a [bloated](bloat.md) framework such as the Godot engine or [QT](qt.md) framework, however that will not achieve portability; on the contrary it will hurt portability. Portability is achieved through good and careful design, efficient code and avoiding [dependencies](dependency.md) and [bloat](bloat.md). + +In connection to software the word *portable* also has one other meaning used mainly in context of [Windows](windows.md) programs: it is sometimes used for a binary executable program that can be run without installing (i.e. it can be carried around and ran from a USB drive etc.). However we'll stick to the previously defined meaning. + +## How To Make Portable Programs + +In short: use [abstraction](abstraction.md) to not get tied to any specific platform (separate [frontend](frontend.md) and [backend](backend.md)), minimize [dependencies](dependency.md) (minimize use of [libraries](library.md) and requiring hardware such as [floating point](float.md) unit or a [GPU](gpu.md), have [fallbacks](fallback.md)), write efficient, [simple](kiss.md) code (lower hardware demands will support more platforms), avoid platform-specific features (don't write in [assembly](assembly.md) as that's specific to each CPU, don't directly use [Linux](linux.md) [syscalls](syscall.md) as these are specific to Linux etc.). + +Remember, portability is about making it easy for a programmer to take your program and make it run elsewhere, so portability is about constantly putting oneself in the shoes of someone else with a very different computer and asking questions such as "how hard will it be to make this work if this library isn't available?". Even things that are supposed or commonly expected to be present on all platforms, such as a file system or a raster screen, may not be present on some computers -- always remember this. + +**Do NOT use big frameworks/engines** -- it is one of the greatest misconceptions among many programmers to think portable software is created with big frameworks, such as the [Godot](godot.md) engine, which can "single click" export/deploy software to different platforms. This will merely achieve creating a badly [bloated](bloat.md) multiplatform program that's completely dependent on the framework itself which drags along hundreds of [dependencies](dependency.md) and wastes computing resources (RAM, CPU, storage, ...) which are all factors directly contradicting portability. If you for example create a snake game in Godot, you won't be able to port it to [embedded](embedded.md) devices or devices without an operating system even though the snake game itself is simple enough to run on such devices -- the game drags along the whole Godot engine which is so huge, complex and hardware demanding that it prevents the simple game from running on simple hardware. + +**Always make your own thin [I/O](io.md) abstraction, [decouple](coupling.md) your I/O libraries, separate [frontend](frontend.md) and [backend](backend.md)**. This is one of the most basic and most important things to do. Why? Well unless you're writing a library, you will need to use I/O (write out messages, draw to screen, create [GUI](gui.md), read keyboard commands, read from files, read from network, ...) so you will NEED to use some library for this (C [stdlib](stdlib.md), [SDL](sdl.md), OS [syscalls](syscall.md), [Xlib](xlib.md), ...) but you absolutely DON'T WANT this library to become a hard [dependency](dependency.md) of your program because if your program depends let's say on SDL, you won't be able to make your program run on platforms that don't have SDL. So the situation is that you HAVE TO use some I/O library but you don't want to become dependent on it. + +The way to solve this is to create your own small I/O abstraction in your project, i.e. your own functions (such as `drawPixel`, `writeMessage`, `keyPressed`, `playSound`, `readFrile` etc.) for performing I/O, which you will use inside your main program. These functions will be defined in a small file which will basically be your own small I/O library just for your program. The functions you define there will then internally use functions of whatever underlying I/O system you choose to use at the time as your [frontend](frontend.md) (SDL, Xlib, SFML, ...); the important thing is that your main program code won't itself depend on the underlying system, it will only depend on your I/O abstraction, your own functions. Your custom I/O functions will depend on the underlying I/O system but in a way that's very easy to change -- let's say that your `keyPressed` function internally uses SDL's `SDL_GetKeyboardState` to read keyboard state. If you want to switch from using SDL to using a different frontend, you will only have to change the code in one place: in your I/O abstraction code, i.e. inside your `keyPressed` function. E.g. if you switch from SDL to SFML, you will just delete the code inside your `keyPressed` function and put in another code that uses SFML functions to read keyboard (e.g. the `isKeyPressed` attribute), and your whole code will instantly just work on SFML. In fact you can have multiple implementations of your functions and allow switching of different backends freely -- just as it is possible to compile a [C](c.md) program with any C compiler, you can make it possible to compile your program with any I/O frontend. If you used SDL's specific functions in your main code, you would have to completely rewrite your whole codebase if you wanted to switch away from SDL -- for this reason your main code must never directly touch the underlying I/O system, it must only do so through your I/O abstraction. Of course these principles may apply to any other thing that requires use of external libraries, not just I/O. + +This is all demonstrated by [LRS](lrs.md) programs such as [Anarch](anarch.md) or [SAF](saf.md), you can take a look at their code to see how it all works. + +Anyway the following is a simple [C](c.md) code to demonstrate the abstraction from an I/O system -- it draws a dithered rectangle to the screen and waits until the user pressed the `q` key, then ends. The main code is written independently of any I/O system and can use either C [stdlib](stdlib.md) (*stdio*, draws the rectangle to terminal with ASCII characters) or SDL2 (draws the rectangle to actual window) as its frontend -- of course more frontends (e.g. one using Xlib or SFML) can be added easily, this is left as an exercise :) + +``` +#define SCREEN_W 80 +#define SCREEN_H 30 + +// our I/O abstraction: +void ioInit(void); // init our I/O +void ioEnd(void); // destroy our I/O +void drawPixel(int x, int y, int white); +void showImage(void); +int isKeyPressed(char key); + +// our main program code: +int main(void) +{ + ioInit(); + + for (int y = 3; y < 20; ++y) // draw dithered rectangle + for (int x = 30; x < 60; ++x) + drawPixel(x,y,x % 2 == y % 2); + + showImage(); + + while (!isKeyPressed('q')); // wait for pressing 'q' + + ioEnd(); + + return 0; +} + +/*--------------------------------------------------- + implementation of our I/O abstraction for different + frontends: */ + +#ifdef FRONTEND_STDLIB // C stdio terminal frontend + #include + char screen[SCREEN_W * SCREEN_H]; + + void ioInit(void) + { + // clear screen: + for (int i = 0; i < SCREEN_W * SCREEN_H; ++i) + screen[i] = 0; + } + + void ioEnd(void) { } // nothing needed here + + void drawPixel(int x, int y, int white) + { + screen[y * SCREEN_W + x] = white != 0; + } + + void showImage(void) + { + for (int i = 0; i < SCREEN_W * SCREEN_H; ++i) + { + if (i % SCREEN_W == 0) + putchar('\n'); + + putchar(screen[i] ? '#' : '.'); + } + + putchar('\n'); + } + + int isKeyPressed(char key) + { + return getchar() == key; + } +#elif defined(FRONTEND_SDL) // SDL2 frontend + #include + unsigned char screen[SCREEN_W * SCREEN_H]; + SDL_Window *window; + SDL_Renderer *renderer; + SDL_Texture *texture; + + void ioInit(void) + { + for (int i = 0; i < SCREEN_W * SCREEN_H; ++i) + screen[i] = 0; + + SDL_Init(0); + + window = SDL_CreateWindow("sdl",SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED,SCREEN_W,SCREEN_H,SDL_WINDOW_SHOWN); + + renderer = SDL_CreateRenderer(window,-1,0); + + texture = SDL_CreateTexture(renderer,SDL_PIXELFORMAT_RGB332, + SDL_TEXTUREACCESS_STATIC,SCREEN_W,SCREEN_H); + } + + void ioEnd(void) + { + SDL_DestroyTexture(texture); + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + } + + void drawPixel(int x, int y, int white) + { + screen[y * SCREEN_W + x] = (white != 0) * 255; + } + + void showImage(void) + { + SDL_UpdateTexture(texture,NULL,screen,SCREEN_W); + + SDL_RenderClear(renderer); + SDL_RenderCopy(renderer,texture,NULL,NULL); + SDL_RenderPresent(renderer); + } + + int isKeyPressed(char key) + { + SDL_PumpEvents(); + const unsigned char *keyboard = SDL_GetKeyboardState(NULL); + + return keyboard[SDL_SCANCODE_A + (key - 'a')]; + } +#endif +``` + +If you compile this code as + +``` +gcc -DFRONTEND_STDLIB main.c +``` + +You'll get the stdlib version. If you compile it as + +``` +gcc -DFRONTEND_SDL -lSDL2 main.c +``` + +You'll get the SDL version. \ No newline at end of file diff --git a/prime.md b/prime.md index 78a6c26..fef268f 100644 --- a/prime.md +++ b/prime.md @@ -1,6 +1,6 @@ # Prime Number -Prime number (or just *prime*) is a [whole](integer.md) positive [number](number.md) only divisible by 1 and itself, except for the number [1](one.md). I.e. prime numbers are 2, 3, 5, 7, 11, 13, 17 etc. Prime numbers are extremely important, [interesting](interesting.md) and mysterious for their properties and distribution among other numbers, they have for millennia fascinated [mathematicians](math.md), nowadays they are studied in the math subfield called [number theory](number_theory.md). Primes are for example essential in [assymetric cryptography](assymetric_cryptography.md). +Prime number (or just *prime*) is a [whole](integer.md) positive [number](number.md) only divisible by 1 and itself, except for the number [1](one.md). I.e. prime numbers are 2, 3, 5, 7, 11, 13, 17 etc. Prime numbers are extremely important, [interesting](interesting.md) and mysterious for their properties and distribution among other numbers, they have for millennia fascinated [mathematicians](math.md), nowadays they are studied in the math subfield called [number theory](number_theory.md). Primes are for example essential in [assymetric cryptography](assymetric_cryptography.md). Primes can be seen as the opposite of [highly composite numbers](highly_composite_number.md) (also antiprimes, numbers that have more divisors than any lower number). The largest known prime number as of 2022 is 2^82589933 - 1 (it is so called [Mersenne prime](mersenne_prime.md), i.e. a prime of form 2^N - 1). diff --git a/wikipedia.md b/wikipedia.md index 865bfe3..ea2cd08 100644 --- a/wikipedia.md +++ b/wikipedia.md @@ -1,6 +1,6 @@ # Wikipedia -Wikipedia is a non-commercial, [free/open](free_culture.md) [online](www.md) encyclopedia written mostly by volunteers, running on [free software](free_software.md), allowing almost anyone to edit its content (i.e. being a [wiki](wiki.md)); it is the largest and perhaps most famous encyclopedia created to date. It is licensed under [CC-BY-SA](cc_by_sa.md) and is run by the nonprofit organization Wikimedia Foundation. It is accessible at https://wikipedia.org. +Wikipedia is a non-commercial, [free/open](free_culture.md) [pseudoleftist](pseudoleft.md) [online](www.md) encyclopedia written mostly by volunteers, running on [free software](free_software.md), allowing almost anyone to edit its content (i.e. being a [wiki](wiki.md)); it is the largest and perhaps most famous encyclopedia created to date. It is licensed under [CC-BY-SA](cc_by_sa.md) and is run by the [nonprofit](nonprofit.md) organization Wikimedia Foundation. It is accessible at https://wikipedia.org. Wikipedia exists in many (more than 200) versions differing mostly by the language used but also in other aspects; this includes e.g. Simple English Wikipedia or Wikipedia in [Esperanto](esperanto.md). In all versions combined there are over 50 million articles and over 100 million users. English Wikipedia is the largest with over 6 million articles. @@ -31,7 +31,8 @@ And the bad things are: - Wikipedia is **too popular** which has the negative side effect of becoming a **political battlefield**. This is one of the reasons why there has to be a lot of **bureaucracy**, including things such as **locking of articles** and the inability to edit everything. Even if an article can technically be edited by anyone, there are many times people watching and reverting changes on specific articles. So Wikipedia can't fully proclaim it can be "edited by anyone". - Wikipedia is **hard to read**. The articles go to great depth and mostly even simple topics are explained with a great deal of highly technical terms so that they can't be well understood by people outside the specific field, even if the topic could be explained simply (Simple English Wikipedia tries to fix this a little bit at least). Editors try to include as much information as possible which too often makes the main point of a topic drown in the blablabla. Wikipedia's style is also very formal and "not [fun](fun.md)" to read, which isn't bad in itself but it just is boring to read. Some alternative encyclopedias such as [Citizendium](citizendium.md) try to offer a more friendly reading style. - Wikipedia is **not [public domain](public_domain.md)**. It is licensed under [CC-BY-SA](cc_by_sa.md) which is a [free](free_culture.md) license, but has a few burdening conditions. We belive knowledge shouldn't be owned or burdened by any conditions. -- Even though there are no ads, there sometimes appears a **political propaganda** banner somewhere (international days of whatever, ...). Main page just **hard pushes [feminist](feminism.md) shit** as featured images and articles. +- Even though there are no ads, there regularly appears **political propaganda**, main page just **hard pushes [feminist](feminism.md) shit** as featured images and articles, there appear popups for LGBT/feminist activism, and of course all articles are littered with [pseudoleftist](pseudoleft.md) propaganda etc. +- Many articles are bought, there exist companies that offer editing and maintaining certain articles in a way the client desires and of course corporations and politicians take this opportunity -- of course Wikipedia somewhat tries to prevent it but no prevention ever works 100%, so a lot information on Wikipedia is either highly misleading, untrue, censored or downright fabricated. ## Fun And Interesting Pages