This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
rahph's profile picture

COMPILING! SPEED! ONE FILE! CLOSED SOURCE!

Started by rahph, 10 May 2015 - 06:49 PM
rahph #1
Posted 10 May 2015 - 08:49 PM
So, everyone knows how SLOW computercraft comps are. But i have briliant idea! COMPILATION. Let me explain:
You have folder.
In this folder you put ALL code/assets of program.
You name main program (that makes next things work) just "Main" or "Startup".
You use sort of "cs" (for Closed Source) api. Take a look:

local www = cs.openAsset("texts/jokes/funlevel9000/joke1") --While the directory does not stand for actual directory. Use FS api for it. Instead it stands for asset location in programs main folder.
print(www)
There would be 2 programs. First:
"Compile"
Usage:

Craft OS 1.8
>compile myprog --myprog is directory of "startup" file for program
It would create myprog.exe (or so) file that would be ran normally by typing myprog.exe in prompt.
Second:
"Emulate"
Usage: Same as with compile, but it runs your program instantly in "debug" mode.
How would it speed up? Look at (propably true) way of running CC program: LuaJ —> Java Virtual Machine —> Actual CPU
After compiling: Hanlder (NON INTERPRETION!) —> JVM —> CPU.

Just imagine Os'es in it. Speed… Speed. SPEEEEED! + one file with no variable in code. What i mean by it is when you make program with all graphics in it you make billion variables. It is bad.

My thoughts:

Encrypting:
LuaJ: i was reading that it is capable of encrypting at speed of ~30kB/s
Compiled: it could be even ~200kB/s

I hope dan reads it :)/>/>
Edited on 11 May 2015 - 04:48 AM
Creator #2
Posted 10 May 2015 - 09:00 PM
If you want to be read and considered, maybe think about watching your language and making the post a little bit more professional. Else, I love the idea!
SquidDev #3
Posted 10 May 2015 - 09:02 PM
There are massive security issues with this. If you are suggesting what I think you are suggesting then people would be able to execute malicious Java bytecode on the server - never a good idea. If you really need improved performance I've written CC-Tweaks which, amongst many other features, adds a Lua to Java bytecode compiler.
rahph #4
Posted 10 May 2015 - 09:04 PM
If you want to be read and considered, maybe think about watching your language and making the post a little bit more professional. Else, I love the idea!
NO! Not language! i want actual compilibg! cuz making next language on top of CC is even more slowing down program processors!

There are massive security issues with this. If you are suggesting what I think you are suggesting then people would be able to execute malicious Java bytecode on the server - never a good idea. If you really need improved performance I've written CC-Tweaks which, amongst many other features, adds a Lua to Java bytecode compiler.
You are right. But even not java. Maybe some secured enviroment, some sort of emulator but thing that:
Adds closed source
Is faster
Can produce 1-file complex programs with apis, assets, code and even readme.





EDIT: I just got idea…
WARNING: STUPIDITY LEVEL: 305713465198243561/10
Maybe modify SNES emulator? :)/>/>
Edited on 11 May 2015 - 04:46 AM
SquidDev #5
Posted 10 May 2015 - 09:07 PM
-snip-
You are right. But even not java. Maybe some secured enviroment, some sort of emulator but thing that:
Adds closed source
Is faster
Can produce 1-file complex programs with apis, assets, code and even readme.

Well if you are desperate for 'closed source' you could look at converting your code into Lua bytecode (string.dump). There wouldn't be any performance increases though - but the only way you are going to get a performance increases is using the same compiler as CC-Tweaks.

There are already many utilities to package multiple files in one (Compilr, Packager, Howl, etc…)

An SNES emulator wouldn't increase performance whatsoever. You could have a look at JVML-JIT and write an SNES to Lua bytecode converter - or even better get an emscripten fork - that I would buy into.
Edited on 10 May 2015 - 07:09 PM
rahph #6
Posted 10 May 2015 - 09:10 PM
-snip-
You are right. But even not java. Maybe some secured enviroment, some sort of emulator but thing that:
Adds closed source
Is faster
Can produce 1-file complex programs with apis, assets, code and even readme.

Well if you are desperate for 'closed source' you could look at converting your code into Lua bytecode (string.dump). There wouldn't be any performance increases though - but the only way you are going to get a performance increases is using the same compiler as CC-Tweaks.

There are already many utilities to package multiple files in one (Compilr, Packager, Howl, etc…)

You see? i think you can easily just decompile from string.dump .
And i dont think CC-Tweaks would speed up programs even ten times (yeah… i want alot)

Thing about SNES emu: I was just playing SMW on emulator and i thinked of.. but it does not process data that fast… it may be true
Edited on 10 May 2015 - 07:11 PM
SquidDev #7
Posted 10 May 2015 - 09:14 PM
You see? i think you can easily just decompile from string.dump .
And i dont think CC-Tweaks would speed up programs even ten times (yeah… i want alot)

