Live data from Hacker News

MoonScript, a programmer friendly language that compiles to Lua

moonscript.org

121–130 of 171 posts

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

#121
post #116

Earlier quoted context omitted.

The love2d community is definitely still active, especially on IRC. Some of the nicest folks I've ever spoken to over the internet. I can't recommend the language or its community highly enough.

A couple of friends just successfully launched a commercial game on android/ios/steam using love2d, and they're really happy with the results. I couldn't believe it was made with lua, it runs really smooth. http://midipixel.com/warlockstower/

The love2d source code is in C++. I believe Lua interpreter was embedded as a scripting mechanism

https://bitbucket.org/rude/love/src

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

#122
post #56

Earlier quoted context omitted.

Except that arrays start on 1, right?

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

As Jef Raskin famously observed: "intuitive" just means "familiar". O- vs 1- based indexing is a source of curious passion for many people, as it really just reflects what you first learned and (consequently) what mental model you are using. Like most matters of taste, there is no objectively correct answer.

If you came up in assembly language and C, like me, you tend to think of array indices as offsets, and the first item obviously has an offset of 0. Anything else is absurd. If you came up in any number of environments that view collections like arrays from the standpoint of something like set theory, then the first (1st!) item clearly has an index of 1. What would a zeroeth item even mean?!. See---it's just point of view and familiarity.

I resisted Python for years because I just couldn't get past the clearly fragility and cognitive burden of something so mind-bogglingly stupid as meaningful whitespace. It took me a while to realize this was much more about me than about Python.

You bounce off of these contextual things all the time in Mathematics: Is 1 prime? Do the Whole numbers include 0? Etc., etc. The answer is---depends on who you ask and what you're working on. It can be implicit, especially to a community (like, say, users of a programming language), or it may need to be explicit to avoid confusion "In this house, we obey the Fundamental Theorem of Arithmetic! 1 is not prime!" As long as you get those particular ducks in a row, the problem is mostly just impedance from people mistaking their personal experience for natural law.

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

#123
post #94

Earlier quoted context omitted.

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.

any kind of numerical method (RKs, FDs, CN) where the n-th step a_n = f(a_(n-1)) and hence you define NUM_STEPS and the the result is a[NUM_STEPS] where a is your numerical lattice. you could work in a 0-based index and your n-th step is a_(n-1) and so the final step is a[NUM_STEPS - 1] in numerical analysis I don't believe i've ever cared that much about slicing. if i wanted to look at a single element in a matrix a…

I don't really get your reasoning.

For an iterative method, you have an initial value a[0], then take your NUM_STEPS steps, so the final result is a[NUM_STEPS]. If it's one-based, the final result is a[NUM_STEPS+1]. This type of thing trips up my Matlab (one-based) students all the time.

In zero-based linear algebra, the indices i and j start at 0, so the top left entry of a matrix is a[0, 0], the pivot element is a[i, j] and the pivot row is a[i, :]. There isn't any adjustment needed.

Finite differences, Simpson's Rule, etc., seem more natural with zero-based too. x_0 is the left-most value, x_n is the right-most value, and the interval is divided into n pieces.

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

#124
post #110

Earlier quoted context omitted.

I have to say that if I see last update in changelog from few years ago I assume the project is dead and one should not use it.

You should disabuse yourself of this notion, a lot of mature projects don't get updates because they don't have (known) bugs or are feature complete.

I don't do this with everything, it depends on what the project is and what my use of it would be. But with libraries or anything that would be a part of something you might find it won't work with your next OS update, browser update (js libraries), or it requires dependencies that are obsolete. I think it's a fair and quick filter.

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

#125
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] htt…

You can use 'local' to have sane scoping (shadowing) in moonscript though:

    -- will print:
    -- 15
    -- 0
    -- 15
    -- 10

    y = 0
    goodfun = (x) ->
        local y
        y = 10
        y + x
    
    badfun = (x) ->
        y = 10
        y + x
    
    print(goodfun(5))
    print(y)
    print(badfun(5))
    print(y)

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

#126
post #101
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…

The font you are using looks broken to me. (Win 10, Firefox) At 100% scaling, every "i" clearly looks like a "1". It reads "MoonScr1pt" for me: https://i.imgur.com/Ti12E5I.png If I zoom in or out in the browser the i looks ok again.

I don't see that at all. Maybe you found a bug for Win10/FF? I am on Win7/FF.

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

#127
post #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 g…

Very cool! I can live without implicit returns. Thanks for the info!

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

#128
post #63

Earlier quoted context omitted.

Moonscript uses local by default (compiles to Lua). Here is your code in Moonscript: foo = { x: {1, 2, 3}, y: (a, b, c) -> sum = a + b + c sum * sum }

Yeah, now just strip away all the other stuff and we'll be good.

Not sure why this was so controversial... I mentioned my requirements in my original post and moonscript clearly doesn't satisfy them. Sorry if that hurts feelings...

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

#129
post #123

Earlier quoted context omitted.

any kind of numerical method (RKs, FDs, CN) where the n-th step a_n = f(a_(n-1)) and hence you define NUM_STEPS and the the result is a[NUM_STEPS] where a is your numerical lattice. you could work in a 0-based index and your n-th step is a_(n-1) and so the final step is a[NUM_STEPS - 1] in numerical analysis I don't believe i've ever cared that much about slicing. if i wanted to look at a single element in a matrix a…

I don't really get your reasoning. For an iterative method, you have an initial value a[0], then take your NUM_STEPS steps, so the final result is a[NUM_STEPS]. If it's one-based, the final result is a[NUM_STEPS+1]. This type of thing trips up my Matlab (one-based) students all the time. In zero-based linear algebra, the indices i and j start at 0, so the top left entry of a matrix is a[0, 0], the pivot element is a[…

yeah i think maybe numericals aren't the best example since the initial value is always labeled x_0 and if you want to create a 2d array with the first array your X_0s then creating an N + 1 array makes sense.

your matrix example is totally bizarre though. the top left of a matrix A is always A_(1,1). so not sure what a[0,0] means. a 1x1 matrix is always 1 element, which is a[1,1]. the number of elements in a mxn array is m*n.

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

#130

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.

Well, this was a few years ago to be fair, and we probably had one of the largest and most intensive Lua deployments in production at that time, if I had to guess. I'm just reporting my experience then, which is just what I experienced. I'm glad to hear that maybe it's better now, and I very much appreciate the hard work and dedication of the developers behind it!
Post reply on HN