## If you were to create a programming language...

General discussion about LÖVE, Lua, game development, puns, and unicorns.
iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

### If you were to create a programming language...

If you were to create a programming language, what would the main syntax be like, and why?

I have always dreamed of a completely readable language. Not because it'd be "easier" to code with, no, it'd be much harder. I just always thought it'd be pretty cool. Here's an example of my "dream language":

Code: Select all

(this is a variable declaration and an if statement.
oh and this is a multi-lined comment.
There is no single lined comment, you always need to close the parentheses.)

variable name is equal to true
if name equals true, out "hi", if not, out "bye".

(this is obviously bunched up in one line and could be whitespaced/newlined as much as needed)

(analysis:
creating a variable called name, and setting it to true. Then, we check if name is equal to true, and then we output hi if yes. Else, we output bye.)

(basic syntax translating:
"variable" is a variable declaration
"is equal to" just means =
"equals" is ==
"," is then, or its a continuation, depending on where the last "," was.
"out" is print
"if not" is an else statement
"." usually means closing a statement)

This is just an if statement, and a variable declaration. I actually mapped out a whole file just showing off syntax for this, not sure where it went though. It had pretty cool concepts, but it was really just like a re-textured Lua.

Funny thing, I once tried to hard-code a simple language with Java, using this syntax. I somewhat succeeded, I created a "language" that could assign a variable a name and a number, and then you could print that. It's all it did, but it was interesting.

And you? What would be your dream syntax if you could create a programming language?

Code: Select all

      L
L Ö
Ö V
L Ö V E
Ö B E
V E
E Y

Website

pk
Citizen
Posts: 67
Joined: Wed Dec 14, 2011 2:13 am
Location: Texas, United States
Contact:

### Re: If you were to create a programming language...

You could probably implement that language in Forth
ALL CREATURE WILL DIE AND ALL THE THINGS WILL BE BROKEN. THAT'S THE LAW OF SAMURAI.

szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

### Re: If you were to create a programming language...

Mine would look like the statically typed bastard child of Ruby and Moonscript with plug-in interfaces types ala Go. And go routines.

Code: Select all

class Number
def self.square -> Number:
@ * @
def square(x: Number) -> Number:
x * x
squares = [x.square for x in 1..10]


ivan
Party member
Posts: 1520
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### Re: If you were to create a programming language...

iPoisonxL wrote:I have always dreamed of a completely readable language. Not because it'd be "easier" to code with, no, it'd be much harder. I just always thought it'd be pretty cool. Here's an example of my "dream language":

Code: Select all

(this is a variable declaration and an if statement.
oh and this is a multi-lined comment.
There is no single lined comment, you always need to close the parentheses.)

variable name is equal to true
if name equals true, out "hi", if not, out "bye".

(this is obviously bunched up in one line and could be whitespaced/newlined as much as needed)

(analysis:
creating a variable called name, and setting it to true. Then, we check if name is equal to true, and then we output hi if yes. Else, we output bye.)

(basic syntax translating:
"variable" is a variable declaration
"is equal to" just means =
"equals" is ==
"," is then, or its a continuation, depending on where the last "," was.
"out" is print
"if not" is an else statement
"." usually means closing a statement)

iPoisonxL, your language example is just syntactic sugar - I mean something like that could be implemented using macros in C/C++ alone. As soon as you introduce equations and other math expressions, the language would start to look a lot like Lua. Also, (usually) in programming the more succinct the language the better.

Recently I've been thinking about possibly a high level language centered around behavior trees. It would be centered around moving/modifying objects and could be useful in AI for games and possibly as an embedded language for robotics. Something like:

Code: Select all

  -- seek and attack player
selector
{
-- wander behavior
parallel
{
not sense(player)
wander
}
-- attack sequence
sequence
{
settarget(player)
rotatetotarget
shoot
}
}

The cool thing about behavior trees is that you can put animation/tween goals in there too.

Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

### Re: If you were to create a programming language...

I've been thinking about a language that I would like to try and implement, but the primary idea would be that it does not store its program as text at all. It would use a sort of linked graph instead. So there wouldn't be much of a syntax probably.

bzSteve
Prole
Posts: 34
Joined: Tue May 21, 2013 2:31 am

### Re: If you were to create a programming language...

Early versions of COBOL used to be a bit like what you're describing. Before the COMPUTE statement, you had to say SUBTRACT C FROM B GIVING A instead of A = B-C.

Those were dark times indeed.

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

### Re: If you were to create a programming language...

my language:

Code: Select all

a = 5

func test()
if a = 5 then
print("test")
a = 2
end
end
it would be lua like but faster to write

veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

### Re: If you were to create a programming language...

It would be identical to lua except you could do this:

Code: Select all

if i == 1 or 2 or 4 then

Roland_Yonaba
Inner party member
Posts: 1562
Joined: Tue Jun 21, 2011 6:08 pm
Contact:

### Re: If you were to create a programming language...

jjmafiae wrote:my language:

Code: Select all

a = 5

func test()
if a = 5 then
print("test")
a = 2
end
end
it would be lua like but faster to write
Question. Hw would you distinguish assignment from equality tests if they all use the same operator "=" ?
I am not saying it's not possible, but it sounds quite confusing, to me.

veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

### Re: If you were to create a programming language...

Roland_Yonaba wrote:
jjmafiae wrote:my language:

Code: Select all

a = 5

func test()
if a = 5 then
print("test")
a = 2
end
end
it would be lua like but faster to write
Question. Hw would you distinguish assignment from equality tests if they all use the same operator "=" ?
I am not saying it's not possible, but it sounds quite confusing, to me.
When i was first getting used to lua i used to always use a single = in if statements. That may be cause i was coming from vb.net which may or may not do that, don't remember.

### Who is online

Users browsing this forum: No registered users and 12 guests