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

General discussion about LÖVE, Lua, game development, puns, and unicorns.
jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

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

vb.net use a single equal (that's so awesome)

DaedalusYoung
Party member
Posts: 402
Joined: Sun Jul 14, 2013 8:04 pm

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

I used to program in MSX-BASIC when I was 10 or so, back in the late 80s, that used a single equal for assigning and equality testing. It's easy enough to distinguish, just doesn't let you have the functionality that assigning returns true. But how often do you really need that?

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

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

jjmafiae wrote:vb.net use a single equal (that's so awesome)
No, it's horrible. You should only use "=" for comparison when you use ":=" for assignment. I'd much prefer having one of (==, :=) rather than having = be ambiguous.

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...

szensk wrote:No, it's horrible. You should only use "=" for comparison when you use ":=" for assignment. I'd much prefer having one of (==, :=) rather than having = be ambiguous.
+1.

iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

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

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

Code: Select all

if i == 1 or 2 or 4 then
Oooh, first time I programmed I tried doing this and the compiler kept complaining. I was so confused...

IMO it should be like

Code: Select all

if i == (i or 2 or 4) then

Also, here's a little bit more code from my language... because why not? Here we're going to define a table then a function.

Code: Select all

(the : operator almost always comes with the keyword contains)

table hello contains:
"unIndexed",
index = "indexed".

(like usual, it is ended with a . operator)
(you can call table values by their number index, or their named index.)

(to index you use the 's operator)

print hello's 1 (this works, prints "unIndexed")
print hello's index (this works, prints "indexed")
print hello's 2 (this works, prints "indexed")
print hello's what (this doesn't work, will complain with a null error)

function sayHello contains:
print "hello".

function returnHello contains:
return "hello".

(functions also use the contains: keyword, and they end with a . operator. They support parameters, like so:)

function say words contains:
print words.

function ret words contains:
return words.

(they can be called like this)
say "hello"
print [ret "hello"]
([] is used to group code)

(and you can assign them to variables)

variable x equals [say]
(if you use [] around a function name without parameters, it will return the function itself)

(or you can use the contains: keyword with a variable assignment to create an anonymous function.)

variable y contains: print "hello!".

(you can use this in parameters)

say [y contains: return "this will be said".] (this will print out "this will be said")
(this creates an anonymous function/variable)


I'm liking this

Code: Select all

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

Website

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

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

I would even prefer both of := and == to make it completely impossible to accidentally screw up by forgetting a = in your ==.

bs4h
Prole
Posts: 4
Joined: Fri Dec 20, 2013 2:11 pm

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

Code: Select all

if i == (i or 2 or 4) then

Code: Select all

if i in {1, 2, 4} then
Similar to Python's "in".

iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

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

bs4h wrote:

Code: Select all

if i == (i or 2 or 4) then

Code: Select all

if i in {1, 2, 4} then
Similar to Python's "in".
I never liked python because whitespace was sensitive

Code: Select all

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

Website

Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

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

I think my favorite features of a language usually have to do with the implicit things that you don't have to write, for which writing them explicitly has no real value. So as a for instance in Lua, the 'do' keyword isn't an explicit block open statement the way the open curly brace is in javascript. If it were, then our code would read function name(params) do end, which doesn't add to anything. The blocks are all opened implicitly, and the keyword to do so are actually serving double duty, So one token ends up doing more. These things can have their implications, but I like it because they alleviate some congnitive load, letting you focus more on the task then trying to remember syntax rules.

So, for one more comparison, let's look at the if statement:
Lua has just one if statement:

Code: Select all

if condition then code end
Javascript has two:

Code: Select all

if (condition) code
if (condition) { code }
I find that to be an inefficient microwaste of my time, and I almost never use the first type of if statement in javascript.

iPoisonxL
Party member
Posts: 227
Joined: Wed Feb 06, 2013 3:53 am
Location: Australia
Contact:

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

Inny wrote:I think my favorite features of a language usually have to do with the implicit things that you don't have to write, for which writing them explicitly has no real value. So as a for instance in Lua, the 'do' keyword isn't an explicit block open statement the way the open curly brace is in javascript. If it were, then our code would read function name(params) do end, which doesn't add to anything. The blocks are all opened implicitly, and the keyword to do so are actually serving double duty, So one token ends up doing more. These things can have their implications, but I like it because they alleviate some congnitive load, letting you focus more on the task then trying to remember syntax rules.

So, for one more comparison, let's look at the if statement:
Lua has just one if statement:

Code: Select all

if condition then code end
Javascript has two:

Code: Select all

if (condition) code
if (condition) { code }
I find that to be an inefficient microwaste of my time, and I almost never use the first type of if statement in javascript.
Agreed, with never using the first one, but it is very useful for some people when they repeat themselves a lot, honestly. It looks pretty clean (not saying that the other one looks dirty), and it's easy to read. I still do love brackets and when I first took up Lua I always thought I'd get lost in all the ends and thens.

Code: Select all

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

Website

### Who is online

Users browsing this forum: No registered users and 11 guests