dyon icon indicating copy to clipboard operation
dyon copied to clipboard

Compile to byte-code or obfuscate(uglify)

Open ccll opened this issue 7 years ago • 5 comments

Often developers don't want to distribute script source in plain text, so compiling to byte-code (or obfuscation) is very useful, is this possible in the future of dyon?

ccll avatar Jun 02 '17 01:06 ccll

Yes, I believe this is a possibility. I wonder if I get time to work on it, though.

bvssvni avatar Jun 02 '17 02:06 bvssvni

Dyon executes code from AST, so the code is very high level if we serialize the AST. Breaking changes to the AST will break the code.

An alternative is storing meta data from Piston-Meta. This will make it possible to load code faster.

bvssvni avatar Jun 02 '17 21:06 bvssvni

Nice to know it's possible! I'm not a PL expert, but I guess it's easier to do obfuscation with the AST rather than compiling to byte-code? Right? For example renaming symbols to meaning-less a/b/c/d, like the uglifier for Javascript, I personally think this is more than suffice for a scripting language. Please correct me if I'm wrong.

ccll avatar Jun 05 '17 06:06 ccll

You could also use the meta syntax to rewrite the source code (using Piston-Meta to get the location of variables) and then inline the code with include_str!.

bvssvni avatar Jun 05 '17 11:06 bvssvni

I'll check it out, Thanks!

ccll avatar Jun 06 '17 00:06 ccll