Thing about SNES emu: I was just playing SMW on emulator and i thinked of.. but it does not process data that fast… it may be true

LuaJC (what CC-Tweaks uses) is about 5x faster than LuaJ's default execution. Without utilising some very clever techniques (like LuaJIT does) you can't get any faster than that, and that would require a rewrite of most of LuaJ. My expertise of compiler optimisation is somewhat limited so I don't think I'd ever be able to achieve 10x performance.

Realistically, as Lua is a dynamic language, you just can't achieve the performance you are asking for - whatever approach you try.
Edited on 10 May 2015 - 07:15 PM
rahph #8
Posted 10 May 2015 - 09:37 PM
You see? i think you can easily just decompile from string.dump .
And i dont think CC-Tweaks would speed up programs even ten times (yeah… i want alot)

Thing about SNES emu: I was just playing SMW on emulator and i thinked of.. but it does not process data that fast… it may be true

LuaJC (what CC-Tweaks uses) is about 5x faster than LuaJ's default execution. Without utilising some very clever techniques (like LuaJIT does) you can't get any faster than that, and that would require a rewrite of most of LuaJ. My expertise of compiler optimisation is somewhat limited so I don't think I'd ever be able to achieve 10x performance.

Realistically, as Lua is a dynamic language, you just can't achieve the performance you are asking for - whatever approach you try.
You did not understand me correctly. I mean to use LuaJ but not to INTERPRET program in realtime but to compile it to code understandable by java. You still write in lua. You cant make malicious for server programs in interpreted lua. You could not either here!
MKlegoman357 #9
Posted 10 May 2015 - 09:42 PM
You did not understand me correctly. I mean to use LuaJ but not to INTERPRET program in realtime but to compile it to code understandable by java. You still write in lua…

…If you really need improved performance I've written CC-Tweaks which, amongst many other features, adds a Lua to Java bytecode compiler.

Basically, what you are suggesting here has been already made by SquidDev, except not on a scale you speculate it should be.
valithor #10
Posted 11 May 2015 - 01:01 AM
If you want to be read and considered, maybe think about watching your language and making the post a little bit more professional. Else, I love the idea!
NO! NOT language! i want actual COMPILING! cuz making next language on top of CC is slowing down bull****.

It appears you completely missed what he said. "watching your language" means to not swear. I do not even know how you possibly could have gotten the idea that he thought you meant to write another language.

All the caps also look unprofessional. They are simply not pleasant to read, and they add nothing to the post so there is no reason to have them.

The fixing of these two things will make your post more appealing, and as such have a better response from those who actually take the time to read it.
Edited on 10 May 2015 - 11:04 PM
theoriginalbit #11
Posted 11 May 2015 - 01:43 AM
You see? i think you can easily just decompile from string.dump.
you can easily decompile even Java bytecode, this point is mute. It seems that you have a misunderstanding of what closed-source and what compiling is, but in any case we'd never allow code on the forums that is obfuscated, it makes it easier for people to create and distribute malicious programs, something that is not allowed on these forums.

Also there becomes a point where a ComputerCraft computer simply cannot run any quicker, a point where Minecraft will always be the limiting factor. CC-Tweaks has done pretty much all that can be done in order to speed up the computers.
rahph #12
Posted 11 May 2015 - 06:44 AM
If you want to be read and considered, maybe think about watching your language and making the post a little bit more professional. Else, I love the idea!
NO! NOT language! i want actual COMPILING! cuz making next language on top of CC is slowing down bull****.

It appears you completely missed what he said. "watching your language" means to not swear. I do not even know how you possibly could have gotten the idea that he thought you meant to write another language.

All the caps also look unprofessional. They are simply not pleasant to read, and they add nothing to the post so there is no reason to have them.

The fixing of these two things will make your post more appealing, and as such have a better response from those who actually take the time to read it.
Ok. I will make my post better. I am also on mvy phone so i can only remove swears…

You see? i think you can easily just decompile from string.dump.
you can easily decompile even Java bytecode, this point is mute. It seems that you have a misunderstanding of what closed-source and what compiling is, but in any case we'd never allow code on the forums that is obfuscated, it makes it easier for people to create and distribute malicious programs, something that is not allowed on these forums.

