So I read a post over at Jason J. Gullickson’s blog about how FOSS Isn’t Capitalism. It’s an interesting quick history of how computers have becoming far less empowering to end users and how the Free and Open Source Software movement is repeating (intentionally or not) some of the same behaviors that commercial ventures engaged in to make computers (and the web) that way.
One thing the article calls for is putting some engineering time into making programming more accessible again, so that people can make their own solutions to their computing needs rather than relying on commercial software that they might not even have access to. It mentions BASIC as a form of this, but says there’s no modern programming language that does the same thing, a statement I agree with.
Our current programming tools aren’t accessible to anyone who isn’t already very comfortable with computers, and who are able to deal with learning complex, unnatural syntax. On top of that, because operating systems don’t ship with programming tools anymore (or they’re very buried, if they are there), you also have to deal with setting up a development environment, a whole extra hurdle that I imagine turns some people off, and definitely discourages casual exploration.
With all that in mind, I started tooling around in my mind with how I would go about designing such a programming language. Two things to keep in mind: I am in no way an expert on this branch of computing, and I’m writing this off-the-cuff. It’s hardly going to a complete specification, just some noodling that might hopefully be useful to someone (maybe even myself) in the future.
Natural Language
I’d like to go with semi-natural language for this programming language. It’s not as efficient, typing-time-wise, but I think it solves several issues. It makes the syntax more-or-less human-readable, with minimal training. This reduces the barrier to entry for a first-timer, and makes it more likely they’ll be able to parse their own mistakes. It also makes programming look less like a nightmarish math problem. I think this would help to decouple math and programming as related skills. They have some overlap, but most programming uses simple arithmetic most of the time, and you just don’t need to be skilled at math to be a good programmer, and vice versa. Hell, I barely clawed my way through my required college math courses and my programming’s turned out fine.
Not to say the use of natural-sounding language is perfect. It’s fraught because it means we’re language-reliant. Assume we build the first version of this code in English, because that’s the language I’m most familiar with and (along with French), one of what I understand to be one of the current lingua francas, at least in the Western world. Our English syntax is going to make a lot of assumptions about the order of things. These assumptions might not hold true if we do a literal translation into another language. Japanese grammar is very different from English grammar, as is French grammar. Even Spanish, which has a lot of grammatical similarities to English, will have significant enough changes that porting it will require notable effort. It could also lead to grammatically-strange sentences that are hard to read, but I’d argue for a complete novice that it’s probably not any harder to read than than a variable assignment (Integer x = new Integer(4);, anyone?).
My inspirations for this approach are COBOL, Basic (If/Then!), and the Inform programming language for interactive fiction.
Sample Lines
So we’re using natural language. How would this look? I’m going to compare it to Java, because that’s what I know best right now.
Assigning Variables
I think that we should used inferred types here, again for ease-of-use on the part of the end user. Can it lead to weird errors? Absolutely. But it’s easier to learn off-the-bat than the difference between an integer, a float, and a double.
Java:
int x = 3;
x = 4;
Hypothetical Easy Coding/Computing Language Environment (HECCLE):
x is 3.
x is 4.
If/Then Blocks
More inference here. Because, I mean, who’s actually assigned variable values during an if statement?
Java:
if(x == 3){
System.out.println("You did it!");
}
HECCLE:
If x is 3, then print "You did it!".
Note: I’m ending each line with a period now, which already gets us into “potential nightmare” territory when it comes to Proper English Grammar, but I think is fairly intuitive? The alternative I can think of is requiring a newline between each command, which would also work.
If-Then-Else
And I guess we’re using commas for “sub-statements” now. There’s no way this could go wrong in the future!
Java:
if(x == 3){
System.out.println("You did it!");
}
else{
System.out.println("Oh no!);
}
HECCLE:
If x is 3, then print "You did it!", otherwise print "Oh no!".
Accepting User Input
Java:
import java.util.Scanner;
Scanner x = new Scanner(System.in);
String input;
//I realize this doesn't quite work,
//but bear with me for example's sake.
while(x.next() != null){
input += x.next();
}
System.out.println("You input: " + x);
HECCLE:
Prompt user for input.
A is input.
Print A.
Object Definition
Time to make this thing feel modern. Before, we were pretty much just doing stuff BASIC could do. I think with object-oriented programming included as a possibility, the potential uses of this expand even further. Not that such an approach should be required for a first-timer programmer who just wants to make, like, a basic calculator.
Java:
//Class definition itself with constructor
public class TerrestrialObject{
int x;
int y;
public TerrestrialObject(int a, int b){
x = a;
y = b;
}
}
//Declaring a new instance of the class
TerrestrialObject mulder = new TerrestrialObject(1,2);
HECCLE:
//Definition, doesn't require an explicit constructor
TerrestrialObject is a widget.
TerrestrialObject has x and y.
//Construction of a new instance
Barry is a TerrestrialObject where x is 1 and y is 2.
Conclusion
Obviously, this is just a few sketched-out examples and isn’t complete, and hardly perfect. I hope it gets across the general direction I’d want to go in, though. Natural language, defining many things implicitly for ease-of use, and including most functionality in the core version of the language, rather than importing libraries. I think something like this would let people who don’t necessarily consider themselves “computer people” program with minimal friction. Combined with a good compiler that gave readable error information, it would (ideally) be possible for even a casual user to experiment on their own, and hopefully start feeling comfortable with the idea that they have control over how they use their machine, rather than the other way around.
I’m intrigued. What I’d really like to see are more complex examples, and also less programmer-y logic.
For instance, building a GUI (which, realistically, is what a lot of “normal” users want to end up with when they sit down to program) is currently very complex and the logic tends to be confusing (why do we have to declare what kind of window we generate, and then create an instance of that window class? why can’t we just declare we want a window to magically appear?).
I could imagine something like:
# create a window called “Application” and apply default gridbox
Application is a window with a grid layout style.
# describe what the Application looks like
In Application:
– box 1: label “Enter your name”
– box 2: text field called “name”
– box 3: button “OK”
– box 4: button “Cancel”
– box 5: merge boxes and print _name_ when _OK_ is clicked.
…or something like that.
I also feel that variables always being in CAPS helps new users a lot. It used to confuse me, when teaching myself to code, never knowing whether a word was part of the language or just some random string the tutorial author chose. Separating language keywords from user input helps a lot.
Also, I think permitting the resulting GUI to be styled with plain old CSS would be brilliant. Not that everyone knows and understands CSS, but it is pretty ubiquitous and easy to learn, and I think it’s better at managing GUI elements than most native systems in any GUI framework I’ve seen.
Qt allows for this, and it makes styling Qt applications so easy.
Nearly all of your syntax is compatible with AWK (excepting the strongly-typed “int” and the class reference).
When anyone I know needs to use one of the languages that appropriated the C control structures (PHP, Javascript, et al.), I point them at the 40 pages of chapter 2 below, and it is occasionally effective:
https://ia802309.us.archive.org/25/items/pdfy-MgN0H1joIoDVoIC7/The_AWK_Programming_Language.pdf