MoonScript - A programmer friendly language that compiles to Lua.
moonscript.org
moonscript.org
It's simple, predictable and easy to read.
This obsession with boiling everything down to strings of symbols is how folk wind up making fun of Perl and OCaml.
What's this do?
$$&[%]
Or this? ?:>
Buggered if I know. Only a professional Perl or OCaml programmer could tell you -- and indeed I made those up. Only a professional Perl or OCaml programmer could tell if they do anything at all.But pretty much anyone from any language background can eyeball an Algol-family syntax and tell you what's going down.
A few years ago I took a unit in my comp sci degree, "Programming Paradigms". The language used for teaching was F#, which is heavily inspired by OCaml. At one point we were given readings on OCaml programs and a particular operator popped up -- something like "is subtype of", I fail to recall exactly -- and it looked like :>? or :?> or similar.
I bitched loudly in the unit forum about this operator, whereupon the professor politely informed me that he, in fact, had invented that little bit of syntax when he was a PhD student at INRIA.
He didn't flunk me! Dr Rowan Davies, still the most scary-smart computer scientist I've met.
If you're going to complain about OCaml's syntax, I would start with having to use different arithmetic ops for int vs. floating point (+ vs. +.) and different indexing operators for strings and arrays ( s.(0) vs. s.[0] ).
You get used to it pretty quickly, and OCaml more than makes up for it in other ways, but it is a bit annoying.
But I love OCaml, I don't why it isn't more hacked/forked.
Because it has a fucked-up licence - you're not allowed to "fork" it in the usual sense of the word, you can only distribute the original source, and your modifications in a patch. The "free-for-all" licence is only available to commercial users.
Sure, OCaml allows you to specify new operators, but the rules are pretty simple, and you cannot arbitrarily fuck up the syntax.
Edit: happily, an attribution has now been added at the bottom, as noted in child comments.
Language using "--" for comments include Lua and Haskell.
You've made me curious - what languages to you use/know that make you think "#" is a "CS convention" for comments?
EDIT: Found a reference:
http://en.wikipedia.org/wiki/Comparison_of_programming_langu...
Further edit: In response to the clarification that CS meant CoffeeScript and not Computer Science (nor the riot control gas), the point, I guess, then follows other commentators, who observe that Lua, to which this compiles, uses "--".
It's still a little irritating that they've changed things that CS handles quite elegantly to be less expressive, presumably just out of a desire to be different. I understand changes to the syntax are necessary for various reasons, but something like ! for argumentless function calls instead of () just seems like needless divergence. Was that extra character really killing you? Is the confusion with other meanings of ! really worth it?
About
The syntax of MoonScript has been heavily inspired
by syntax CoffeeScript.Imagine that C on the PDP-11 had a slightly different syntax from C on x86, and the syntax were different from that on C on ARM, etc.
Are there so many similar places where users are forced to use Lua, to warrant an extra layer? (with all the complexities such as debugging, a compile step, tracing errors back to MoonScript code, etc)
Note, I'm not commenting about the language's choices. Maybe coding in MoonScript rocks big time. I just don't get why it compiles to Lua.
Lua's portability & smooth C integration make it an interesting code generation target (not to mention LuaJIT's performance). And however you feel about working in Lua, its code is straightforward to generate - the syntax is refreshingly free of odd corner cases.
If you miss OO in Lua, use some OO library (I like middleclass).
Honestly, I don't see any gain in Moonscript.
After writing the majority of the compiler in MoonScript itself, and some other scripts, I've actually grown to like it and I find it perfectly readable. More readable than Lua in fact, because half of the text on my screen isn't the keyword `local` :). Try it out, if you code Lua then I think you might like it.
So I wrote the language for myself to use, but I've opened it up for other people because I think there is some potential for it. The use case for MoonScript is the same as the use case for Lua.
Also I have done a lot of mitigate the pains of compiling and debugging. It's actually pretty seamless, I've done stuff like automatic code compilation on require, and error line number rewriting. I urge you to check out the documentation: <http://moonscript.org/reference/#moonscript_api>;
Many languages compile to an intermediate format of some kind. The complexities you cite are easily be hidden. MoonScript already makes compiling and error traceback invisible, and I expect direct debugging of MoonScript files will be doable at some point as well.
This is the first I've heard of MoonScript, but I've long wondered why more languages don't use Lua as a target.
Also, I can see it compiling into JavaScript as well. I'm not sure if that would be a good idea, or a really horrible one, though.
My main grudge against Lua purely as a language is that it has implicit global variables. I can live with the rest of the idiosyncracies.
My main grudge in day-to-day programming is the ecosystem, it's very small. It's a chicken-and-egg thing.
Its compiler doesn't do much analysis / optimization, but the performance of individual Lua constructs is usually easy to reason about.
If only objc would remove the square brackets (and stay true to smalltalk), the syntax would be so much nicer:
NSArray* array = NSArray alloc init autorelease NSDictionary* dict = NSDictionary dictionaryWithObjectsAndKeys:obj,key,nil
...
http://olua.sourceforge.net/ ?
> If only objc would remove the square brackets (and stay true to smalltalk), the syntax would be so much nicer:
Objective C is (or at least it used to be, not sure ATM) a strict superset of C. One of the ways this is achieved is through having orthogonal syntax for the smalltalk-ish bits compared to classic C.
I am enjoying this wave of new programming languages that compile down to existing ones in a human readable way. They are pleasant to write and read and yet performant and don't require a special runtime, making them easy to integrate anywhere in their parent language.
I hope someone talented will build one of these for C/C++. Mobile an game developers could use it.
There's a space for innovation there. ooc [2] has been a step in that direction, although its usage of garbage collection makes it much less flexible than CoffeeScript or MoonScript. I don't think developers need to be abstracted from memory management at low level. What they could use is getting rid of a lot of cruft, to be able to write/read/think more quickly.
[1] http://attractivechaos.github.com/plb [2] http://ooc-lang.org/
C, C++, APL, etc. all seem perfectly "programmer-friendly" to me, once you've learned them...
Really happy to see some action!
b = x-10
is converted to
local b = x(-10)
This looks like to be really error prone.! operator can be used to call a function with no arguments
Seriously?
I feel like people are coming up with these things just to be "different". Programming language syntax is a UI, and needs to be treated like one -- you don't make major changes to basic UI paradigms without convincing reason.
Edit: Maybe more to the point, you don't add random buttons to a UI that do non-obvious things. Language syntax should be self-evident and quickly readable, and shouldn't require careful parsing of individual characters.
Handy tip: languages that are marketed for use in the real world tend to advertise actual uses in the real world.
My point/question was: it doesn't add a runtime or new libraries/routines, you can read the generated code if something goes wrong, so why wouldn't it be ok to use in production?
On the contrary, at the very top of the page, albeit in extremely poor contrast, it says "A programmer friendly language". That certainly implies the author considers it to be good for something other than "playing with new syntax".