Page 2 of 5

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

Posted: Fri Dec 20, 2013 9:21 pm
by jjmafiae
vb.net use a single equal (that's so awesome)

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

Posted: Fri Dec 20, 2013 10:17 pm
by DaedalusYoung
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?

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

Posted: Fri Dec 20, 2013 10:31 pm
by szensk
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.

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

Posted: Fri Dec 20, 2013 10:38 pm
by Roland_Yonaba
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.

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

Posted: Sat Dec 21, 2013 1:37 am
by iPoisonxL
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

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

Posted: Sat Dec 21, 2013 11:39 am
by Plu
I would even prefer both of := and == to make it completely impossible to accidentally screw up by forgetting a = in your ==.

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

Posted: Sat Dec 21, 2013 2:54 pm
by bs4h

Code: Select all

if i == (i or 2 or 4) then
How about this?

Code: Select all

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

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

Posted: Sat Dec 21, 2013 7:58 pm
by iPoisonxL
bs4h wrote:

Code: Select all

if i == (i or 2 or 4) then
How about this?

Code: Select all

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

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

Posted: Sat Dec 21, 2013 8:28 pm
by Inny
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.

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

Posted: Sun Dec 22, 2013 2:08 am
by iPoisonxL
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.