Also there becomes a point where a ComputerCraft computer simply cannot run any quicker, a point where Minecraft will always be the limiting factor. CC-Tweaks has done pretty much all that can be done in order to speed up the computers.
Oh… But think about it from other side… Now complex programs can be one-file! Even entire os (maybe there would be save option to create virtual folders in this one compiled file!
Edited on 11 May 2015 - 04:52 AM
theoriginalbit #13
Posted 11 May 2015 - 07:00 AM
Oh… But think about it from other side… Now complex programs can be one-file! Even entire os (maybe there would be save option to create virtual folders in this one compiled file!
I'm not completely sure you know how compilers work, but sure… This is already possible, just take a look into Lua and you'll find that you can easily put everything into a single file, yes even an OS.
rahph #14
Posted 11 May 2015 - 07:18 AM
Oh… But think about it from other side… Now complex programs can be one-file! Even entire os (maybe there would be save option to create virtual folders in this one compiled file!
I'm not completely sure you know how compilers work, but sure… This is already possible, just take a look into Lua and you'll find that you can easily put everything into a single file, yes even an OS.
But it is hard. What i have to say is: you comfortably create foldered program (1 asset is one file) and the compiler puts ot into one file. You can say: oeeds packager. No. You need to "unpack" program before running it. It is not what i want.
MKlegoman357 #15
Posted 11 May 2015 - 07:25 AM
What TheOriginalBIT said was that it is completely possible and doable in plain Lua and it has already been done. Oeed has made Compilr which packs a program into a file which you can directly run without unpacking. There's also Howl.
Bomb Bloke #16
Posted 11 May 2015 - 11:35 AM
Though personally, I'd much rather see code used by multiple scripts placed into separate files, so you don't end up with a redundant copy of it in every script you install. That is, after all, much of the point of making an API…
rahph #17
Posted 11 May 2015 - 08:36 PM
Though personally, I'd much rather see code used by multiple scripts placed into separate files, so you don't end up with a redundant copy of it in every script you install. That is, after all, much of the point of making an API…
… You dont umderstand awesomeness of 1 file. Lets say game. On server. Game saves itself to executable. Everything is in it. You can easilly move it.
Creator #18
Posted 11 May 2015 - 08:47 PM
Use this. It is called Compress.
SquidDev #19
Posted 11 May 2015 - 08:52 PM
Though personally, I'd much rather see code used by multiple scripts placed into separate files, so you don't end up with a redundant copy of it in every script you install. That is, after all, much of the point of making an API…
… You dont umderstand awesomeness of 1 file. Lets say game. On server. Game saves itself to executable. Everything is in it. You can easilly move it.

Whether you should do it or not is a moot point. The key is that an emulated filesystem is pretty trivial and has been done many times before, most notably Compilr. This issue addresses two points:
  • Faster compilation: Achieved through CCTweaks
  • Multiple files in one: Can be done yourself - you can modify Compilr to allow write access too, well I guess it might be possible.
Edited on 11 May 2015 - 06:52 PM
Cranium #20
Posted 11 May 2015 - 10:15 PM
There is absolutely no improvement to the game that "compiling" a scripted language would do in this instance. Due to the simple and inescapable fact that Lua can be run from a single file anyway. Even the programs that use multiple files only do so because it makes writing and reading code much easier and cleaner. You can actually run any program that you want within a single line, no matter how long it is. Adding this function would have absolutely no improvement to ComputerCraft whatsoever.

The only time you would have any need whatsoever in compiling Lua code(with the exception of the rare bytecode if you're feeling fresh) would be to compile a Lua file into an executable for use outside of an interpreter. Since that's not the case, I can't possibly see a case use for adding this ability.
Edited on 11 May 2015 - 08:15 PM
theoriginalbit #21
Posted 11 May 2015 - 11:55 PM
… You dont umderstand awesomeness of 1 file. Lets say game. On server. Game saves itself to executable. Everything is in it. You can easilly move it.
fun fact: you can easily move a folder too
Creator #22
Posted 12 May 2015 - 06:21 AM
… You dont umderstand awesomeness of 1 file. Lets say game. On server. Game saves itself to executable. Everything is in it. You can easilly move it.
fun fact: you can easily move a folder too

Are you serious? *ironic tone*
rahph #23
Posted 12 May 2015 - 04:16 PM
EDIT: Question removed.
Edited on 12 May 2015 - 05:36 PM
Lupus590 #24
Posted 12 May 2015 - 04:32 PM
Dear administrator. Please close this topic.

use the report button
Creator #25
Posted 12 May 2015 - 05:06 PM
Or leave it open since other people may have an opinion too. There is no need to close it.

PS: I don't know what happened with my keyboard, but the post just duplicated. Can you please remove them.
Edited on 12 May 2015 - 03:08 PM
rahph #26
Posted 12 May 2015 - 07:35 PM
Or leave it open since other people may have an opinion too. There is no need to close it.

PS: I don't know what happened with my keyboard, but the post just duplicated. Can you please remove them.
Oh you are right…
ardera #27
Posted 19 May 2015 - 12:47 PM
Well, AOT (Ahead-of-Time) Compilation is not really an option, because storing the file somewhere in the filesystem would bring massive security issues, but JIT (Just-in-Time) Compilation is. CCTweaks uses JIT Compilation by using the LuaJC compiler instead of the normal one.