Live data from Hacker News

MoonScript, a programmer friendly language that compiles to Lua

moonscript.org

91–100 of 171 posts

Re: MoonScript, a programmer friendly language that compiles to Lua

#91
post #7

I understand that people love programming in classes, but I really want something like a stripped-down ES6. In particular, I want: 1. Lists and objects/dicts only; objects have no prototypes at all; objects have no first-class methods, but they can have functions as member variables, and those functions can close over other data in the object 2. All function and variable declaration is anonymous (as a consequence of…

That actually wouldn't be hard to make; just use a custom eslint rules!

If you want implicit returns and really want to disable "fancy features", babel plugins are fairly easy to create – blacklisting certain constructs wouldn't be very difficult, and implicit returns aren't so hard (you can copy my implementation[0] from a JS superset I built called LightScript[1]).

EDIT: bonus of building on babel is that you can get static types for free à la Flow (though typechecking implicit returns may be a pain).

[0] - https://github.com/lightscript/babel-plugin-lightscript/blob...

[1] - http://lightscript.org

Re: MoonScript, a programmer friendly language that compiles to Lua

#92
post #2

I love the syntax that Coffeescript-like languages are converging to, like Moonscript, tj's luna ( https://github.com/tj/luna ) and Pogoscript ( http://pogoscript.org/ ). They fall way on the right of the "computer code vs. human code" spectrum, which is handy when writing applications as quickly as possible rather than focusing on fine details like implementation and performance. It's a shame I don't see it often in…

Curious what you might think of LightScript (http://lightscript.org) – would love feedback!

Re: MoonScript, a programmer friendly language that compiles to Lua

#93

Can this be used instead of Lua with Redis? Is there an example somewhere of that?

Here's an example of a job runner (≈ cron) in Redis and MoonScript: https://github.com/debrouwere/jobs/tree/master/src. I don't maintain it anymore, but it should give you an idea of how MoonScript can make Redis scripting a whole lot less tedious.

Re: MoonScript, a programmer friendly language that compiles to Lua

#94

Earlier quoted context omitted.

Arrays starting at 1 and being closed intervals is mostly just worse than starting at 0 and being half-open intervals. Here's an expression to take an integer b and "mod it" into an interval from a to c, given the normal convention from C++ or Python or whatever where intervals are [a, c): (b-a)%(c-a)+a And here it is in the lua convention where intervals are [a,c]: (b-a)%(c-a+1)+a This is a generalization of what yo…

Yes there are many algorithms that are naturally 0 indexed. But there are also many that are naturally 1 indexed! This is somewhat unscientific, but I once went through the first quarter of an algorithms textbook. And counted how many were naturally one based or zero based. And on most it didn't matter, but there were slightly more one based ones.

Can you give us some examples of one-based algorithms?

I've done a lot of programming in one-based languages, and now avoid such languages as much as possible (sometimes have no choice) because nothing seems to naturally fit into that.

Re: MoonScript, a programmer friendly language that compiles to Lua

#95
post #50

Earlier quoted context omitted.

> Except that that whitespace is not used only for that purpose, it could mean also something else, right It's not just whitespace, it's the specific formatting of whitespace. It's just a character, like any other, only defined by it's lack of distinguishing characters. Instead of whitespace, block continuations could be defined by pipes, or angle brackets, or any number of things. They chose wihtespace. > We trade a…

> It's not just whitespace, it's the specific formatting of whitespace. Yes. Specific, context sensitive, that requires disambiguation in your head and therefore harder to read. > We trade an unambiguous set of characters --the parentheses-- by whitespace, and make it context sensitive. Parenthesis are often context sensitive in languages. Yes, but they're consistent with the mathematical notation everyone has used o…

> Yes, but they're consistent with the mathematical notation everyone has used over their entire life. By the time you pick up a programming language you have most likely used parenthesis for a while.

As opposed to the natural visual distinctions that we make all the time? Braces are a learned concept. Having something visually offset might be a learned concept, but if it is I bet it's so early it's prior speech developing. People notice visual patterns. An offset bit of text forms a visual pattern. Again, I don't prefer it, but I think you're reaching in your arguments against it.

> I am going to create a new language 99% identical to English, where fork means knife, knife means spoon and spoon means fork. Have a happy time translating paragraphs of text involving those 3 objects from English into my language.

So, exactly the same situation we have with English today, where it changes and slang is used? I'll have to ponder that problem as I kick it in my crib tonight. Or maybe I'll just settle in and watch the boob tube. Surely replacing some words with others isn't and intractable problem?

> Implicit meaning takes non-zero effort to understand.

Whitespace blocks are not always implicit. They may be well defined within the language they are used in (such as in Python). It's no more implicit than inclusion of one or more symbols to confer meaning (even if they are space characters), rather than the exclusion of information. You are confusing whitespace for no-space.

> Now you have 2 ways of doing the same thing with no added value.

Of course there is added value. People prefer it. People's preferences have value.

> Now you have more possible ways of writing down an expression, if you are parsing an expression or refactoring your code with a regex now it's much more complex.

That depends on the language and whether there are multiple ways of defining a block. Unless you expect your expression to parse C, Lisp, Python, Smalltalk and Prolog correctly it it's just those pesky Python whitespace blocks that are holding you back. Within Python, space indented blocks are canonical. If you think that is causing too many ways to define how to perform something in different languages, you're probably better off not looking at some of the other languages I listed earlier...

> In 2017 there's still people fighting over tabs vs spaces. Now we add another dimension to it: spaces vs parenthesis. An endless source of bikeshedding.

Not really. Tabs vs spaces is something people that interact in code with each other have to deal with. I doubt Perl and Python developers get upset when they load each other's code, in the other's language, and see the other used spaces instead of parenthesis[1] or vice-versa, because that choice doesn't make sense within those languages. Sure, try to use indentation to define blocks in Perl. It won't do you any good without the parenthesis, because Perl doesn't support that choice.

1: It's obvious at this point we're actually talking about curly-braces, and not parenthesis, right? I'll keep using parenthesis for now for consistency's sake.

Re: MoonScript, a programmer friendly language that compiles to Lua

#96
post #16
post #4

Earlier quoted context omitted.

Thankfully, GitHub starting gutting Coffee from Atom a long time ago. There's still too much in there though.

While I understand the move to es6 or whatever we're calling it now, a part of me really misses coffeescript. I found it to be very elegant

spread some love for moonscript (and its inspiration coffeescript of course, my daily bread-and-butter) - to my mind the best possible syntax for a (dynamic) programming language. python being second place.

is it possible to get a tattoo with significant whitespace?

Re: MoonScript, a programmer friendly language that compiles to Lua

#97
post #37

Earlier quoted context omitted.

This is basically Lua, excluding type annotations. Lua's form of OOP is very strange in that methods aren't bound to a parent context, but instead take the object as a value. For example, `object:method()` is the same as `object.method(object)`, and `function object:method()` is the same as `function object.method(self)` - the only difference being calling the function via `object:method()` is a bit more optimized. T…

I forgot to emphasize that I'm particular about syntax. I amended my comment accordingly. I also don't like the global-by-default bit, but maybe my ideal language could be a syntax layer atop Lua?

If you ignore the class support of moonscript, you can pretty much use it to do what you want. It doesn't have the "global by default" silliness, to start with.

Re: MoonScript, a programmer friendly language that compiles to Lua

#98
post #95

Earlier quoted context omitted.

> It's not just whitespace, it's the specific formatting of whitespace. Yes. Specific, context sensitive, that requires disambiguation in your head and therefore harder to read. > We trade an unambiguous set of characters --the parentheses-- by whitespace, and make it context sensitive. Parenthesis are often context sensitive in languages. Yes, but they're consistent with the mathematical notation everyone has used o…

> Yes, but they're consistent with the mathematical notation everyone has used over their entire life. By the time you pick up a programming language you have most likely used parenthesis for a while. As opposed to the natural visual distinctions that we make all the time? Braces are a learned concept. Having something visually offset might be a learned concept, but if it is I bet it's so early it's prior speech deve…

Parentheses have been used for evaluating functions and establishing operator precedence for literally hundreds of years. It's taught in every school in every country and most books will contain this notation.

But since everything is relative, it doesn't matter anymore. Let's delimit function evaluations and operator precedence with the words "cat" and "dog" from now on. Since everything is a preference, and is relative, it doesn't matter.

However, what you fail to see is that in reality a choice like this involves effort, it has an economic cost, it's not only preference.

Re: MoonScript, a programmer friendly language that compiles to Lua

#99
post #83

Some of the stuff in Moonscript feels a little overdone and magical, like parens-less function calls and the syntactically significant whitespace - but others really feel like they're fixing the gaps in Lua. Moonscript's nice lambda syntax, ternary operator, default local, implicit return, etc. But I don't think I really needed the ! operator, for example.

fixing the gaps in Lua. Moonscript's [...] default local

Roberto Ierusalimschy, the creator of Lua, believes that "Local by default is wrong." [1].

I don't necessarily agree that local-by-default is inherently wrong, but every implementation of local-by-default that I've seen has had flaws.

It looks like MoonScript is no different - its scoping rules seem to suffer from the same "madness" as CoffeeScript [2].

[1] http://lua-users.org/wiki/LocalByDefault

[2] https://donatstudios.com/CoffeeScript-Madness

Post reply on HN