PREMISE: GLOBOL is a fantastic language that takes advantage of global variables.
> GLOBOL takes the hassle and confusion out of figuring out scope. No longer need you ask "Which NUMBEROFPICKLES am I looking at right now?"
> GLOBOL avoids case sensitivity issues by ensuring that EVERYTHING IS ALWAYS IN UPPER CASE, and disallows such confusing punctuation as underscores in variable names. This makes variables more clear and prevents the inevitable bug caused by a slight misspelling.
> GLOBOL is dynamically typed, preventing wasted programmer time by typing silly things like "int x;"
> GLOBOL implements pure, system level multithreading to effectively parallelize any task. Threads can run on multiple cores or even multiple servers with ease.
> GLOBOL provides a rich API, allowing a great number of functions to be used without mucking about in "import" statements. Chances are someone wrote the function you want already.
> GLOBOL makes networked programming as easy and natural as anything else.
> GLOBOL code resembles natural language, so can be understood by programmers and non-programmers alike.
> GLOBOL strongly discourages "reinventing the wheel". No function ever needs to be written twice!
> GLOBOL prevents the use of difficult to understand practices, such as recursion, functional programming, or regular expressions.
> GLOBOL uses integers that are almost impossible to mistype for a different number, causing hours of confusion in debugging.
> GLOBOL avoids the use of parenthesis, requiring special software to match them and avoid confusion.
In essence, GLOBOL is roughly what you'd get if you mated the syntax of COBOL with a little bit of Python and forced all variables to be global. I do mean global in the sense that there is (almost) no sense of scope the values are stored on a server somewhere and everyone uses the same pool of variables. If I define COUNTER to be 7, then someone in China decides COUNTER should equal TRUE, the next time I read the value of COUNTER, it will be TRUE.
And now, some actual syntax:
General Syntax Rules
GLOBOL uses Python style indentation.
GLOBOL programs MUST NOT contain lowercase letters AT ALL - not in comments, not in string literals.
Comments
Comments begin with one of the following phrases:
- Code: Select all
DID I EVER TELL YOU
IGNORE THIS NEXT PART
SO ANYWAY,
YOU KNOW,
BY THE WAY,
OF COURSE,
INTERESTINGLY ENOUGH,
ERGO
Comments are mostly ignored but MUST FOLLOW the indentation rules. In addition, lines can be indented "children" of comments to make themselves comments.
Variables
Variable names consist of a string containing only UPPERCASE CHARACTERS - no lowercase, no spaces, no underscores.
Variable names must be more than one character long (because those are references)
Variable names cannot be reserved words
Variables are dynamically typed, and can be of any of the following types:
Null
Boolean
Integer
Float
String
Function definition
Variables are evaluated the moment they are seen. Their values are also not cached: the global repository is checked each time the variable is seen. Thus, it is possible for the value of
- Code: Select all
ADD MYVARIABLE TO MYVARIABLE
to be an odd number.
Literals
Null literals are declared with BLANK, CLEAR, NOTHIN, or ZILCH. There is no difference between these words whatsoever.
Boolean literals are declared with YES, YUP, NO, NOPE, or MAYBE. YES and YUP evaluate as true, NO and NOPE evaluate to false, and MAYBE evaluates to true or false randomly when it is encountered by the parser.
Integer literals can be declared as a sequence of digits, like
- Code: Select all
ONE TWO THREE FOUR FIVE SIX SEVEN
or can be declared with natural English phrases:
- Code: Select all
ONE MILLION TWO HUNDRED THIRTY FOUR THOUSAND FIVE HUNDRED SIXTY SEVEN
The understood words are:
ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN ELEVEN TWELVE THIRTEEN FOURTEEN FIFTEEN SIXTEEN SEVENTEEN EIGHTEEN NINETEEN TWENTY THIRTY FORTY FIFTY SIXTY SEVENTY EIGHTY NINETY HUNDRED THOUSAND MILLION BILLION TRILLION
Similarly, floating point numbers must be declared as a sequence of digits with the addition of the word POINT:
- Code: Select all
THREE POINT ONE FOUR ONE FIVE NINE TWO SIX FIVE THREE FIVE NINE
String literals go between beautiful ASCII art quote marks.
- Code: Select all
``HELLO WORLD''
Escape characters cannot be used to avoid confusion.
Assignment
Variables are assigned with the IS NOW operator:
- Code: Select all
NUMBEROFPICKLES IS NOW SEVENTEEN
Assignments must be used as their own statements and cannot be part of larger expressions
- Code: Select all
THEULTIMATEANSWER IS NOW MULTIPLY SIX BY NINE
- Code: Select all
BARK THEULTIMATEANSWER IS NOW FORTY TWO
Comparison
There are three comparison operators:
- Code: Select all
EXPRESSIONONE IS LIKE EXPRESSIONTWO
- Code: Select all
EXPRESSIONONE IS EXPRESSIONTWO
- Code: Select all
EXPRESSIONONE IS BIGGER THAN EXPRESSIONTWO
Flow Control
- Code: Select all
IF EXPRESSION
DO STUFF
CONTINUE DOING STUFF
IF EXPRESSION
DO STUFF
OTHERWISE
DO MORE STUFF
AS LONG AS EXPRESSION
DO STUFF
These examples do roughly what you think they do. AS LONG AS is how you say WHILE and OTHERWISE is ELSE. Expressions are evaluated to booleans according to the following rules:
Null - false
Booleans - their value
Numbers - true if not zero
Strings - true if not the empty string
Functions - true
Function Calls
Functions are meant to appear as close to natural English as possible.
- Code: Select all
FUNCTION ARGUMENT SEPARATOR ARGUMENT SEPARATOR ARGUMENT SEPARATOR ARGUMENT
All functions must have at least one argument. This is a consequence of the following:
There are no parenthesis or anything to indicate association, so the innermost function will take all arguments after it. This puts a damper on functional programming for people who try to escape the clutches of global scope.
There is also no "order of operations".
FUNCTION is any variable name or builtin function name. It is an error to call a variable that is not of type function declaration.
SEPARATOR is any of:
- Code: Select all
AND OR WITH BY TO FROM ,
Different separators serve no purpose.
All of the following examples evaluate to 17:
- Code: Select all
ADD FOUR AND THIRTEEN
ADD TWO, TWO, THREE AND TEN
ADD SEVEN AND MULTIPLY FIVE BY TWO
MULTIPLY SEVENTEEN BY SUBTRACT TWO FROM THREE
The following built in functions are available:
For numbers
ADD (two or more arguments)
(X+Y)
SUBTRACT X FROM Y
(Y-X)
MULTIPLY (two or more arguments)
(X*Y)
DIVIDE X BY Y
(X/Y)
Arguments are converted to strings
ADD (two or more arguments)
(X+Y) (concatenation)
BARK (one or more arguments)
STDOUT.println (concatenates arguments)
SQUEAK (one or more arguments)
STDOUT.print (concatenates arguments)
SQUEAL (one or more arguments)
STDERR.println (concatenates arguments)
Arguments are converted to booleans
BOTH (two or more arguments)
(X&&Y)
EITHER (two or more arguments)
(X||Y)
NOT X
(!X)
It is an error to call a function with the wrong number of arguments.
References
References are the one exception to the rule of global scope. They are used in function definitions to stand in for the arguments. Each is represented by a single upper case letter, so there are only TWENTY SIX of them. They are set by calling the function and local to that function definition body. They are also constant, so you can't use them to change variable names.
Function Definition
- Code: Select all
HOW TO FUNCTION ARGUMENT SEPARATOR ARGUMENT
DO STUFF
THE ANSWER IS WHATEVER
ARGUMENTs must be references, and SEPARATORs are the same as for function calls.
There must be at least one argument
FUNCTION is the name of the function.
THE ANSWER IS is the return statement.
- Code: Select all
HOW TO SQUARE X
THE ANSWER IS MULTIPLY X BY X
HOW TO AVERAGE X AND Y AND Z
HOPEFULLYUNIQUELYNAMEDSUMVARIABLE IS NOW ADD X, Y AND Z
THE ANSWER IS DIVIDE HOPEFULLYUNIQUELYNAMEDSUMVARIABLE BY THREE
Exceptions
- Code: Select all
I CAN'T HEAR YOU (Used a lowercase character)
WHERE'S MY MOMMY? (Network error)
THAT MAKES NO SENSE (Generic syntax error)
I FORGET (Out of memory error)
I CAN'T DO THAT TO THAT (Type error)
STOP VERBING NOUNS (Called a non-function variable as a function)
THIS ISN'T LISP (Tried to use parenthesis)
WHY ARE YOU USING RECURSION? (Stack overflow)
YOU FAIL AT MATH (Division by zero)
TOO MUCH INFORMATION (Too many arguments)
NOT ENOUGH INFO (Too few arguments)
Exception handling
HA HAHAAA HA HA HAAA HA HA HAHAHAHAAAHAHAHAHAAAHAHAHAA HAHAAAHAHAAAAHAHAHAAHAHAHAAAAHAHAHAHAHAA...
no. Any error halts the program.
Examples
- Code: Select all
DID I EVER TELL YOU HOW TO USE THIS LANGUAGE?
I SUPPOSE I DIDN'T. WELL, HERE ARE SOME EXAMPLES
OF HOW TO USE THE LANGUAGE. DON'T ACTUALLY RUN
THIS FILE, THOUGH. IT CONTAINS TWO INFINITE
LOOPS AND WON'T GET VERY FAR. ALSO, IT WILL
TROLL ANYONE TRYING TO USE THE SQUARE FUNCTION.
YOU DON'T WANT TO DO THAT, DO YOU? ANYWAY,
MOVING SWIFTLY ALONG...
HELLOWORLD IS NOW ``HELLO WORLD''
BARK HELLOWORLD
BY THE WAY, IT'S POSSIBLE AND/OR VERY LIKELY
THAT THEULTIMATEANSWER WOULD BE
42 BY THE TIME IT WAS PRINTED
THEULTIMATEANSWER IS NOW MULTIPLY SIX BY NINE
AND THEN BARK ADD ``THE ULTIMATE ANSWER TO LIFE, THE UNIVERSE, AND EVERYTHING IS '' TO THEULTIMATEANSWER
YOU KNOW, THIS IS HOW YOU WOULD TROLL PEOPLE
WHILE YES
HOW TO SQUARE X
BARK ``U MAD ?''
THE ANSWER IS ``JOHN MADDEN''
BARK ``THEY MAD''
BY THE WAY, THIS IS HOW YOU WOULD DEFINE IT CORRECTLY
HOW TO SQUARE X
THE ANSWER IS MULTIPLY X BY X
OF COURSE, THIS MIGHT TROLL PEOPLE MORE
WHILE YES
SQUARE IS NOW ``JOHN MADDEN''
INTERESTINGLY ENOUGH, THIS CODE DOES SOMETHING
WHILE YES
FOOISARESERVEDWORD IS NOW FOOISARESERVEDWORD
