Live data from Hacker News

MoonScript, a programmer friendly language that compiles to Lua

moonscript.org

81–90 of 171 posts

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

#81

Earlier quoted context omitted.

Can't agree with that. Having used both Lua and Moonscript quite a bit I think Moonscript is what most dynamic scripting languages should be. Simple, succinct and does what you need for a scripting language. I really enjoy using it.

Care to give an example?

The list comprehensions are really great. Most of the time when I'm writing Lua I can't be bothered to write exactly what Moonscript outputs for a list comprehension because it's noisy, but it's what I really would write if I cared about tiny amounts of performance.

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

#82

Earlier quoted context omitted.

Exactly. It's more intuitive and you have less `x-1`'s in your code.

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.

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

#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.

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

#84
post #50

Earlier quoted context omitted.

Except that that whitespace is not used only for that purpose, it could mean also something else, right? We trade an unambiguous set of characters --the parentheses-- by whitespace, and make it context sensitive. How is that now more readable? As someone who has had to match these whitespace based parenthesis I can tell you it's not more readable. It's more like someone determined that parenthesis were not visually p…

> 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…

> Languages often use '+' for both numeric addition and string concatenation

Perl uses . or ~ depending on which version you are using. It also uses braces for code blocks and postfixed ifs which prevents errors like:

  if (x)
    y
  z
Instead of:

  if (x)
    y
    z
It prides itself to being close to natural language yet still uses braces.

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

#85
post #15

Hey all, I made MoonScript about 6 years ago. I used it to build a ton of opensource stuff in addition to the company I founded. I use it every day and I'm very happy with how it's turned out. I regret not updating the language more frequently, but I've been busy building a bunch of stuff in it. The biggest open source project is a web framework for Open Resty: https://github.com/leafo/lapis It's used for the followi…

If you were to devote more time to MoonScript, what would be the likelihood of including Lua 5.3 compatibility?

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

#86

I was on a team that used Lua in production on tens of thousands of machines running 24/7. The Lua interpreter was the weak link in the system, requiring at least daily restarts. Squashed so many bugs over the years, and still found more and more all the time. What I'm saying is, the Lua interpreter itself is flawed and I can't imagine using it as a runtime if I had the chance to avoid it. That said, the language was…

This page lists every known bug in the Lua interpreter for the last 14 years, along with its fix: https://www.lua.org/bugs.html The average is 8 bugs per year, most fairly obscure. Every Lua release fixes all known bugs. Roberto, the chief architect, is kind of fanatical about quality: https://www.youtube.com/watch?v=yU5QNKpATxk I do not believe the interpreter is as flawed as you claim.

I think Lua interpreter itself is fairly stable. But the problem is that it lacks the proper mechanism for language upgrade or deprecation---for example we have found a (undocumented) bug affecting Lua 5.1.x which has been silently fixed in 5.2, but we were stuck at 5.1 so we had to fork the interpreter. That kind of things. The development process of Lua is definitely flawed in my humble opinion.

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

#87

I was on a team that used Lua in production on tens of thousands of machines running 24/7. The Lua interpreter was the weak link in the system, requiring at least daily restarts. Squashed so many bugs over the years, and still found more and more all the time. What I'm saying is, the Lua interpreter itself is flawed and I can't imagine using it as a runtime if I had the chance to avoid it. That said, the language was…

This page lists every known bug in the Lua interpreter for the last 14 years, along with its fix: https://www.lua.org/bugs.html The average is 8 bugs per year, most fairly obscure. Every Lua release fixes all known bugs. Roberto, the chief architect, is kind of fanatical about quality: https://www.youtube.com/watch?v=yU5QNKpATxk I do not believe the interpreter is as flawed as you claim.

Agreed. In my experience it is extremely solid code. I haven't come across anything that I could imagine leading to a need for daily restarts.

And I speak as someone who reported one of the bugs on their bugs page.

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

#88

I was on a team that used Lua in production on tens of thousands of machines running 24/7. The Lua interpreter was the weak link in the system, requiring at least daily restarts. Squashed so many bugs over the years, and still found more and more all the time. What I'm saying is, the Lua interpreter itself is flawed and I can't imagine using it as a runtime if I had the chance to avoid it. That said, the language was…

This page lists every known bug in the Lua interpreter for the last 14 years, along with its fix: https://www.lua.org/bugs.html The average is 8 bugs per year, most fairly obscure. Every Lua release fixes all known bugs. Roberto, the chief architect, is kind of fanatical about quality: https://www.youtube.com/watch?v=yU5QNKpATxk I do not believe the interpreter is as flawed as you claim.

[deleted]

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

#90
post #84
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…

> Languages often use '+' for both numeric addition and string concatenation Perl uses . or ~ depending on which version you are using. It also uses braces for code blocks and postfixed ifs which prevents errors like: if (x) y z Instead of: if (x) y z It prides itself to being close to natural language yet still uses braces.

I'm aware, and Perl is specifically what I had in mind when I noted that. It's a little different of a case in Perl than in a language that is more strongly typed, like Python, as Perl uses operators to cast into the appropriate types for the operation and Python makes it an explicit action (which is why Perl has separate operators for most string and numeric operations, such as and gt, == and eq, etc). A Python programmer without much experience in Perl might think this is a case of implicit action, but it's actually rather explicit, as the string and numeric specific operators explicitly define exactly what to do with the two operands.

It's a pet peeve of mine that languages have promoted + for addition and string concatenation when concatenation and addition are distinct concepts that don't really share a lot in common beyond the surface. To me, in new languages, it signals that someone likely hasn't thought through that issue very clearly, or has and just doesn't care about consistency (which I think it important in a language). Python at least has the excuse of age (even if it's not all that old compared to many others).

Post reply on HN