News for hackers. Stuff that matters.
Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by rufugee on Wednesday April 24, 2013 @05:40PM (#5604178)
Looks interesting, but the use of "\" instead of "." is really a turnoff. Why do languages (I'm looking at you, PHP) think that using the backslash in any other way than escaping is a good idea?
Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by leafo on Wednesday April 24, 2013 @08:25PM (#5604959)
I really don't see why \ has anything do with escaping when not in the context of a string (or regex) literal. There is no ambiguity whatsoever. It's a shame more languages don't use it because it's easy to type (no shift required).
Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by Dissori on Thursday April 25, 2013 @02:27AM (#5605966)
It's not easy to type on some keyboard layouts such as the finnish one though (alt gr and - of american layout) http://frontype.com/keyboarding/540px-Computer-keyboard-Swed...
Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by danjessen on Saturday April 27, 2013 @06:23AM (#5617374)
I agree it's the same on a danish keyboard
Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by MichaelGlass on Wednesday April 24, 2013 @07:41PM (#5604749)
see https://github.com/leafo/moonscript/issues/35

. is taken. : is taken. propose a better alternate and maybe it'll end up in the language.

Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by fingerprinter on Wednesday April 24, 2013 @06:16PM (#5604354)
Couldn't agree more. I've am looking at Lua for a new project and got excited when I saw this. However, that syntax looks terrible.

What's worse, is it is inconsistent. Take:

  csrf.assert_token @
  Users\create name: @params.username
I don't get why they both can't be '.', which would be very readable and approachable to everyone.

All that said, this looks great given it is built on OpenResty (whose performance seems outstanding at initial blush). Wonder if anyone has deployed anything really big with it.

Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by jacktoole1 on Wednesday April 24, 2013 @07:36PM (#5604720)
I've used moonscript a lot, and don't particularly like the \ syntax. However, you get used to it quickly, and it stops seeming like such a big deal.

It would be hard to have both be '.', because of lua semantics: '.' means "get the property from the table", while ':' in lua and '\' in moonscript mean "get the function from this table, with the first parameter for that function bound to the table itself".

Javascript/Coffeescript can get away with both being '.' because of the horrible mess that is implicit 'this'. All functions have an implicit first parameter, that non-method functions usually ignore, and '.' in javascript does the equivalent of ':' and '\' in moonscript (for functions). I find the lua approach much simpler and cleaner, and think it is actually more approachable than the javascript way, because the difference between '.' and ':' or '\' is conceptually simpler than all the rules behind 'this' in javascript.

Programming in Lua explains ':' in http://www.lua.org/pil/16.html , and probably has a better explanation that I wrote :).

Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by danjessen on Saturday April 27, 2013 @06:34AM (#5617396)
Would you recommend learning Lua first before going into moonscript ?
Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by jacktoole1 on Thursday May 09, 2013 @07:52PM (#5683693)
I learned them concurrently, translating lua in Programming in Lua into the equivalent moonscript. It's a pretty strait-forward translation and is definitely doable. I already had experience with a reasonable variety of languages before learning it though, and for people still getting into programming, I think Lua is a simpler and still awesome language.

I don't think it's possible to learn moonscript without learning lua concurrently, since lua makes up so much of the underlying semantics. So I think the choice is either (a) learn lua, or (b) learn lua and moonscript for some nice syntactic sugar.

Re:Show HN: Lapis – A web framework for MoonScript and OpenR... by pygy_ on Wednesday April 24, 2013 @07:44PM (#5604766)
`.` and `\` in Moonscript map to `.` and `:` in Lua.

In Lua, `foo.bar` is just syntactic sugar for `foo["bar"]`, a table lookup with a string key.

In turn, `foo:bar(baz)` is syntactic sugar for `foo.bar(foo, baz)`.

It is not uncommon to mix things up, and put a dot instead of the column. IIRC, Leafo used the backslash instead because it is more distinct, visually.

    Users\create name: @params.username
is thus equivalent to

    Users.create( Users, name: @params.username )
(adding parens for maximum clarity).