4

I know there is no such thing, strictly speaking, as a compiled or interpreted language.

But, generally speaking, is LISP used to write scripts like Python, bash script, and batch script?

Or is it a general purpose programming language like C++, JAVA, and C#?

Can anyone explain this in simple terms?

Rainer Joswig
  • 136,269
  • 10
  • 221
  • 346
Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147

3 Answers3

6

Early versions of Lisp programming language and Dartmouth BASIC would be examples interpreter language (parse the source code and perform its behavior directly.). However, Common lisp (Current version) is a compiler language.

Note that most Lisp compilers are not Just In Time compilers. You as a programmer can invoke the compiler, for example in Common Lisp with the functions COMPILE and COMPILE-FILE. Then Lisp code gets compiled.

Additionally most Lisp systems with both a compiler and an interpreter allow the execution of interpreted and compiled code to be freely mixed.

For more details check here

Community
  • 1
  • 1
S M
  • 3,133
  • 5
  • 30
  • 59
  • 4
    The first Lisp compiler was finished in 1960. – Rainer Joswig Mar 24 '16 at 06:37
  • 2
    Additionally to Rainer's comment: some Lisp systems (CMUCL I think) really had no interpreter but rather always compiled, even what you typed interactively. I suspect Racket works like this too. –  Mar 24 '16 at 08:27
  • 2
    @tfb: there are some compiler-only implementations, but CMUCL had an interpreter - though the usual default is to use the compiler. SBCL (a fork of CMUCL) used to only have a compiler - but an interpreter has been added some time ago. – Rainer Joswig Mar 24 '16 at 10:50
  • 1
    @RainerJoswig: You are right, I'd forgotten the details. CMUCL had *two* compilers (or rather Python could emit byte code as well as native code) didn't it? (As well as an interpreter). The byte code thing must have mattered when memory was scarce (CMUCL seemed terrifyingly huge in the early 90s). –  Mar 24 '16 at 11:02
  • @tfb: CMUCL also has special support to compile files or larger modules. The bytecode compiler/runtime has the advantage, that the bytecode machine is easier portable, than a native code generator / runtime. Also, in theory, the generated byte code could be portable. – Rainer Joswig Mar 24 '16 at 11:13
  • I don't think this answer addresses both of the OP's questions and these followup comments are devolving into a compiler minutiae discussion that completely sidelines the OP. – cdlane Mar 24 '16 at 16:30
3

Lisp is a compiled general purpose language, in its modern use.

To clarify:

  • “LISP” is nowadays understood as “Common Lisp”
  • Common Lisp is an ANSI Standard
  • There are several implementations of Common Lisp, both free and commercial

Code is usually compiled, then loaded into an image. The order in which the individual parts/files of an entire system are compiled and loaded is usually defined through a system definition facility (which mostly means ASDF nowadays).

Most implementations also provide a means for loading source code when started. Example:

sbcl --load 'foo.lisp'

This makes it also possible to use lisp source files as “scripts”, even though they will very likely be compiled before execution.

Svante
  • 50,694
  • 11
  • 78
  • 122
1

Traditionally, LISP can be interpreted or compiled -- with some of each running at the same time. Compilation, in some cases, would be to a virtual machine like JAVA.

LISP is a general purpose programming language, but rarely used as such anymore. In the days of microcoded LISP machines, the entire operating system, including things like network, graphics and printer drivers, were all written in LISP itself. The very first IMAP mail client, for example, was written entirely in LISP.

The unusual syntax likely makes other programming languages, like Python, more attractive. But if one looks carefully, you can find LISP-inspired elements in popular languages like Perl.

cdlane
  • 40,441
  • 5
  • 32
  • 81
  • 2
    Ah, uh, no. Common Lisp is used as a general purpose language also now. It has less overhead than Python, rather comparable in performance to Java (or C when optimized, which is relatively easy to do inside the language). The reasons of its low adoption are mostly external. – Svante Mar 24 '16 at 09:51
  • @Svante, I answered fairly, touched on compiler/interpreter issues and classified LISP as a general purpose language. I assume folks down voted my use of 'rarely'. SO CommonLisp tag followers are ~ 1/200th of the average of the other languages mentioned. The [TIOBE Index](http://www.tiobe.com/tiobe_index) confirms this in current and long term trend data. The other languages are in the TIOBE top 5, with Lisp at 28 and CommonLisp outside the top 50. Translating their numbers, it puts LISP around 1 in 1,500 programmers which, if it were a disease, would be classified 'rare' in the US. – cdlane Mar 24 '16 at 16:27
  • A performance comparison from Peter Norvig of several programming languages, Python and Lisp included: http://norvig.com/python-lisp.html. In Matrix multiplication or array access Python is somewhat like 100 times slower than Lisp. I can see your point that the syntax or the functional paradigm are challenging for beginners, but the overhead, no. – FrankS101 Mar 24 '16 at 19:17