You are not logged in.

#1 2005-01-26 15:40:38

hiower4
Member
Registered: 2004-07-31
Posts: 38

programming question

Hello all,
thought for some time if this should go int "off-topic" or "other languages" wink

I'm wondering why there are no programming languages that can be both interpreted and compiled? Or have i missed some? Is there anything in one blocking the other?

regards


#348498 +(4737)- [X]

<MasterG> .....................................................................
          ..................................
<judas> where's pacman when you need him?

Offline

#2 2005-01-26 20:20:38

mico
Member
From: Slovenia
Registered: 2004-02-08
Posts: 239

Re: programming question

I'm wondering why there are no programming languages that can be both interpreted and compiled?

There is Java, I'm sure you heard of it. First it is compiled into bytecodes, then this is "interpreted" on JVM.

IMHO this in most cases wouldn't make muche sense, because this approach would usually just combine the bad sides of both types of languages.

Maybe a language that could be either interpreted or compiled (not both) would be more interesting, but I don't know if there is one.

Offline

#3 2005-01-26 20:31:53

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: programming question

pyrex compiles Python into compiled binaries...

And there's a tool for compiling Java to binary too, I think.

Dusty

Offline

#4 2005-01-26 21:24:37

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: programming question

mico: I think he meant "interpreted OR compiled" as in you can run it like a script, or compile it to binary form

There are no languages like that because, from a logical standpoint, it just doesn't fit.  Kinda like "why aren't there any vegetables that are both a potato and an onion?".  The thing is, interpreted languages are still compiled, it's just done on the fly - just in time compiling, as some call it.  Python is the closest to what I suspect you're talking about... `python my_script.py` will run a python script, but it also outputs a "my_script.pyc" file, which is a compiled (think java bytecode) form of the source.  Timestamps are compared on each run, and if at all possible it runs the pre-compiled version.

Does that help any?

Offline

#5 2005-01-26 21:37:15

crimbil
Member
Registered: 2004-10-10
Posts: 20

Re: programming question

I think there are some tools that can compile Java to native machine code. E.g. http://gcc.gnu.org/java/, http://www.excelsior-usa.com/jet.html

Offline

#6 2005-01-26 21:49:09

xerxes2
Member
From: Malmoe, Sweden
Registered: 2004-04-23
Posts: 1,249
Website

Re: programming question

the point with scripting languages is that you don't do any memory management and you don't have to define the type and size of the variables, also eval() and such like statements are not possible to compile to native binaries,


arch + gentoo + initng + python = enlisy

Offline

#7 2005-01-26 22:34:15

TsaTsaG.
Member
Registered: 2005-01-26
Posts: 6

Re: programming question

AAhhhh, teh beauty of Lisp...

http://lush.sourceforge.net/index.html -- LUSH, based on Lisp
http://www.cons.org/cmucl/ -- Common Lisp
but maybe also
http://www.ocaml.org -- Ocaml, if you can get along with a ML based language; not a real interpreter but compiles on the fly, giving the impression "as if interpreted"

Offline

#8 2005-01-27 14:25:21

hiower4
Member
Registered: 2004-07-31
Posts: 38

Re: programming question

Dusty wrote:

pyrex compiles Python into compiled binaries...

Do you mean:http://nz.cosc.canterbury.ac.nz/~greg/python/Pyrex?

This seems to first translate python into C and then compile...?
Why not a native python compiler?


#348498 +(4737)- [X]

<MasterG> .....................................................................
          ..................................
<judas> where's pacman when you need him?

Offline

#9 2005-01-27 14:37:58

hiower4
Member
Registered: 2004-07-31
Posts: 38

Re: programming question

phrakture wrote:

mico: I think he meant "interpreted OR compiled" as in you can run it like a script, or compile it to binary form

