Compiling vs. Byte compiling 
Author Message
 Compiling vs. Byte compiling

What is exactly the difference? Is the byte-compiled code still interpreted?

Janos Blazi



Wed, 17 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> What is exactly the difference? Is the byte-compiled code still
> interpreted?

This is a common question, and I asked it too.  I'm not quite sure
there is a universally correct answer, though.

compilation is a broad term that suggests translating code from one
language into another, and (usually) implies optimization along the
way (at least in my mind).

Byte compilation often refers to compilation into instruction chunks
called "bytecodes".  These codes are usually at a higher level than
machine code, and so usually a bytecode interpreter will read the
bytecodes and then perform the machine-specific operations.

This is the distinction between something like ACL (Franz) and CLISP.
The former will compile Lisp into native machine code while the latter
compiles Lisp source into bytecodes that the bytecode interpreter will
use.

There is usually a big win associated with byte compilers in the sense
of portability, simplicity, etc.  I've never written a compiler for
Lisp, but my guess would be that writing the Lisp-to-bytecode compiler
is a simpler task (especially since the bytecode language can be
designed with Lisp in mind, whereas most machine codes are not).
Then, you can work separately on the problem of byte-code to
machine-code.

I think, in the end, better performance can be gained by skipping the
bytecode layer.  Again, more people will surely follow up, so some of
the experts in this field may give you more guidance.

dave

--
-----------------------------------------------------
Get your email delivered to your cell phone for free!
Go to http://www.mailmycell.com
-----------------------------------------------------



Wed, 17 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> What is exactly the difference? Is the byte-compiled code still interpreted?

Byte code is typically code for an abstract machine, usually much
simpler than a real machine, for which there exists an interpreter
which runs these byte-compiled programs.  Byte codes have the
advantage that they're portable, typically more compact than native
code, and that you only have to write the byte code interpreter for
each new system, not a whole native compiler. There may also be a
further compilation stage which translates byte codes into real
machine code, and this may sometimes happen on the fly, and only on
demand.

Although they don't call it byte compiled (do they?), Java is a good
example of a system like this, complete (nowadays) with a byte-code to
native-code compiler.

of Lisps in common use, I think CLISP is entirely byte compiled, while
CMUCL has both a byte compiler and a (heavy-duty) native compiler.

--tim



Wed, 17 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling


Quote:

>> What is exactly the difference? Is the byte-compiled code still interpreted?

>Byte code is typically code for an abstract machine, usually much
>simpler than a real machine, for which there exists an interpreter
>which runs these byte-compiled programs.  Byte codes have the
>advantage that they're portable, typically more compact than native
>code, and that you only have to write the byte code interpreter for
>each new system, not a whole native compiler.

Often the byte code interpreter is written in some other high level
language, so it's also portable.  A good example of this is Emacs Lisp.

--

GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.



Thu, 18 Apr 2002 02:00:00 GMT  
 Compiling vs. Byte compiling

Quote:


> > What is exactly the difference? Is the byte-compiled code still interpreted?

> Byte code is typically code for an abstract machine, usually much
> simpler than a real machine,

sometimes this code is executed by a real (-> hardware) machine.


Thu, 18 Apr 2002 02:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> What is exactly the difference? Is the byte-compiled code still interpreted?

IMHO, the term "compilation" is abused.  The term "translation" is probably
better.  Currently, the parameter which separates "byte-code" from
"native-code" translators lies in the answer to the question "who
executes what".

A "byte-compiler" translates to "something" which is executed by
another program.  The most notable cases around today are Emacs (you
have not answered the question whether you are using Emacs or not :)),
and Java.  Emacs contains a "byte code interpreter" which executes
"byte coded Emacs Lisp".  Java comes with a Virtual Machine which is
nothing less than an intepreter for Java byte codes.

A "native-code" translation of a program is run by the underlying
hardware.  The number of levels between the two extremes may be great.

(Common) Lisp is usually translated to native code (apart from the
CLisp implementation which translates to byte code).

CMUCL has native code translators and a byte code translator.
The major commercial implementations (ACL, LWW, Liquid, MCL, Corman)
have native code translators.

GCL translates to (human-unusable) C, which in turns is translated to
native code, as does (I believe - Howard can correct me) Eclipse.

OTOH, Lisp high level form (i.e. S-exps) is already amenable of direct
executuion by means of a program (i.e. the interpreter) which is
present in every implementation.

