Kewl Programming Language
I recently was recently listening to a talk from the ConFoo Developer Conference and started to have some ideas on what a new programming language could look like. Most of what I have written up here is an example and / or extension of what is discussed in that video. While I don't agree with everything he says about JavaScript, I do find some of his suggestions extremely valuable.
I listed some things that I would like it to do and then I wrote some example code from this as of now not real programming language:
I listed some things that I would like it to do and then I wrote some example code from this as of now not real programming language:
- Spaces in identifiers.
- Setting a value uses a colon.
- Values are constant be default unless the 'var' modifier is used.
- Comparing a value uses an equal sign.
- Blocks of code are distinguished with curly braces.
- Functions are called with the '()' operator.
- Functions are first class citizens.
- A function can be handled asynchronously by using the -> operator.
- Everything is an object and can be defined using a JSON equivalent format.
// The 'Kewl' programming language.
// Comments start with two forward slashes.
// Identifiers can contain spaces.
// Setting a value uses the colon operator.
// Values are constant by default.
my cool value: 4
// Prepending an assignment with 'var' makes it a variable.
var my cool value that can change: 2
// Conditional statements uses a single equals sign.
// If statements do not need parenthesis.
if my cool value = 4 {
// Functions are called with the '()' operator
new value: do something cool()
} else {
// Functions can be passed around just like other values.
new value: do even cooler stuff(do something cool);
}
// Curly brackets do not contain scope.
// The return value of a function can be accessed
// asynchronously by stating an identifier after
// asynchronously by stating an identifier after
// the function call and using the '->' operator and curly brackets.
add two values (new value, my cool value) the sum -> {
print a message (the sum)
}
// Functions are defined using the 'def' operator.
def do even cooler stuff(function to call) {
return function to call()
}
def do something cool (cool value) {
print a message (cool value)
}
def do something cool() {
return 1
}
def add two values(first value, second value) {
return first value + second value
}
def print a message (message) {
print (message)
}