Jump to content




COMPILING! SPEED! ONE FILE! CLOSED SOURCE!


  • You cannot reply to this topic
26 replies to this topic

#1 rahph

  • Members
  • 81 posts

Posted 10 May 2015 - 07: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 by kok, 11 May 2015 - 05:48 AM.


#2 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 10 May 2015 - 08: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!

#3 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 10 May 2015 - 08: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.

#4 rahph

  • Members
  • 81 posts

Posted 10 May 2015 - 08:04 PM

View PostCreator, on 10 May 2015 - 08:00 PM, said:

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!

View PostSquidDev, on 10 May 2015 - 08:02 PM, said:

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 by kok, 11 May 2015 - 05:46 AM.


#5 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 10 May 2015 - 08:07 PM

View Postkok, on 10 May 2015 - 08:04 PM, said:

-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 by SquidDev, 10 May 2015 - 08:09 PM.


#6 rahph

  • Members
  • 81 posts

Posted 10 May 2015 - 08:10 PM

View PostSquidDev, on 10 May 2015 - 08:07 PM, said:

View Postkok, on 10 May 2015 - 08:04 PM, said:

-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 by kok, 10 May 2015 - 08:11 PM.


#7 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 10 May 2015 - 08:14 PM

View Postkok, on 10 May 2015 - 08:10 PM, said:

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 by SquidDev, 10 May 2015 - 08:15 PM.


#8 rahph

  • Members
  • 81 posts

Posted 10 May 2015 - 08:37 PM

View PostSquidDev, on 10 May 2015 - 08:14 PM, said:

View Postkok, on 10 May 2015 - 08:10 PM, said:

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!

#9 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 10 May 2015 - 08:42 PM

View Postkok, on 10 May 2015 - 08:37 PM, said:

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...

View PostSquidDev, on 10 May 2015 - 08:02 PM, said:

...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.

#10 valithor

  • Members
  • 1,053 posts

Posted 11 May 2015 - 12:01 AM

View Postkok, on 10 May 2015 - 08:04 PM, said:

View PostCreator, on 10 May 2015 - 08:00 PM, said:

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 by valithor, 11 May 2015 - 12:04 AM.


#11 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 11 May 2015 - 12:43 AM

View Postkok, on 10 May 2015 - 08:10 PM, said:

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.

#12 rahph

  • Members
  • 81 posts

Posted 11 May 2015 - 05:44 AM

View Postvalithor, on 11 May 2015 - 12:01 AM, said:

View Postkok, on 10 May 2015 - 08:04 PM, said:

View PostCreator, on 10 May 2015 - 08:00 PM, said:

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...

View Posttheoriginalbit, on 11 May 2015 - 12:43 AM, said:

View Postkok, on 10 May 2015 - 08:10 PM, said:

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 by Lyqyd, 11 May 2015 - 05:52 AM.


#13 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 11 May 2015 - 06:00 AM

View Postkok, on 11 May 2015 - 05:44 AM, said:

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.

#14 rahph

  • Members
  • 81 posts

Posted 11 May 2015 - 06:18 AM

View Posttheoriginalbit, on 11 May 2015 - 06:00 AM, said:

View Postkok, on 11 May 2015 - 05:44 AM, said:

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.

#15 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 11 May 2015 - 06: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.

#16 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 11 May 2015 - 10: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...

#17 rahph

  • Members
  • 81 posts

Posted 11 May 2015 - 07:36 PM

View PostBomb Bloke, on 11 May 2015 - 10:35 AM, said:

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.

#18 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 11 May 2015 - 07:47 PM

Use this. It is called Compress.

#19 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 posts
  • LocationDoes anyone put something serious here?

Posted 11 May 2015 - 07:52 PM

View Postkok, on 11 May 2015 - 07:36 PM, said:

View PostBomb Bloke, on 11 May 2015 - 10:35 AM, said:

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 by SquidDev, 11 May 2015 - 07:52 PM.


#20 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 11 May 2015 - 09: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 by Cranium, 11 May 2015 - 09:15 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users