0

I am reading a C Language book. It said,

some higher-lever language are not compiled but are interpreted.

Basic and Java are two programming languages in which programs are ofter interpreted and not compiled. Other examples include the Unix system's shell and Python.

How about C# and Perl?

I thought C# should be compiled always and Perl doesn't compiled always.

Is that right?

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
Nano HE
  • 9,109
  • 31
  • 97
  • 137
  • Of course, many versions of BASIC *are* compiled. This is a common misconception perpetuated by users of low-level languages attempting to justify their own pain. You also run into quite a gray area with Java, as it is compiled to byte-code, but executed under a Virtual Machine that's responsible for converting it to native code for the current processor/environment. See here: http://stackoverflow.com/questions/2657268/whats-the-difference-between-compiled-and-interpreted-language – Cody Gray - on strike Jan 27 '11 at 03:37
  • @Cody he tagged the question as basic because it was a _simple_ question. – Rafe Kettler Jan 27 '11 at 03:51
  • @Rafe: I wasn't really referring to the tag so much as the quotation from the book that he included: "Basic and Java are two programming languages in which…" – Cody Gray - on strike Jan 27 '11 at 03:59
  • @Cody oh didn't even see that... well this is awkward... – Rafe Kettler Jan 27 '11 at 03:59

1 Answers1

3

C# and Java are both compiled, but not to native code. They are compiled to bytecode (for the Common Language Runtime and Java Virtual Machine, respectively), which is interpreted by their VM.

Perl can be compiled, actually, since there's a command line option to produce C code from Perl and compile that. But more generally, Perl is interpreted.

Both Perl and Python, when run normally, are compiled to bytecode which is then interpreted by their respective interpreters. There is no required compilation before running, unlike Java and C#.

By the definitions of your C book, languages are only compiled if they are compiled to native code (e.g. assembly) that runs directly on the CPU with no runtime.

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151