Project idea: .love -> .lua

I’ve started learning about the 2D-games-development environment called LÖVE at love2d.org.

Basically, it wires together lots of “de facto standard” multimedia libraries (like SDL/OpenGL, OpenAL, DevIL) and ties it up with the minimalistic scripting language Lua (visit lua.org).

I really like the idea, and have brought up the “Hello World” on my screen in less than 5 minutes from visiting the page.

Now the downside of this is the syntax of Lua:

function hypot(a, b)
  return math.sqrt(a*a + b*b)
end

While that doesn’t look so scary, I’m not fond of long keywords (function) nor words-as-end-markers. It gets especially visible/cumbersome if you have a couple of nested levels of control code:

function myfunc(a, b)
  if a>b then return end
  while a<b do
    if a==b then
      for i=0,4 do
        print(i)
      end
    end
    a = a + 1
  end
end

I like Pythons syntax much better:

def hypot(a, b):
    return math.sqrt(a*a + b*b)

The second example in Python:

def myfunc(a, b):
  if a>b: return
  while a<b:
    if a==b:
      for i in range(5):
        print i
    a = a + 1

Some might say I’m crazy, but then you haven’t coded that much in both these languages. While I can’t say I’ve coded *much* in both, I do have at least some weeks of effective time in both. These little things do make a difference.

So this is a project idea: write a simple translation program from a Python-influenced Lua dialect, into pure Lua. Let’s end files in this new language with “.love” just for the sake of the newly discovered LÖVE library. What the translator would do is simply translate “def” to “function”, and keep track of when an indentation-block ends, so it can add the appropriate “end” keywords a la Lua.

You up for it?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s