8

I know the term "scripting languages" is just a subset of programming languages, but I want to refer to programming languages such as Python and Ruby among others.

  1. First of all, why don't we need a compiler for these languages? For example, IDEs like Visual Studio or Eclipse have their own compiler in order to translate the code and execute the program. What does it mean for a programming language to be interpreted and how are they (Python, Ruby) compiled before execution in the terminal without a compiler?

  2. Also, when we install Python or Ruby in our computers before we start coding, what are we actually installing? packages? files? something that lets our computer understand the language?

Kilian Foth
  • 107,706
  • 45
  • 295
  • 310
chris
  • 251
  • 3
  • 6
  • Some scripting languages (e.g. Lua or Python or Neko) are compiled to a [bytecode](https://en.wikipedia.org/wiki/Bytecode). See also [this](http://programmers.stackexchange.com/a/285456/40065) – Basile Starynkevitch Oct 15 '15 at 20:39
  • ... Others (for example [perl](http://perldoc.perl.org/5.8.9/perlcompile.html)) may be compiled into an internal representation (perl is *always* compiling to an internal (but not bytecode) representation). That representation may be then fed through the interpreter, or to another compiler (that produces C source code). This can be further confused in that the interpreter part may be invoked in the middle of a compilation phase (the `BEGIN` block). The line between compilers and interpreters is very fuzzy now. IMHO: its best to forget about 'scripting' languages. They are languages. That's it. –  Oct 15 '15 at 20:48
  • 2
    You don't **need** a compiler for any language. Not even C. – user253751 Oct 16 '15 at 05:01
  • There are lots of interesting question with "Python" and "compile" tags. I recommend reading those ( shameless plug : http://programmers.stackexchange.com/questions/243269/why-isnt-there-a-python-compiler-to-native-machine-code ) – Euphoric Oct 16 '15 at 06:33
  • C interpreters exist. – reinierpost Oct 16 '15 at 09:27

1 Answers1

16

What does it mean for a programming language to be interpreted and how are they compiled before execution in the terminal?

Compilers and interpreters are very similar things, right up until the last step. For a compiler, the last step is to generate code in the output language and save it. For an interpreter, it's not trying to save your code; it's trying to execute it immediately. It does this by breaking down the program into basic semantic commands, much like the compiler does, and then executing those commands via a runtime that implements them in software.

2) Also, when we install Python or Ruby in our computers before start coding, what are we actually installing? packages? files? something that lets our computer understand the language?

Generally speaking, you're installing the interpreter and the standard libraries. Most likely some basic tools (such as a REPL, in the case of many scripting languages) get installed too as part of the standard package.

Mason Wheeler
  • 82,151
  • 24
  • 234
  • 309