Added non-serious pages.
This commit is contained in:
		
							parent
							
								
									2da8caa35c
								
							
						
					
					
						commit
						a1b0f82c96
					
				
							
								
								
									
										
											BIN
										
									
								
								site/projects/img/magicng.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								site/projects/img/magicng.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 62 KiB | 
| @ -13,6 +13,7 @@ These are my projects, new and old. | ||||
| #++exec | ||||
| #+BEGIN_SRC python3 | ||||
|   top_projs = ( | ||||
|       'magicng', | ||||
|       'gravnoise', | ||||
|       'hbcht', | ||||
|       'mege', | ||||
|  | ||||
							
								
								
									
										290
									
								
								site/projects/magicng/index.org
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										290
									
								
								site/projects/magicng/index.org
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,290 @@ | ||||
| #+title: MagicNG | ||||
| #&summary | ||||
| The Next Generation Programming Language | ||||
| #& | ||||
| #+license: bysa | ||||
| #&toc | ||||
| 
 | ||||
| * Chapter 1: The Future of Yesterday | ||||
| 
 | ||||
| /Software./ | ||||
| 
 | ||||
| /Magic./ | ||||
| 
 | ||||
| Two seemingly unrelated words. Yet together they form the essentials of the new | ||||
| programming language that has already changed how computers and humans interact | ||||
| with each other: *MagicNG* (short for Magic: The Next Generation). | ||||
| 
 | ||||
| *MagicNG* is not your common programming language; it is not biased towards one | ||||
|  or two paradigms, in fact it uses none of the existing ways of programming: | ||||
| 
 | ||||
| + Functional programming is, naturally, much too functional for any magic-based | ||||
|   programming language, as magic is not /functional/, but | ||||
|   /magical/. Magic-based software do not require functionality as in something | ||||
|   being able to do something else, because it depends on magic which /does/ | ||||
|   stuff instead of making sure that /stuff/ can be done; this makes using the | ||||
|   computer much faster. | ||||
| + Object-oriented programming does not fit very well with the ideas behind | ||||
|   *MagicNG* either. While the magic-oriented approach /is/ able to properly | ||||
|   emulate object-oriented ways of doing things, such emulations will often | ||||
|   require {CMU&abbr='Central Magical Unit'}-expensive conversions from spell | ||||
|   scrolls to object-based representations. | ||||
| + Procedural programming conflicts with the nature of magic; since in the case | ||||
|   of magic, advanced heuristics are used run a program, the simple approach of | ||||
|   procedurally executing commands pales in comparison to the magical | ||||
|   approach. The same is true for assembly programming and machine programming. | ||||
| + Logic programming is mute. Magic is always above logic. Logic is based on | ||||
|   magic. Everyone knows that. | ||||
| + Declarative programming is actually the only one of the existing widespread | ||||
|   paradigms which is even slightly like *magical programming*. Declarative | ||||
|   programming languages do, however, still base their entire existence on | ||||
|   deduction and knowledge, both of which are infinitely long below the | ||||
|   standards of magical programming languages. Deduction and knowledge are for | ||||
|   programming languages that do not /see/ how everything works, whose authors | ||||
|   do not understand the connectionabilities of everything. | ||||
| 
 | ||||
| In short, *MagicNG* employs the *magical programming* paradigm because it is | ||||
| superior to non-magical approaches. | ||||
| 
 | ||||
| 
 | ||||
| ** But how do I program in it? | ||||
| 
 | ||||
| The reader should now be comfortable thinking about programming in terms of | ||||
| magic and be able to see what a big mistake it was to learn all those outdated, | ||||
| logic-based programming languages. The reader might also be a little | ||||
| overwhelmed and perhaps confused; but fear not, we will soon take a look at an | ||||
| example of MagicNG programming. | ||||
| 
 | ||||
| Before we get to that, we will go over a few (yes, there are many more) of the | ||||
| applications of magical programming, to pique the reader's curiosity. | ||||
| 
 | ||||
| 1. First, there is the temporal improvement. Since magic is independent of the | ||||
|    flow of time, a program can be run not just everywhere, but | ||||
|    every{/when/}. This is the sole reason MagicNG is already so popular --- | ||||
|    someone spread its use many years ago, through several temporal-offset | ||||
|    MagicNG runs. | ||||
| 2. Speed. The Central Magical Unit runs programs magically many times faster | ||||
|    than any CPU in existence. This is possible due both to the previously | ||||
|    explained effects of magic in programming /and/ what we will come to refer | ||||
|    as "magic downleveling" in later chapters (since magic cannot be optimized, | ||||
|    other approaches such as the downleveling approach have been developed). | ||||
| 3. Code maintenance also becomes much easier, as you will see in the examples | ||||
|    and excercises. | ||||
| 
 | ||||
| Now, to our first example. We wish to print to a computer console (on a magical | ||||
| computer) the magical string "Hello, world!". This is often accomplished in | ||||
| anything from 1 to 100 conventional lines in conventional programming | ||||
| languages; in MagicNG, it is not /that/ simple. It's another kind of simple, | ||||
| namely the /magic simple/ way, from now on referred to as the /magple/ way. | ||||
| 
 | ||||
| To write the magple MagicNG code for this example, we first fire up our MagicNG | ||||
| interactive interpreter: | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| MagicNG vX | ||||
| ? | ||||
| #+END_SRC | ||||
| 
 | ||||
| (MagicNG is not being developed because it relies on magic for updates, hence | ||||
| the 'X' version.) | ||||
| 
 | ||||
| (The correct way to program in MagicNG is to write on pergament scrolls, but | ||||
| for the beginner it is often easier to write the magical expressions on one's | ||||
| computer and then print afterwards.) | ||||
| 
 | ||||
| The =?= at the prompt means we can type something. Let us try typing the | ||||
| following: | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| ? one frog eye | ||||
| #+END_SRC | ||||
| 
 | ||||
| What this tells the MagicNG interpreter is that if /it is not the case/ that no | ||||
| frog eyes exist in the programmer's vicinity, it will print "Hello, | ||||
| world!". The frog-eye detection is only a formality, included in MagicNG to | ||||
| make the proofs of magical truth be magically true, and so the sentence can be | ||||
| excluded if the programmer wishes so. That is, you could write | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| t | ||||
| #+END_SRC | ||||
| 
 | ||||
| which is short for "one frog eye", and it would have the same effects. | ||||
| 
 | ||||
| MagicNG programs can be compiled (printed) to scrolls, which can then be used | ||||
| independently of a running magical computer. | ||||
| 
 | ||||
| (Trivia: This was in fact one of the major reasons why the text-based nature of | ||||
| MagicNG was chosen over the two other proposed ways of programming: speech and | ||||
| jumping. While speech had the advantage that it worked well for people who had | ||||
| difficulties writing, history had shown that the human memory was not a good | ||||
| place to store information not meant to be changed. And while jumping was good | ||||
| for people who were only good at jumping, it was too radical an approach for | ||||
| many of the language designers.) | ||||
| 
 | ||||
| Now, it may not be obvious to the casual non-magician why and how both "one | ||||
| frog eye" and "t" eventually prints "Hello, world!". In fact, these two | ||||
| expressions are not at all the only ways to print "Hello, world!" --- one can | ||||
| also write "traveller with seven legs", "spider queen", or something | ||||
| similar. The thing to remember is that it is /the intention/ that counts. If | ||||
| you /feel/ that the expression "bonsai of Norway" prints the sum of all | ||||
| prime numbers below 4012, then /that is what it does/. | ||||
| 
 | ||||
| In essence, MagicNG is an *intention-based programming language*. This might at | ||||
| first sound like all other programming languages: You have an intention on | ||||
| which you base your programming. The difference here is that the intention /is/ | ||||
| the programming and not just part of it. Once you have figured out what you | ||||
| want and written in down in your inner language, magic takes care of the boring | ||||
| stuff. | ||||
| 
 | ||||
| This has the side-effect that all magic is somewhat personal; a scroll written | ||||
| by an individual A might yield different results if used by an individual B | ||||
| with different intentions than A. | ||||
| 
 | ||||
| This means that MagicNG has *built-in encryption*. | ||||
| 
 | ||||
| At this point some might note that this is not good for interoperability. At | ||||
| the core of MagicNG, this is true. However, one extraordinary extension has | ||||
| been made to MagicNG that makes interoperability both possible and easy: | ||||
| MagicIS (short for Magic Intention Serializer). | ||||
| 
 | ||||
| MagicIS encodes your intention in a magical format, after which the intention | ||||
| is compiled along with your program. With MagicIS, a compiled program that | ||||
| prints "My name is Niels" might look like this (imagine it compiled on a | ||||
| scroll): | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| Holy oak of honey | ||||
| ,si:pmnin34_=UUe | ||||
| #+END_SRC | ||||
| 
 | ||||
| where the =,si:= part denotes the start of the serialized intention. | ||||
| 
 | ||||
| The MagicIS extension can be enabled on most MagicNG compilers with a | ||||
| command-line option. Note that it will need to be connected to your brain with | ||||
| a special magical interface to work. | ||||
| 
 | ||||
| 
 | ||||
| * Chapter 2: Real World Examples | ||||
| 
 | ||||
| "This is all very nice," you might think, "but what is it any good for?" | ||||
| 
 | ||||
| MagicNG can be used for everything a typical, non-magical language can be used | ||||
| for, the major differences being that MagicNG is per definition faster, better | ||||
| and easier to program in. This has been magically proven. | ||||
| 
 | ||||
| ** cat | ||||
| 
 | ||||
| Consider the UNIX =cat= program. If written in C (even if you look at the Plan | ||||
| 9 version), there are many lines of source code. If written in Python 3, there | ||||
| are 2 lines: | ||||
| 
 | ||||
| #+BEGIN_SRC python3 | ||||
| for line in open(filename): | ||||
|     print(line) | ||||
| #+END_SRC | ||||
| 
 | ||||
| If written in MagicNG, there is _one_ line (/and/ it is magical): | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| cauldron of candy | ||||
| #+END_SRC | ||||
| 
 | ||||
| (without MagicIS enabled.) | ||||
| 
 | ||||
| 
 | ||||
| ** Finding a value when a key is known | ||||
| 
 | ||||
| In a non-magical programming language, you could use a hash map. Or you could | ||||
| sort the elements by their keys and use binary search. Or you could look | ||||
| through every element one by one. | ||||
| 
 | ||||
| In MagicNG, no such algorithms are used; /magic/ finds the value. In fact, this | ||||
| reveals a large, fascinating and unavoidable part of MagicNG: it does not | ||||
| support algorithms. | ||||
| 
 | ||||
| "No algorithms? But how, then, can I program?" you think. The answer is simple, | ||||
| and it has been explained before, but to stress it one last time: /magic/. | ||||
| 
 | ||||
| This leads us to another important part of MagicNG: its use of the *black box | ||||
| model*. The /black box model/ has been revered all over the known universe for | ||||
| its unchangeability (it is absolute), unworsenability (since you cannot change | ||||
| it, you cannot make it worse), high suprise factor ("who knew my program could | ||||
| do /that/?!"), and lack of meaningful error messages (no errors, no worries). | ||||
| 
 | ||||
| 
 | ||||
| ** Calculating the sum of a list of numbers | ||||
| 
 | ||||
| In C: | ||||
| 
 | ||||
| #+BEGIN_SRC c | ||||
| int sum(int xs[], int xs_len) { | ||||
|   int fin_sum = 0; | ||||
|   int i; | ||||
|   for (i = 0; i < xs_len; i++) { | ||||
|     fin_sum += xs[i]; | ||||
|   } | ||||
|   return fin_sum; | ||||
| } | ||||
| 
 | ||||
| [...] | ||||
| 
 | ||||
| sum({1, 3, -2, 9}, 4); | ||||
| #+END_SRC | ||||
| 
 | ||||
| In Python: | ||||
| 
 | ||||
| #+BEGIN_SRC python3 | ||||
| sum([1, 3, -2, 9]) | ||||
| #+END_SRC | ||||
| 
 | ||||
| In MagicNG: | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| head of Macbeth | ||||
| #+END_SRC | ||||
| 
 | ||||
| 
 | ||||
| ** A flight simulator | ||||
| 
 | ||||
| Up until now, we have only looked at MagicNG programs spanning single | ||||
| lines. One can create a very powerful MagicNG program in one line, but | ||||
| sometimes it can be necessary to use two, or even three lines. | ||||
| 
 | ||||
| As a flight operator, you may wish to have a very durable and efficient 3D | ||||
| flight simulator; in MagicNG such a system can be written concisely in just | ||||
| three lines of magical code (four lines with MagicIS enabled). | ||||
| 
 | ||||
| #+BEGIN_SRC text | ||||
| dragon claw polished with golden mead | ||||
|   mead in cauldron | ||||
| tastebuds of 23 pigs | ||||
| ,si:3=)uUUn!2aa | ||||
| #+END_SRC | ||||
| 
 | ||||
| (Notice the indentation and the explicit number.) | ||||
| 
 | ||||
| 
 | ||||
| /[Chapters 3 through 88 have been excluded in this preview. Only members of | ||||
| the Magically Magical Magic Community (MMMC) have access to these chapters.]/ | ||||
| 
 | ||||
| 
 | ||||
| * Chapter 89: How to Learn More | ||||
| 
 | ||||
| To recap: MagicNG is an easy language to learn, since it not only does not | ||||
| require the user to learn about algorithms, data structures and related wastes | ||||
| of time, but actually discourages that; MagicNG encourages its users to /not | ||||
| think/ which /reduces errors/. | ||||
| 
 | ||||
| To expand your knowledge of MagicNG, both in theory and practice, do not look | ||||
| at the examples of other MagicNG programmers, unless you are *absolutely sure* | ||||
| that their intentions are the same as yours. You can of course deduce the | ||||
| intention from a MagicIS line, but then, if you wish to base a new program on | ||||
| the old program, you will have to convert that intention to your own along with | ||||
| the actual program, which can be tedious and very difficult (MagicNG is | ||||
| actually a very complex language). | ||||
| 
 | ||||
| What you should do is lean back in a comfy chair and look into nothingness and | ||||
| not strain your mind. That way, everything you need to know will come to you | ||||
| eventually. That's how this book was written. | ||||
| 
 | ||||
							
								
								
									
										22
									
								
								site/writings/number-bases.org
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								site/writings/number-bases.org
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| #+title: Number bases | ||||
| #&summary | ||||
| This is fairly serious. | ||||
| #& | ||||
| #+license: cc0 | ||||
| 
 | ||||
| | Base                  | Description                                        | | ||||
| |-----------------------+----------------------------------------------------| | ||||
| | u-nary                | the always true base                               | | ||||
| | bi-nary               | the somewhat true base                             | | ||||
| | tri-nary              | hipster binary ("binary is so mainstream")         | | ||||
| | revolutio-nary        | trinary instead of binary                          | | ||||
| | counterrevolutio-nary | binary                                             | | ||||
| | imagi-nary            | unary imagined to be useful                        | | ||||
| | visio-nary            | binary or trinary, depending on the person         | | ||||
| | statio-nary           | trinary or binary, depending on the person         | | ||||
| | ordi-nary             | base 10 ("this works, so why use something else?") | | ||||
| | extraordi-nary        | base 11                                            | | ||||
| | veteri-nary           | base 14 ("Tetra? Is that an animal?")              | | ||||
| | no-nary               | unary                                              | | ||||
| | u-r-i-nary            | binary (mind melt)                                 | | ||||
| | evolutio-nary         | base 60                                            | | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Niels Serup
						Niels Serup