Does this clarify the issues?

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa



Thu, 18 Apr 2002 02:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> GCL translates to (human-unusable) C, which in turns is translated to
> native code, as does (I believe - Howard can correct me) Eclipse.

With the difference that Eclipse by design generates _human-usable_ C,
quite unlike GCL, as far as I understand it.

Quote:
> OTOH, Lisp high level form (i.e. S-exps) is already amenable of direct
> executuion by means of a program (i.e. the interpreter) which is
> present in every implementation.

Not every implementation has a real interpreter, some always compile and
execute (i.e. eval invokes the compiler and executes the result).  IIRC
then at least MCL and Corman Lisp are examples of this.  CMUCL does have
an interpreter, but it works on the same internal representation, that
the later stages of the compiler work on (i.e. interpreter and compiler
share the first stage(s)), IIRC.

Quote:
> Does this clarify the issues?

The above might muddy things more thant it clarifies them, but should
demonstrate to the original poster that issues of compilation and
interpretation are not at all clear cut (as is often presented).  They
involve many small and large trade-offs.  But most of this is
transparent to the user (at least in Common Lisp), so he shouldn't
overly concern himself with the internal details of implementing CL,
as long as things are fast enough for his designs.

Regs, Pierre.

--

  "One smaller motivation which, in part, stems from altruism is Microsoft-
   bashing." [Microsoft memo, see http://www.opensource.org/halloween1.html]



Thu, 18 Apr 2002 02:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> IMHO, the term "compilation" is abused.  The term "translation" is probably
> better.  Currently, the parameter which separates "byte-code" from

Why is something called "byte-code"? A byte-code is just a special
encoding of instructions. A virtual machine does not need to
run byte-codes (for example the x86 emulators for the PowerPC).
The was for example a bit-slice processor running natively
the byte-code of the UCSD Pascal system (P-Code).

So, I think the term "byte-code" can be misused.

Quote:
> "native-code" translators lies in the answer to the question "who
> executes what".

> A "byte-compiler" translates to "something" which is executed by
> another program.

Possibly, but not necessarily. See above.

Quote:
> A "native-code" translation of a program is run by the underlying
> hardware.  The number of levels between the two extremes may be great.

I could generate "native-code" on my Mac with LispWorks. Unfortunately
this "native-code" is then interpreted by Virtual PC.


Thu, 18 Apr 2002 02:00:00 GMT  
 Compiling vs. Byte compiling

Quote:
> have not answered the question whether you are using Emacs or not :)),

Sorry, I must have overseen the question. Yes, I use EMACS and wrote two or
three hundred lines of EMACS LISP code.
After that my EMACS have behaved like a strange mixture of NT and my old
BRIEF editor which L loved very much. (I prefer EMACS now.)

This was the first time I came across LISP and I was enthralled with it.
Then I downloaded CLISP. In the documentation you can read that "the book by
Steele is the best text book I know", but this was not written by Bruno
Haible, it was written by somebody else. The very same day I borrowed the
book from the library of the university and ordered the book by Graham. I
also borrowed a German book on LISP wich turned out to cover Nils' LISP
mainly but also covered CL to some extent.

Then I was angry as I found the German book  bizarre for different reasons
and the book by Steele was a scholarly work or a reference manual rather
than a textbook for beginners. As a beginner you are not very much
interested in how XJ3delta-gamma voted on the 12th September 1989 and you
would prefer more examples. Also it seemed to me as if the metalanguage he
used was a bit unusual. So I was angry and then I looked at the Amazon.com
web site and the Barnes and Noble web site. I have been their customer for
some time. And then I saw that no books were written in the last two or
three years (or to put it more precisely no new books were published).

But I then visited the LISP home page and found the book by Lamkins and it
is a VERY NICE book, it is a pity that he cannot publish it. Publishing such
a book on a CD does not satisfy me as I want to read books in my bed and on
the toilet and on the train an everywhere.

So by then I had had enough books. Suddenly several people started talking
about their own bookshops and about other interesting things. I was
fascinated as I even could learn a lot about the bookshops in the world, not
only about LISP.

I only mentioned those bookshops I could reach as they proved the vanishing
demand for LISP. And then some people started hating me but this is not
unusual. Clearly the guy who shouted "FIRE" must be the arsonist.

Janos Blazi

Well, that's the way it is.



Thu, 18 Apr 2002 02:00:00 GMT  
 Compiling vs. Byte compiling

