7

Lua users, have you used moonscript?

It's a little language that has it's own interpreter or can be compiled down to Lua and it's absolutely lovely (currently using it with Love2d).

Of course, as with most things, what I love about it also royally pisses me off sometimes.

For starters local has to be declared for variables, unlike lua.
Otherwise the variable goes to _
Also note, that some tutorials literally tell you the opposite.

all variables are local by default
unless you don't declare them
then they go to _ (throwaway)
Some tutorials get this wrong too.

all variables have to be declared local
except tables. failure to declare a table WITHOUT a local will cause things like
table.insert to fail with "nil" values for no god damn reason.
No tutorial I could find mentioned this.

Did you know we call methods with '\'?
By the way, we call methods with '\'.
Why? Who the fuck knows.
Does make writing web routes more natural though.

Variables in the parameters of new are declared and bound for you. Would have loved to know this before hand instead of trying
to bind to them like a fucking idiot.

Fat arrows are used to pass in self for methods.
Unless you're calling a method. Then you use backwards slash. This fact is unhelpful when you're a beginner and dealing with the differences between the *other* arrow, the backslash, the fat arrow, and the fact that functions can be called with or WITHOUT parenthesis.
And on that note..

While learning all this other shit, don't forget parenthesis are optional!
Except when they're not!
..Like when you have a function call among your arguments and have to disambiguate which args belong to the outer call and to the inner call! Why not just be fucking consistent?

But on the plus size, ":" is now used for what it should have been used for in the fucking beginning: binding values to keys.
And on the downside, it's in a language thats built on top of another language that uses it for fucking *method calls*, a completely
different fucking usage.

And better still, to add to that brainfuckery thats lost in the mental translational noise like static on a fucking dialup modem, you define methods with the fat arrow. Wait, was that the single arrow or fat one? Yeah the fat one. Fuck. But not before you do THIS shit..

someShit: =>

yeah, you STILL include the god damn colon just so when you're coming from lua you can do a mental double take. "Why am I passing self twice? Oh right, because fuck me, I decided to use moonscript." It's consistent on that front but it also pisses me off.

A lot of these are actually quality of life improvements disguised as gotchas, but when you're two beers in to a 30 minute headscratcher it sure doesn't fucking feel like it.

Nevertheless, once I moved beyond the gotchas, it was like night and day. Sure moonscripts takes a giant steaming dump all over the lua output, like a schizophrenic alcoholic athena from the head of zeus, but god damn, when it works it just WORKS.

Locals that act like locals? Check.
Sane OOP? Check.
Classes, constructors, easy access to class methods, iterators? Check, check, check, check, check.

I fucking hate ceremony. Configuration over convention is for cunts. And moonscript goes a long ways toward making lua less cunty.
If you've ever felt this way while using lua, please, give moonscript a try.

You'll regret it, but in a good way!

Comments
  • 5
    Stealing the last line for picking up babes
  • 1
    Hey fellow lua user!

    I use pure lua for games / love framework, so I have only scratched moonscripts, ill take a closer look though!
  • 0
    What are the problems you ran into lua with btw?
  • 1
    @dmoa

    Prototypes do fucky things to my headspace.

    I'm strongly visual so languages that let me fuck with scopes and 'implement my own OOP' cause me to mentally recurse until I run out of stack and crash.

    I like to be able to look at something and know definitively what it does and where it belongs in relation to the rest of the source code, instead of the indirection of having to figure out what the meta table is doing in conjunction with the run time or state of the system (reasoning about the invisible is hard for me).

    I like to be able to debug my program, not my understanding of the tools. Like most programmers using garbage collected languages, I like my training wheels and safety helmet while I drool on my self and eat bugs all day.

    Jokes aside, it took me *ages* to grok closures, and it always seemed like when I asked I got some high brow fucky answer from some smug university cunt, until about a year ago someone said 'basically they are 1st class scopes'
  • 0
    @Wisecrack I can understand where you are coming from. I was kinda fine with scopes, but that’s just me. I like to use this classes ‘module’, which basically means I can do player = Player(arg1, arg2). That makes oop a lot easier for me to use
  • 0
    @dmoa

    Give moonscript a try.

    Almost an order of magnitude improvement in development speed now that I don't have to mess with metatables..always seemed fiddly to me.
Add Comment