There are no languages like that because, from a logical standpoint, it just doesn't fit.  Kinda like "why aren't there any vegetables that are both a potato and an onion?".  The thing is, interpreted languages are still compiled, it's just done on the fly - just in time compiling, as some call it.  Python is the closest to what I suspect you're talking about... `python my_script.py` will run a python script, but it also outputs a "my_script.pyc" file, which is a compiled (think java bytecode) form of the source.  Timestamps are compared on each run, and if at all possible it runs the pre-compiled version.

Does that help any?

Yes, thank you, interpreted Or compiled is exactly what i meant.
Logical standpoint... from my view, i'd say it's more like "why aren't there any potatoes that you can both cook and fry?" or even, "why aren't there any potatoes which can be cooked during mornings and eaten at dinner as well as potatoes which you cook right before?"
which there of course are, therefore I don't understand why there could not be such languages too.

And yes, I know some python.  and AFAIK, .pyc files still need python to run.


#348498 +(4737)- [X]

<MasterG> .....................................................................
          ..................................
<judas> where's pacman when you need him?

Offline

#10 2005-01-27 14:43:58

hiower4
Member
Registered: 2004-07-31
Posts: 38

Re: programming question

xerxes2 wrote:

the point with scripting languages is that you don't do any memory management and you don't have to define the type and size of the variables, also eval() and such like statements are not possible to compile to native binaries,

Well if the interpreters usually manages the memory management, why cannot that be compiled into the binary also, automatically?

Even though the variables doesn't have to be defined manually, they are defined, if so at run time, or rather at the pre-compilation stadium. (Now talking about python, it is sort of compiled right before it is run, isn't it?)
Now since those variables then can be defined at run time, could they not be defined in a compilation beforehand too?

I guess eval() means evaluate or similar, but I don't have enough programming knowledge to answer your statement. Could you kindly clearify?


#348498 +(4737)- [X]

<MasterG> .....................................................................
          ..................................
<judas> where's pacman when you need him?

Offline

#11 2005-01-27 14:51:29

hiower4
Member
Registered: 2004-07-31
Posts: 38

Re: programming question

TsaTsaG. wrote:

AAhhhh, teh beauty of Lisp...

http://lush.sourceforge.net/index.html -- LUSH, based on Lisp
http://www.cons.org/cmucl/ -- Common Lisp
but maybe also
http://www.ocaml.org -- Ocaml, if you can get along with a ML based language; not a real interpreter but compiles on the fly, giving the impression "as if interpreted"

Oh...So you mean Lisp can be interpreted (more or less), as well as compiled? Sort of python and C in one?


#348498 +(4737)- [X]

<MasterG> .....................................................................
          ..................................
<judas> where's pacman when you need him?

Offline

#12 2005-01-27 19:20:56

TsaTsaG.
Member
Registered: 2005-01-26
Posts: 6

Re: programming question

Yes, and another one comes into my mind:
http://www-sop.inria.fr/mimosa/fp/Bigloo/ -- Bigloo, a version of Scheme
Compiled code and interpreted code can be mixed together. That is, interpreted code is allowed to call compiled code and vice versa.
Bigloo compiles to C before it compiles to machine code, but does a very good job.

Offline

#13 2005-02-28 10:56:27

falmarian
Member
From: Chicago
Registered: 2005-01-28
Posts: 12

Re: programming question

IINM, PERL can be compiled into C code
from there it can be compiled by GCC into binaries of whatever sort you prefer
I think that I read that in Programming Perl, by the man himself, Larry Wall. But that information could be incorrect, it is not something I ever have to do.  For one thing, everybody should have PERL installed.  For another, I do not write sufficiently large programs to be worth compiling them.  In addition, I feel that such an undetaking really is best when one knows enough about C to proofread.  Just to make sure we won't be segfaulting or such things.


Those who would surrender a little freedom for the false sense of security deserve neither freedom nor security.
- Benjamin Franklin

Therefore

Give me Liberty, or give me death.

- Patrick Henry
falmarian-at-falmarian-dot-us

Offline

Board footer

Powered by FluxBB