Quote:
> some time. And then I saw that no books were written in the last two or
> three years (or to put it more precisely no new books were published).

That's no big problem. Common Lisp is around quite some time.

Get PAIP, AMOP, Lisp 3rd Editon, etc. and then come back
when you read it.

Then read the manuals of your favorite Lisp system. My
Lisp Machine for example has a meter worth of documentation.



Fri, 19 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> I only mentioned those bookshops I could reach as they proved the vanishing
> demand for LISP. And then some people started hating me but this is not
> unusual. Clearly the guy who shouted "FIRE" must be the arsonist.

1. The point of shouting "Fire!" is to enable everyone to get out
   before they burn to death. What's the point of shouting "Lisp
   is dying!", even if it's true? What do you propose to do about
   it?

2. If you shout "Fire!" in a crowded building where there *isn't*
   a fire, a lot of people can get badly hurt in the stampede.
   Why not take some steps to establish whether there really is
   a fire or not, before shouting about it?

3. If you shout "Fire!" in a large shop and everyone runs away,
   they'll have some justification for complaining that you've
   harmed their sales and been the cause of damage to their stock
   when everyone rushes out. Don't you think it's rude to
   proclaim the death of something people are working on and
   making a living from, if you don't have really solid evidence?

It's not a matter of hating *you*, by the way. Just objecting
to the same tired old claims being bandied about without enough
evidence. The world is full of people announcing the death of[1]
Lisp, socialism, capitalism, evolution, Christianity, science,
artificial intelligence, and a million and one other things which
in fact seem likely to last longer than their critics will. Is it
any wonder that some people get annoyed at hearing the same
claim made for the 101st time?

[1] Apart from the inclusion of Lisp, the list is arbitrary.

--

sig under construction



Fri, 19 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling
O.K., this was an honest letter and I am going to answer honestly.

Quote:
> 1. The point of shouting "Fire!" is to enable everyone to get out
>    before they burn to death. What's the point of shouting "Lisp
>    is dying!", even if it's true? What do you propose to do about
>    it?

I actually did not shout fire but I smelled some smoke and ASKED if there
could be a fire. This means: I never told LISP was dying. I could not have,
as I did not know almost anything about LISP when we started but for those
few lines of EMACS LISP code I had written. And my purpose was simply to
find out about the state of affairs at the moment. I have found out about
it. So from this point of view this is an excellent newsgroup.

Quote:
> 2. If you shout "Fire!" in a crowded building where there *isn't*
>    a fire, a lot of people can get badly hurt in the stampede.
>    Why not take some steps to establish whether there really is
>    a fire or not, before shouting about it?

I have partly answered this question already. I do not think anybody got
hurt; I may have (inadvertantly) hurt some people's feelings but I am sorry
for that and I would like to apololgize. I must admit the reaction came as a
complete surprise to me, I did not know about similiar discusions before and
I was stunned how angry some people became. It seems though that I touched
an open wound. Again: I did not know and if I had known that in advance I
would not have asked.

There is no proof whatsoever that some people abandoned LISP after reading
this discussion. I was not talking to a "crowd". I was talking to LISP
experts, I was talking to the chosen Few. So as far I can see there is no
proof for any damage.

Quote:
> 3. If you shout "Fire!" in a large shop and everyone runs away,
>    they'll have some justification for complaining that you've
>    harmed their sales and been the cause of damage to their stock
>    when everyone rushes out. Don't you think it's rude to
>    proclaim the death of something people are working on and
>    making a living from, if you don't have really solid evidence?

Again, I did not proclaim anything. I just asked. And I asked on the grounds
of some cicumstantial evidence I had found. So if you maintain that I caused
damage to anybody you would have to prove that. I do not think the LISP
sales went down after my message.

And it makes a difference if your ideas are rude or the way you present
them. Ideas are seldom really rude; the can be unexpected, heretic
thought-provoking, weird e.t.c. I like to look at new, fresh ideas. After
some time then it is time for a judgement. I am very tolerant in the
beginning and after some time I keep on living with some of the new ideas
and I dismiss others. I always look at things from several different sides
at the same time.
Huxley wrote in "Eyeless in Gaza" that we should have several sets of eyes
to read several books at the same time as life is short and books so
infinetely many. I should like to have several sets of eyes to read the same
book with them with several attitudes at the same time.

