Hacker News new | past | comments | ask | show | jobs | submit login

I know +1's are frowned upon here, but, err, +1? But, to cater to one of your criticisms - namely that the surface syntax of lua might be a bit better. It's not bad, per se, but it doesn't quite match the elegance of the lua's semantics or it's flexibility.

In which case, the regularity of lua's semantics come to the rescue. It's much easier than most to develop an alternative syntax which compiles down to it.

Notice I said "alternative syntax", and not "other language which transpiles to lua". Because in the case of moonscript (or yuescript) or fennel - you're still writing lua. Using lua semantics. With no runtime overhead.

Yes, you get this to varying degrees in other ecosystems (javascript et al). But it seems to me that the friction within lua is even lower. Once you buy into "closures all the way down" & "use tables for everything", then no matter what surface syntax you're designing, it's still, pretty much, lua.






I've made changes to the Lua/LuaJIT lexer/Parser to have a C like syntax and a program to convert Lua syntax to LJS syntax you can see it in the repositories shown bellow, the C api and language semantics remain the same.

- https://github.com/mingodad/ljs

- https://github.com/mingodad/ljs-5.4

- https://github.com/mingodad/ljs-5.1

- https://github.com/mingodad/ljsjit

- https://github.com/mingodad/raptorjit-ljs

- https://github.com/mingodad/CorsixTH-ljs

- https://github.com/mingodad/snabb-ljs

- https://github.com/mingodad/ZeroBraneStudioLJS


Cool! Did you fix new variables being global by default? What kind of checking is applied to the type annotations like `: string`?

No changes to "global by default" and no checking are made to type annotations. The idea was to be able to convert any existing Lua code automatically and get it working as before like I did with some non trivial projects like:

- https://github.com/mingodad/CorsixTH-ljs - https://github.com/mingodad/ZeroBraneStudioLJS


But I implemented a warning/error for variable shadowing.

I think the syntax could probably be improved, yeah, even though it's not really bad. You could even fix default-global at that level! The nil semantics and 1-based indexing in ipairs are maybe a little tougher.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: