5

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?

0

3 Answers 3

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

Sign up to request clarification or add additional context in comments.

6 Comments

The first Lisp compiler was finished in 1960.
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.
@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.
@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).
@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.
|
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.

Comments

2

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.

3 Comments

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, 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 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.
A performance comparison from Peter Norvig of several programming languages, Python and Lisp included: 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.