But if you use rude language everything is different. You probably feel that
your means of expressing your thoughts in a language are not adequate and
this of course happens to many of us as English is not our native tongue.
There may be other reasons for feeling inferior. We all suffer from this.
But still most people try to use decent words. There is no excuse for using
rude language, no excuse at all.

Quote:

> It's not a matter of hating *you*, by the way. Just objecting
> to the same tired old claims being bandied about without enough
> evidence. The world is full of people announcing the death of[1]
> Lisp, socialism, capitalism, evolution, Christianity, science,
> artificial intelligence, and a million and one other things which
> in fact seem likely to last longer than their critics will. Is it
> any wonder that some people get annoyed at hearing the same
> claim made for the 101st time?

Again I have not proclaimed anything. And after all, you cannot blame me for
things that happened before I was "borne" i.e. before I started asking
questions. May you can blame me that I had not read in deja.com what
happened in the newsgroup months ago. But this would be a bit unusual. But
if everything so happend (and I am  sure you are right): Then it would have
been enough if somebody ghad written "Wekll, this question is being asked
here periodically, please look at the FAQ "xxx" " or "well LISP is not
really dying and there are still a few thousand devotees around the world
who do good work so you can get all help you need here..." or something like
this.

Instead the first answer I received started with "o.k., let us flame on:". I
was very naive, I did not understand the expression "flame on" then. I have
understod it by now.

Announcing the dead of Christianity would be very stupid indeed, so stupid
that nobody would respond to it. Even the mythology of the ancient Greeks is
not dead, though there are not many people nowadays who believe that there
are Gods who live in the mountains. So if you compare my question I posted
with such stupidity then I must conclude that you do not appreciate me very
much, to say the least. It is all right.  But do you really think that LISP,
however nice it is, can be compared with such wonderful ideas like
Christianity or socialism, ideas that once change the world?

And finally: Isn't it fascinating that we are discussing such things after I
asked a technical question about byte compiling?

Quote:
> [1] Apart from the inclusion of Lisp, the list is arbitrary.

Nothing is arbitrary in my response.

Janos Blazi



Fri, 19 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> So, I think the term "byte-code" can be misused.

Surely so!

Quote:
> I could generate "native-code" on my Mac with LispWorks. Unfortunately
> this "native-code" is then interpreted by Virtual PC.

Of course, you could also interpret it yourself :)  Even better, we
could write an x86 emulator (read x86 Virtual Machine) in Common Lisp
:)

Cheers

--
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa



Fri, 19 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling

Quote:

> There is no proof whatsoever that some people abandoned LISP after reading
> this discussion. I was not talking to a "crowd". I was talking to LISP
> experts, I was talking to the chosen Few. So as far I can see there is no
> proof for any damage.

Not at all: you were posting to a newsgroup which might be read by
*anyone*, and on empirical evidence is often read by people who are
not Lisp experts (for instance, you!).

--tim



Fri, 19 Apr 2002 03:00:00 GMT  
 Compiling vs. Byte compiling
I wrote a  detailed response to a response to another response...
And then you write a response and take a line from my message. It is a line
that was not entirely correct I admit. And you point out this to me.

Well, you are right of course. But it is mostly read by experts or by people
who are seriously interested (like me). And I cannot rule out the
possibility either that the newsgroup is read by others as well.

But that was my point.



Quote:

> > There is no proof whatsoever that some people abandoned LISP after
reading
> > this discussion. I was not talking to a "crowd". I was talking to LISP
> > experts, I was talking to the chosen Few. So as far I can see there is
no
> > proof for any damage.

> Not at all: you were posting to a newsgroup which might be read by
> *anyone*, and on empirical evidence is often read by people who are
> not Lisp experts (for instance, you!).

> --tim



Fri, 19 Apr 2002 03:00:00 GMT  
 
 [ 23 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Is Ruby interpreted or byte-compiled?

2. byte compiled files

3. Q: Byte-compiling out of place

4. Running byte compiled code with tclsh 8.4

5. how can i byte compile my tcl code?

6. Byte code compiling

7. Byte-compiling lisp interpreter required

8. Direct Access to byte-compiled objects ?

9. Byte codes and compiled methods

10. Usage of compile ?compile >mark <mark <resolve >resolve

11. (postpone babble: using postpone in interpret-mode to compile compile-only words)

12. COMPILE, [COMPILE], POSTPONE

 

 
Powered by phpBB® Forum Software