Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

to HN readers: I can make LiteScript compile to PHP or C.

To PHP: If you have only PHP in your hosting, you can have LiteScript source and compile for node.js or PHP.

To C: (node native module/nginx module), when you need a ultra-fast service, and js/V8 is not fast enough.

Any of this two compiler targets make sense for you?



Sounds... incredible.

A few questions:

- Which object model & garbage collector system are you using? (in C)

- How do you handle scoping differences between JS/PHP/C?

- Which bignum and string libraries are you using in C? Is the String library fully unicode happy?

- How do you deal with 'eval', and other JS-specific functionality?

- You mention the classes being easily turned into C++ classes... how does that work with the dynamic nature of POJO objects, when at any time new methods and properties can be added to any object, or prototype?

Sounds intriuging, anyway...


Great questions!, I guess I didn't express myself correctly.

I meant: LiteScript is designed with the Grammar https://github.com/luciotato/LiteScript/blob/master/source/G... separated from the "production" of target code https://github.com/luciotato/LiteScript/blob/master/source/P...

I "want" to (and think I can) add new "producer" modules other than "producer_js", but I've not even started.

The idea -so far- is to compile to a node native extension http://nodejs.org/api/addons.html#addons_hello_world so most C answers are: V8's

With respect to PHP, I think it's simpler. The idea is to generate PHP but do not support all PHP quirks, just generate PHP code that is "js-like", (PHP mimics allmost all js functionality) and have support libs in LiteScript unifying APIS.

Some things like "eval" can throw a compiler error, when the target is PHP.


Is LiteScript much simpler than JavaScript, and so you're able to compile it to C more easily?


Javascript itself it's not too hard to compile to C. The LiteScript added value will be to be able to test & debug as js, and then compile to C for production (adding all the boilerplate required for a nodejs extension).

The only thing I see as "easier to compile to C" (LiteScript vs js) is that in LiteScript you define classes & properties, so it's easier to define a C++ class from a LiteScript class.




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

Search: