If you were to create a programming language...

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
baconhawka7x
Party member
Posts: 494
Joined: Mon Nov 21, 2011 7:05 am
Location: Oregon, USA
Contact:

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

Post by baconhawka7x »

Kingdaro wrote:I love Lua's simplicity, so I wouldn't really change anything about it. The only thing I truly want is assignment operators. This is annoying:

Code: Select all

self.longVariable = self.longVariable + 1
This is less annoying:

Code: Select all

self.longVariable += 1
I totally agree.
User avatar
sashwoopwoop
Prole
Posts: 8
Joined: Fri Jun 27, 2014 10:53 am

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

Post by sashwoopwoop »

Kingdaro wrote:I love Lua's simplicity, so I wouldn't really change anything about it. The only thing I truly want is assignment operators. This is annoying:

Code: Select all

self.longVariable = self.longVariable + 1
This is less annoying:

Code: Select all

self.longVariable += 1
And zero-based table indizes. Please.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

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

Post by Kingdaro »

sashwoopwoop wrote:And zero-based table indizes. Please.
This I disagree with. I like the way Lua does it. Although unorthodox and not mindful of how memory management works, it's more humanistic and just makes more sense in general.
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post by zorg »

Kingdaro wrote:
sashwoopwoop wrote:And zero-based table indizes. Please.
This I disagree with. I like the way Lua does it. Although unorthodox and not mindful of how memory management works, it's more humanistic and just makes more sense in general.
Everytime i want to wrap something:

Code: Select all

i = ((i + 1 - 1) % N) + 1 -- or more concisely: i = ( i      % N) + 1
i = ((i - 1 - 1) % N) + 1 -- or:                i = ((i - 2) % N) + 1
1-based indices make it less clear just what the code does, contrast 0-based:

Code: Select all

i = (i + 1) % N
i = (i - 1) % N
i guess there are alternatives to this like "i = (i+1)<N and i+1 or 1" too, i just like not mixing too much logic into a plain math thing like modular arithmetic; to me, it's more clear what i'm trying to accomplish, and in some places, 1-based is indeed better; this must be like the 0^0 == 1 or 0 problem :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
soulaymenc
Prole
Posts: 36
Joined: Thu Jul 11, 2013 2:03 pm
Contact:

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

Post by soulaymenc »

Thank you for starting this awesome subject!

As a software, web and game developer, I would say that Lua is an awesome programming language, but have many weak points.
The programming language that I'm going to write for sure will look similar to lua, but much less dangerous. What's dangerous about Lua is that you might not know what you are manipulating. Variables could contain different kind of data and you need to make sure you are passing the right variables in the right parameters. I think that static typing in programming language is a feature. Lua syntax is very simple and comfortable. I would use pretty much same syntax but with different style since I'll be adding types, something like:

Code: Select all

let update = function( dt: Int )
   #Check objects
   for i, v in ipairs(objects) do
      if v.health == 0 then
          objects.remove v
      end
   end
end
I wrote a language which was kinda similar in C, but i fucked things up so I had to rewrite it, and I'm just being lazy :emo:
This world is so strange.
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

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

Post by LuaWeaver »

Lots of things are functions rather than built-in features to allow power and would have some nice syntactic sugar to hide this. For example, an if statement might look like this:

Code: Select all

if(blahblah == 'hi'){
	whatever
}
But 'if' is a function. For example, an 'equivalent' Lua thing would be like

Code: Select all

local function decide(cond,func)
	if cond then
		func()
	end
end
Obviously the raw if would have to be implemented in the host language, but you could then overwrite 'if' to do weird things if you want. Flexible. Dangerous. I like it.
"your actions cause me to infer your ego is the size of three houses" -finley
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post by Robin »

If you use Church Booleans then the definition of "if" becomes something like:

Code: Select all

function ifelse(cond, thenpart, elsepart)
    return cond(thenpart, elsepart)
end
Help us help you: attach a .love.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

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

Post by Plu »

Obviously the raw if would have to be implemented in the host language, but you could then overwrite 'if' to do weird things if you want. Flexible. Dangerous. I like it.
I'm currently reading Practical LISP, and pretty much LISP does just that, where you can redefine the whole language if you want. And you're pretty much expected to.

It's weird, the more I read about old languages, the more I find they've plugged up most of the problems I have with modern languages.
User avatar
murks
Party member
Posts: 185
Joined: Tue Jun 03, 2014 4:18 pm

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

Post by murks »

  1. Static types, no implicit variable declaration.
  2. Require local or global, no implicit scope at variable declaration time.
  3. No syntactic sugar (except maybe the comfortable increment operators Lua lacks)
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

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

Post by LuaWeaver »

Plu wrote:
Obviously the raw if would have to be implemented in the host language, but you could then overwrite 'if' to do weird things if you want. Flexible. Dangerous. I like it.
I'm currently reading Practical LISP, and pretty much LISP does just that, where you can redefine the whole language if you want. And you're pretty much expected to.

It's weird, the more I read about old languages, the more I find they've plugged up most of the problems I have with modern languages.
That's part of my inspiration for that; I just want a friendlier looking syntax. In Lisp, code and data are the same. However, I want code to look like code, not data, and Lisp doesn't solve that problem for me.
"your actions cause me to infer your ego is the size of three houses" -finley
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests