Ocelot

  A Symbol-Based Programming Environment





1. 

"What are the advantages of 

programming with symbols?"



Programming with symbols is far less draining on the programmer.  This is possible when a custom keyboard and code editor work in tandem.



Regular programming languages use an alphanumeric keyboard for code, just like anything else that is done on the computer.


This lack of specialization has some costs.  Since every character of every command is typed out individually, the modern code editor tries to reduce the amount of typing needed by the programmer by providing guesses (called code completion).


By contrast, we use a custom 48-key symbol keyboard, with each key dedicated to an individual symbol or a group of symbols.  A given symbol can serve a wide range of functionality, too, and not just stand in for a single occurrence of its stated function or purpose.  This type of code, multi-faceted, reduces overall dependence on alphanumeric code completion.


Screen Shot 2017-12-15 at 11.31.35 PM.png



We combine the use of this custom keyboard with a symbol-based code editor (tailored all-around to symbol-based, interactive code).   It takes input from both the symbol keyboard and the programmer's regular, alphanumeric keyboard he uses already.  That is, the normal keyboard is still utilized in the editing of code.



This combination of keyboard input allows the insertion of a desired symbol within 1-5 key strokes.  The typing demands for an equivalent move in alphanumeric keys in regular programming languages often require a dozen or more key strokes, even with code completion.  For example:


To remove the object at index 4 of a list:


Compare typing

 
⍀4 vs.  removeObjectAtIndex(4)

(2 keys vs. 23 keys)



To replace the object at index 9 of a list with another object:


Compare typing

  ⎄ 9 text_for_field   vs.   replaceObjectAtIndexWithObject(4,text_for_field)

(3 keys + variable name vs. 35 keys + variable name).



A programmer's effort is then focused on the right areas within the code editor, instead of being taxed by typing out each character of a standard routine ("remove," in this case).  Surely, all programmers can agree that when typing "removeAtIndex:" and "removeAllObjects" there is a feeling of unnecessary duplication in code syntax.  The word "remove" can actually be summarized by a single character, , for any variety of situations.


When many standard functions have individual symbols to represent them, the number of human errors is reduced because their construction in type is not dependent on laborious typing activity.




2. 

"Why would I bother to learn a 

new system based on symbols?"



When keyboard input hardware and code editor software work in tandem to produce a new programming environment, the programmer's adoption of symbols is smoother than transitioning to another programming language.



The editor can display the written meaning above each symbol for a person becoming familiar with the symbolic code.  Meanwhile, symbols are pictographic and it is possible to explain why they resemble what they do.



More importantly, the opportunity to provide a new type of code, written through a custom code editor, has allowed for some design improvements in the layout of programmatic code itself, to provide an escape from old vexations left over from decades ago.


In this programming environment background colors are an integral part of programming. 


Background color serves to demarcate the boundaries of a given code area as well as indicate its function.  


Demarcating code areas by background color means that: 


There are significantly fewer instances when a programmer needs to track starting and terminating characters (curly braces, parentheses) or monitor their indentation.  

Curly braces are not used to indicate the beginning or end of a code block anymore and this cleans up the overall appearance of code.




Background Colors Currently Used By Ocelot:


code function grouping

code background color for category

example functions for grouping

orange

modify an object


                  

example usage: (add symbol)     

add, remove, insert, reduce, replace [something] in an object.

navy blue

access a property

                 

example usage: (first object symbol)    

first object, last object, object count, object at index, column at index, row at index, "does this object contain" a certain object.

bright yellow

provide a code area to operate within loops and generated schemes.



0…100.5



current loop index, object at current loop index.

purple-pink

provide a code area to evaluate one or more conditional expressions (if-else and switch equivalent)



    



"if true, then," "if not true, then", "case [followed by expression]"

pea green

provide an area for conditional expressions (placed inside purple-pink area alongside other symbols).


>3 or < 10

greater than, less than, equal to, not equal to.  note: "or" is spelled out instead of being made symbolic, just like "and".

medium-dark gray

provide a code workspace area, appended to an object, to work on that particular object.

     



"this object" referenced inside the area, alongside any other relevant symbols.

medium-dark green

synthetic constructor: construct an object from two objects of a different type.  (example: two point objects separated by the line class symbol form a line object).


   p1       p2 

takes two arguments: the objects of the class that can form a second type of object.



On top of using background colors, Ocelot requires the display of a symbol prefixe before any variable, object, or function.


