The Web: Getting Started

For the purposes of this work "the web" describes the set of all documents encoded in such a way that they can be read with a web browser. This is not the "Internet", which is the set of all computers connected to one another in a network. The point for this work is that I don't really care how a device is connected to other devices, I care that a device can read and write a file in the format we're working on. When Geometron is run on existing commercial hardware(as opposed to future custom built systems or physical implementations) it is intended to be used in a web browser that adheres to all the standards set forth for those(which seem to be pretty much convergent on a single standard as of 2017).

The web, as defined above, then consists of three types of code, referred to as the "holy trinity" by some web developers, or just "html5", which is not in fact really html5 but a combination of the following:

  1. HTML5
  2. CSS
  3. JavaScript
HTML5 is the current version of html which stands for "hypertext markup language". "Hypertext" refers to the way that web documents have links in them which connect them to other documents, an idea that goes back to decades before the beginning of the Web, long before these other parts were built. A "markup language" is a way to convert the kind of things you can type with a keyboard like < i > italic < /i > to the actual thing you see on your screen like this italic.

In order to work with geometron you only need about a dozen commands to get started, all of which look like the italic form in the previous paragraph, with a tag in angle brackets and then an end tag also in angle brackets with a forward slash. This way of organizing information with angle brackets, slashes and tags, is part of a broader class of documents called eXtensible Markup Language, or XML. The way to start with HTML is to download and install a text editor with code capabilities such as textWrangler, which is the on I use, then copy and paste the code of a simple website into that, save it as something like "test.html", and open that file in your web browser(this file will be local on your harddrive and therefore not technically on the "Internet". You can then edit the text file, save it, re-load the browser and see the change.

Start with copy and pasting this into your text editor:

Do not forget to save the file with the ".html" ending, or it won't be recognized as html by the browser when you try to open it.

The second of the three main elements of the web is CSS, which stands for "cascaded style sheets". CSS is a whole language unto itself, which can exist in files that end with .css. These files are used by professional web developers to give a consistent and polished look to their professional work. That is not how it is used in Geometron, however. CSS can be and often is embedded inside html documents in the "<style>" tag. What it does is specify how all the html looks. Fonts, colors, margins, positions on the screen, etc. are all handled through CSS. The system incorporated in CSS allows for specific elements of the html document to be controlled, as well as types of element such as "paragraph" or "table", and classes, which can be defined by a class name.

CSS is a broad and deep subject, but for the purposes of Geometron we will just use some very basic pieces of it and define a class called a Geometron Atom. Now copy and paste the following code into "test.html".

Now you should see a document set up roughly like the pages of this book. Change the text, save, and reload the browser. You can now edit a decent looking document in HTML! With this, it's possible to put presentable publications on the Web with just a few simple html commands.

For both html and CSS, the way to move forward is to go through the tutorials and references found on https://www.w3schools.com. As much as I hate to recommend a for profit company for anything, this is by far the most useful free resource for the amateur like me and I will strongly recommend it over the alternatives.

The third leg of the tripod is javaScript. This language is not to be confused with Java, which is supposedly unrelated(even though to those of us who don't care about the pointless territory battles of "tech" they both look identical to C). javaScript is a C-like language that can run in an html document. It runs on your browser! This is why I introduced the idea of the "Riddle of Steel" in the previous chapter. What matters in computer languages is only one thing: how many people does the thing talk to? And the web browser is the most powerful by many orders of magnitude.

Just as CSS code goes inside a "<style>" tag and can be in a .css file, JavaScript code can be inside a "<script>" tag or in a .js file. And just as we exclusively avoid external .css files in Geometron we mostly do the same with javascript. It is commonplace to put something like Geometron in a "library" file, an external .js file with all the needed JavaScript functions, and it would in many ways be more convenient to do this. However, this would contradict the goal of having each instance of Geometron be totally customizable and independent. External code libraries lead to central control which has political and philosophical implications. Therefore the core library functions of Geometron are always included in the html document which is referencing them. This is part of the process by which the language evolves.

The one exception to the no-external-libraries rule is the mathjax.js library. This allows for math to be typeset using commands from LaTeX, another markup language, older than the Web, which is designed specifically for typesetting mathematical documents. LaTeX is already very widely used in the physical sciences, so this is largely for those who are already comfortable with LaTeX and mathematics. If you need to create documents with very intense theoretical math, you very likely already know LaTeX, and if you don't, you don't need it. The Mathjax library appears to have a stable not-for-profit system of updating and maintaining their code which leads me to believe that trusting it for long term projects is safe. At least for now.

What you need to learn in JavaScript to do Geometron:

  1. for loops
  2. functions
  3. arrays
  4. parsing strings
  5. interacting with the DOM
  6. basics of "math" object
  7. basic syntax(using semicolons, comments etc.)

Hopefully it should be possible for amateurs to quickly learn just these things, use them to learn Geometron, and then work mostly in Geometron in the future. Some users will also inevitably delve much deeper into the language and use all of it to improve Geometron, but it is the goal to have the minimum needed JavaScript to edit the core library be something that can be learned in just a few days, and easily and quickly looked up again when forgotten. There should also be a reference in the Geometronsphere that has a list of examples of key things used.

Other Resources

Aside from the three legged stool describe above of HTML, CSS and JavaScript, there are several extremely useful pieces of modern computer software which we will use to build out some of the Geometron instances. These include:

Initialization and Global Variables

According to the Technocratic Priesthood, use of global variables is not part of "best practices". One of the ways I anticipate useless noise to be generated from the "tech" scammers after publication of this work is that they will whine about the fact that Geometron is driven entirely by the use of global variables. I claim that as with most of the things engineers and their collaborators say, that this is not a fact of what can or should be done but is in fact 100% about social control and protection of "property" rights, which are essential to the continued political dominance of the techno priest class.

Since I regard all techno priests as the class enemy of this work, I do not take this seriously. They want you to follow "security protocols" to make things work with large numbers of random scripts all being run at the same time, which might overlap and break each other. This has nothing to do with your functions or your freedom, it's about their(the technocratic enemy) ability to all control you without interfering with the other technocrats who are also trying to control you.

"Best practices[to use the Enemy's language]" in Geometron involve always having all scripts embedded in the html, with no outside scripts other than mathjax, and that only for mathematical work. Our goal is to not just have variables be global in the browser instance you happen to be running at this time, but to have names that follow the code into many future mutations and specific applications. The property-worshipper needs local variables to protect their right to live in a overpriced highrise where your place used to be after the condo developers bulldozed it. We will use global variables to attempt to fight their world and their values.

Geometron can be thought of as a virtual processor, which carries out operations on the global variables, just as a physical processor does things to registers and the accumulator(at least on the 6502).

Functions

There are several helper functions which would normally be put in a library but which we'll always include at the beginning of a Geometron html file in the "head" element of the document. They mostly convert information from one type to another. I will go through them and discuss what each one does here.

commaCleaner

//remove extra commas from glyph:
function commaCleaner(dirtyGlyph){ 
	var dirtyArray = dirtyGlyph.split(",");
	var cleanGlyph = "";
	for(var index = 0;index < dirtyArray.length;index++){
		if(dirtyArray[index] != ""){
			cleanGlyph += dirtyArray[index] + ",";
		}
	}
	return cleanGlyph;
}

drawGlyph

spellGlyph

byteCode2string

string2byteCode

localRoot

appendGlyphButton

doTheThing()

The function that actually does all the operations of Geometron is called doTheThing(). It generally acts on an integer, which is generally passed in base 8, and returns nothing. In processing or Arduino it is therefore defined with a "void" statement. The one integer argument is always called "localCommand"(note the Camel case here as in most names we use). It's important to keep that core nomenclature the same so that parts of the function can by copy and pasted easily from one Geometron instance to another. A very basic doTheThing() function might look like this:
function doTheThing(localCommand){
    if(localCommand == 0300){
      x = x0;
      y = y0;
      theta = theta0;
      side = unit;
      thetaStep = Math.PI/2;
      scaleFactor = 2;
      ctx.lineWidth = 2;
      ctx.strokeStyle="black";
      ctx.fillStyle="black";
    }
    if(localCommand == 0304){
      thetaStep = Math.PI/2;
    }
    if(localCommand == 0305){
      thetaStep = 2*Math.PI/5;
    }
    if(localCommand == 0306){
      thetaStep = Math.PI/3;
    }    
    if(localCommand == 0310){
       scaleFactor = Math.sqrt(2); 
    }
    if(localCommand == 0311){
       scaleFactor = phi; //"golden" ratio 
    }
    if(localCommand == 0312){
       scaleFactor = Math.sqrt(3); 
    }
    if(localCommand == 0313){
      scaleFactor = 2;  //2x
    }
    if(localCommand == 0314){
      scaleFactor = 3;  //3x
    }
    if(localCommand == 0315){
      scaleFactor = 3.14159;  //pi*
    }    
    if(localCommand == 0316){
      scaleFactor = 5;  //5*
    }        
    if(localCommand == 0317){
       side = unit; 
    }
    if(localCommand == 0330){
      x += side*Math.cos(theta);   
      y += side*Math.sin(theta); 
    }
    if(localCommand == 0331){
      x -= side*Math.cos(theta);   
      y -= side*Math.sin(theta); 
    }
    if(localCommand == 0332){
      x += side*Math.cos(theta - thetaStep);
      y += side*Math.sin(theta - thetaStep);
    }
    if(localCommand == 0333){
      x += side*Math.cos(theta + thetaStep);
      y += side*Math.sin(theta + thetaStep);
    }
    if(localCommand == 0334){
      theta -= thetaStep; // CCW
    }
    if(localCommand == 0335){
      theta += thetaStep; // CW
    }
    if(localCommand == 0336){
      side /= scaleFactor; // -
    }
    if(localCommand == 0337){
      side *= scaleFactor; // +
    }
    if(localCommand == 0340){  //point
		ctx.beginPath();
		ctx.arc(x, y, 3, 0, 2 * Math.PI);
		ctx.fill();	
		ctx.closePath();
    }
    if(localCommand == 0341){  //circle
		ctx.beginPath();
		ctx.arc(x, y, side, 0, 2 * Math.PI);
		ctx.closePath();
		ctx.stroke();
    }
    if(localCommand == 0342){   //line
    	ctx.beginPath();
    	ctx.moveTo(x,y);
		ctx.lineTo(x + side*Math.cos(theta),y + side*Math.sin(theta));
		ctx.stroke();		
   		ctx.closePath();   		
    }
    if(localCommand == 0343){
    	ctx.beginPath();
		ctx.arc(x, y, side, theta - thetaStep,theta + thetaStep);
		ctx.stroke();
		ctx.closePath();
    }
}
Now is a good time to use your browser to read the source of this document and the previous chapters and future chapters to see how doTheThing changes for various instances of Geometron.

Build a Full Geometron Document and Edit it

This is it! You will now build a full document yourself in Geometron using basic web tools. You will use github to put it on the web, and will in the end of this section have a document that is readable by several billion internet enabled devices using any standard browser! Geometron aims to seize the means of production for the web, and that should be accomplished in this section, and until it is, I will re-write this over and over and add things as needed based on trying this on people. While I reference above to the w3schools website for learning basic web stuff, this section will attempt to be self-contained, and have the core pieces documented right here which you need to make and edit a working document.

things