Teen Programmers Unite  


Return to forum top

P-Code? Native Code?

Posted by Brok3n_Link [send private reply] at June 20, 2003, 04:22:05 AM

In Visual Basic, what EXACTLY does compile to P-Code do?
What about Native Code? It says optimize for speed,size tc. but which is better and why?


Posted by regretfuldaydreamer [send private reply] at June 20, 2003, 06:01:21 AM

P-Code is like Java Bytecode as far as I know. It isn't an executable, you need some sort of interpreter at run time to run P-Code.

As for optimization, I'd go for speed. Neither are as important these days as they once were, but people would prefer a slightly larger file that runs fast than a slightly smaller file that runs slightly slower

Posted by buzgub [send private reply] at June 20, 2003, 07:12:43 AM

There are source code. There are executables. Somewhere between the two, there is bytecode.

Bytecode is the thing that java compiles to, that .net compiles to (they call it MSIL, the microsoft intermediate language), and even that python and perl compile to. All these things are bytecode, but they are different bytecodes in much the same way that all those languages have different syntaxes and every CPU's assembly lanuage is different. It is essentially a kind of pseudo-assembly that is then run through an interpreter. Compiling to bytecode takes time, but execution of such is faster than interpreting straight from source. It also allows for platform-independence.

P-code is bytecode. When you specify P-code, you are telling VB to compile to bytecode and add the mechanics to your final executable to make it run through the visual basic interpreter. When you specify native code, you are telling VB to compile to machine code. Native code is likely to be faster, but I imagine it has some disadvantages in the VB case. I don't know what they are, though.

Optimizing for speed and space - neither is definitively, always better. It's a tradeoff. That's why you have to choose.

I hope that all makes sense.

Posted by Brok3n_Link [send private reply] at June 20, 2003, 07:35:16 AM

Thanks a lot fellas.
That cleared it up for me.

Posted by Neumann [send private reply] at June 20, 2003, 08:15:49 AM

The immediate difference between a P-Code VB app and a native app is the size of the produced executable. P-Code is smaller.

But VB being VB, your program still need heavyweight runtime libs for both P-Code and native executable.

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.