In a regular programming language, a variable's type is often unknown just by looking at it (bowlingballs could be an object of any class , a string, an integer, etc.) , requiring further investigation.  


This leads programmers to name variables and objects after classes (e.g. an object of class array has name array_of_bowlingballs).  

But in this symbol-based programming language, variables and objects are made to have their type symbol (  for a point object, for example) stand in front of them at any time.  


In other words, any time a point object named a is referenced, it must be prefixed by its type symbol (crosshairs) like the following:     a .  The gray background area designates the name of the variable.


Thus, in any situation, it is known what is being referred to in the code editor.



3. 

"What do the symbols provide besides typographic shorthand?"




A symbol is useful across multiple contexts.


The action of a symbol changes when a different background color is placed behind it.



-   - accesses the first object in a list while    inserts an object at the beginning




The same symbol can work for varied functionality



-    (union) is an operation that can be used to say multiple types of commands:

- "make a union of two lists", to produce a resultant array. 

- "make a union of two rectangle areas" to produce a resultant bounding rectangle. 

- "make a combinatoric union of two bezier paths" to produce a resultant bezier path.



- ⍀3 (remove at index 3) is an operation that can be used to say multiple commands as well:


- "delete the 3rd object in a list (array)"

- "delete the 3rd character in a string"



  -  (contains) can be used to say:


- "does the list contain [this number or object]?" 

      - "does the image contain [this pixel of a certain color]?" 

      - "does the rectangle contain [this point]?"

      - "does the rectangle contain [this rectangle]?"

      - "does the range contain [this number]?"



Modifiers extend the symbol's range of purpose:


We saw earlier that ⍀3 removes the first element in an list.


 🂓3  removes the table column (🂓 symbol) with index 3 on a table


 ⍀⍀🂓3🁡30 deletes the contents of the table cell located at 3:30.



A given set of symbols can be used across different specialties.


The symbols that interact with tables (e.g. a spreadsheet) are also capable of modifying and querying databases and their tables.

The symbols that interact with servers are capable of interacting with many types of servers (FTP, HTTP, etc.)



Symbols provide more syntactical opportunities in the design of programming languages



Functions that would not be considered for a regular programming languages are sometimes apparent in symbolic code.



-    (transpose values) is an operation for flipping values between any two objects of the same type, such as a number, string, or color.



Constructors can exist as operators.



-    p1       p2  produces a line object from two points, using line data type symbol as construction operator.


-    A  #∠     B  produces an angle object that will contain the degrees between two points, using angle data type symbol as construction operator.




Syntax and typographic errors are largely reduced because the context is always known by the editor


In an alphanumeric programming language, the code editor does not know what should be permitted most of the time because the person programming is typing every name out.  But since this symbol-based programming language is interlinked with the code editor:


Every next potential step of the programmer is known, including what input types are allowable, preventing incorrect input and this is known at almost any time.


The code editor enforces lowercase transformations of all alphanumeric input for object and function names.  This means no camelcase accidents— a significant source of typographic errors.  


Object and function names are all lowercase and they use underscores as separation between words.   There is no need to type "shift + -"  to get an underscore : pressing the spacebar converts spaces to underscores automatically while a person is naming a variable or function.  As mentioned, the moment a variable is being named is known by the editor.




The typing of symbols is not all there is to the Ocelot symbol-based programming environment



Many types of graphical controls are permitted inside the code, for situations like defining by literal syntax.  For example, object collections, like lists or dictionaries, can be defined within graphical tables, within the code, via elements that allow the adding and removal of rows via keyboard commands, without using the mouse to click into individual cells or components.


This is much easier to use than any list or dictionary syntax of any programming language.  Actual graphical tables can be inserted into code and the values entered into the table and these can act as the literal values for a table object, which is later manipulated in the code.


Decision-trees, also with interface options to add and remove nodes, can stand in where syntax would be if a person opts to do so.

A common code phenomenon is the need to type multiple lines consecutively that are just setting a group of various property values of a particular object, often immediately after the object was initialized.  A table inserted into the code, which can add or remove rows of properties for configuration as needed through button controls, can accomplish the same tasks of these lines of code and it can allow expressions in its cells at the same time, allowing variable names previously declared in code to be referenced in the table.


A toolbar on the top functions in a similar way to a spreadsheet program's toolbar, providing a myriad of tool options, provided contextually, based on where the editor's cursor is in the code.  The toolbar informs the person as to what is possible and provides options not necessarily programmed into the custom keyboard, either because they are more unusual or the person decided to leave them off on purpose.