I, like many other programmers, first learned to write computer code with some variation of BASIC. To be precise - I wrote my first programs in TI-Basic during algebra class and then graduated onto Visual Basic my freshman year of high school. I found QBASIC somewhere in the midst of that before moving onto Python.
It's weird to me that a lot people learn what I believe to be much harder programming languages. JavaScript, while ubiquitous, has at least 4 ways to make a new function and as many ways to define a new variable. Bring in pattern-matching, and suddenly it's tough to keep track of all the braces.
So, I'd like to bring BASIC back (though, to be fair, it never actually left).
https://github.com/jdan/basic2020
FUNCTION factorial(N)
IF N = 1
RETURN 1
ELSE
RETURN N * factorial (N - 1)
END
END
PRINT(FACTORIAL(20))
I want a language with incredibly Simple syntax and the ability to quickly and natively create Command-line programs, Drawing programs and Web programs.
Later on, I want to allow others to make different types of program templates (for things outside of command-line and web that I haven't thought about!) and Editor integrations.
The complete grammar can be found on GitHub
X <- 10
Y <- X + 5
IF X - Y > 0
MAX <- X
ELSE
MAX <- Y
END
FUNCTION factorial(N)
IF N = 1
RETURN 1
ELSE
RETURN N * factorial (N - 1)
END
END
The Preamble with contain:
COMMAND LINE PROGRAM
PRINT "Hello, world!"
X <- INPUT
Y <- INPUT "Enter your age:"
MENU [
"Enter a new student" ENTER_STUDENT
"Change a student" MODIFY_STUDENT
"Help" DISPLAY_HELP
]
I've begun adding syntax highlighting
But... wow this is hard stuff.
{
"match": "\\b([A-Za-z][A-Za-z0-9\\$_]*)\\s*(<-)",
"captures": {
"0": {
"name": "variable.basic2020"
},
"1": {
"name": "keyword.operator.assignment.basic2020"
}
}
}
I've been using Microsoft's JavaScript.tmLanguage as inspiration and it is hard to comprehend that this is the best way to do this.