views:

420

answers:

11

Note:I don't mean some theoretical question which don't have any implementation just languages that don't have both!!!!!


These days there exists a c/c++ interpreter(cint) and a python compiler(to python bytecode).

I understand that the simplest definition is that a compiler just converts code from language a to language b, and then you have a machine which runs b it together with input, while an interpreter is simply something that takes input plus code in language a and runs it. And that using these definitions if something has an interpreter or compiler its fairly simple to get the other by immediately running the output of the compiler or embedding the compiler w/ the source code to get an interpreter.

So ignoring those which languages don't have both a compiler (which compile source code in A to B preferably an intermediate language) and an interpreter that run large chunks of code without compiling them?

+3  A: 

How about translator based languages? Example: pretty much any machine assembly. The assembler just translates code into the machine opcodes.

terminus
+1, had a feeling assembly was in a different class but wasn't sure what the name for it was.
no
That would probably be considered another compiler. Compiling is pretty much just another name for translation.
drharris
@drharris I disagree. Assemblers are basically a bijective functions. They take members of set A and turn them into corresponding members of set B. Compilers are injective at best. Many times one programming language statement has no direct corresponding statement in assembly.
AndrejaKo
The definition of a compiler makes no distinction between translating one-to-one or many-to-many. An assembler can be considered a compiler. For that matter, many consider an interpreter to be a subset of a compiler.
drharris
@drharris Looks like I'm uninformed. Source please.
AndrejaKo
Well, I don't have my dragon book with me at the moment, but suffice it to say that there is a whole subset of compiling that deals with cross-compilation, and the subset of that called "source to source" compilation. This is a form of compilation that typically results in equivalent code on a line-to-line basis. I'm fairly sure the dragon book would define compilation in the simplest terms of translation, though somebody correct me if not so.
drharris
I have to agree with drharris. There is nothing inherent in the definition of a compiler that says whether the translation is non-trivial or not, and most assemblers are definitely _not_ bijective, as there is a large amount of symbolic information discarded. Without playing with definitions in strange ways, there is nothing to reasonably distinguish an assembler from any other source-to-source translation, which is isomorphic with the definition of "compilation".
Gian
Personally I somewhere saw such definitionscompiler - translator from high to low level languagetranslator - translator from high to high level languagede-compiler - translator from low to high level languageI'm pretty comfortable with such definitions even they a a bit philosophical (high/low are not very objective terms -(sometimes C is considered as middle level language):)).Lets just talk about translators and everything will be fine :)
0x69
A: 

A compiler converts the entire of the source code to some other code, usually machine code or some kind low level intermediate language like java bytecode or .net IL. An interpretter converts the source code line by line as it executes the program. You have to do one or the other unless you write in assembly language, and even that needs turning from assembly language nmemonics into binary machine code.

Ben Robinson
I was asking for something that doesn't have both.
Roman A. Taycher
No you were not, you were asking for something that has neither, that is exactly what the title of your questions says. Something that doesn't have both might have one but not the other.
Ben Robinson
A: 

A few small RISC machine codes don't have either, since all they do is push bits around. There's no interpretation since there is no possible lower level to run it at, and there's no compilation since it's already 0s and 1s.

Ignacio Vazquez-Abrams
It seems likely that these machines have had simulators written for them (or very easily could)? Why is that not a RISC machine code interpreter? There is no requirement that an interpreter run at a "lower level". I could write a machine code interpreter in Python and it's still an interpreter.
Gian
+2  A: 
  Compiler vs. Interpreter

An interpreter translates some form of source code into a target representation that it can immediately execute and evaluate. The structure of the interpreter is similar to that of a compiler, but the amount of time it takes to produce the executable representation will vary as will the amount of optimization. The following diagram shows one representation of the differences. graphic Compiler characteristics:

* spends a lot of time analyzing and processing the program
* the resulting executable is some form of machine- specific binary code
* the computer hardware interprets (executes) the resulting code
* program execution is fast

Interpreter characteristics:

* relatively little time is spent analyzing and processing the program
* the resulting code is some sort of intermediate code
* the resulting code is interpreted by another program
* program execution is relatively slow

alt text

What about languages that run on a VM, its technically complied down to the VM bytecode, then interpreted on the VM.
Pharaun
Or Jit'd or interpreted + jit mix
Roman A. Taycher
+6  A: 

There are several esoteric languages that lack either a compiler or interpreter, as they have been designed merely as intellectual exercises, and are waiting for someone to actually implement them.

Paul Butcher
A: 

One of my classmates can write a complete mic-in to speaker program on an APPLE ][ by punching all the hex codes after a CALL -151. So the answer can probably be: machine code.

ohho
_@ohho:_ Machine code doesn't count. Your friend is the compiler, after all. Uh, or the interpreter...?
stakx
+1  A: 

The ladder language for programmable logic controllers (PLC) has no compiler or interpreter. The ladders are converted into boolean conditions to manage inputs, outputs and memory states. Ladders are evaluated thousands times a second to actually run the code on the hardware.

Good luck!

Reference: Programmable logic controller on Wikipedia

rjobidon
+1 for introducing any kind of hardware logic, but I have to ask why you don't believe that ladders are not readily translatable to two levels of boolean logic, which may be evaluated by an interpreter? If any kind of software simulator for these devices exists, then it seems that is an interpreter in the most basic sense without having to stretch the definition in any way.
Gian
Just curious ... "The ladders are converted into boolean conditions ..." How? And can't whatever is doing it be considered an interpreter?
LeonixSolutions
@Gian, that would technically be a compiler (or converter), not interpreter. The language would be compiled into a bitstream which would then be uploaded to the device.
vladr
I was referring specifically to a simulator, of course there is a natural implementation of compilation available too, when discussing real devices.
Gian
I've personally implemented ladder logic interpreters and compilers for Rockwell Automation; your answer is simply wrong. The machine "underlying" the ladder logic is typically a conventional microprocessor, and cannot execute the ladder logic directly. Rockwell once had a chip that executed ladder logic compiled in very simple ways, but AFAIK stopped making that when I showed my interpreter was faster than their hardware.
Ira Baxter
A: 

So I preface this with a claim: any language that has a fixed semantics that can express computable functions is implementable. I'm hedging my bets here by not saying specifically what I mean by the "semantics", but I generally mean something that is either an operational semantics (big or small step), a denotational semantics, or axiomatic semantics.

So, with that out of the way, there remain two questions: Are there languages which don't have any semantics at all (and are therefore not implementable by any of the usual means), or are there languages which haven't been implemented, despite it being possible to do so?

The latter case is obviously true, but it's not very interesting. Just because people dream up a language doesn't mean it's a good idea. I could think of a language right now, and it wouldn't have a compiler or an interpreter. Not very interesting.

The former case is a little more interesting. There are languages that are actually logics and (via the Curry-Howard correspondence) proofs in these logics are also programs (and vice-versa). If the logic is not decidable, or if the language includes some kind of higher-order constructs that are not strongly normalising (such as some very expressive type system), then compilation or interpretation becomes a slightly scary affair. This might start to verge into the territory of "not compiling or interpreting", but that's a slightly spurious claim, because if we can make a computer manipulate these symbols, we can write an interpreter. Similarly, if it has no semantics, then it's probably not operating over computable functions - it's probably just natural language of some kind at that point, no longer a "programming language".

This is especially true because we can argue that the Church-Turing thesis says that it will always be possible to write an interpreter for a Turing-complete language, even if that interpreter ends up being another Turing machine.

I see some other answers have made claims about machine language. There is nothing magical about machine language except that it has a very compact representation. One could very easily write an interpreter for it, and many exist (e.g. the various virtual machines that faithfully implement the execution semantics of a hardware processor in software).

The languages that meet your criteria are likely to be ones that have no execution semantics, i.e. they do not express computable functions. Here are a couple languages with fixed semantics I know of that are not directly executable by either an interpreter or by compiling them to anything else without enriching these programs with additional information:

Gian
Is the note at the top not very clear?
Roman A. Taycher
No, it's really not.
Gian
... and in fact CPUs are "compact, high performance" interpreters of machine code.
Ira Baxter
@Ira Baxter, an excellent point.
Gian
+3  A: 

Latin and Aramaic. Two dead languages with translators but insufficient live speakers to warrant any interpreters. You could add Klingon, but I suspect that there actually interpreters for that now.

dwarFish
+1  A: 

If by interpreter you mean a tool that executes part of the code interactively, then hardware description languages (VHDL, Verilog, ...) I think don't have these. Mostly people simulate VHDL and Verilog descriptions as monoliths to check the net (ahem) effect. Verilog and VHDL are compiled ultimately into gates (for FPGAs) and transistor circuits for implementation as chips.

Similarly, I don't think you'll find many interactive constraint-solver languages. Like the hardware design langauges, constraint programs are mostly executed as monoliths, because a partial constraint will produce too many answers. Constraint solver languages are often compiled to a lower level representation which is "processed" more than interpreted by propagating constraints based on dependences.

As a general rule, neither of these produces "machine instructions".

Ira Baxter
A: 

HTML is a language, but a markup language. I don't know how browsers really parse them, but I assume they interpret them line by line, building up the DOM and rendering elements, etc.

Natural languages, such as English, have a large and ever increasing grammar and are not always expressed in a formal notation (such as BNF) unless you use an exact, precise form. I think.

So I say that you can't really build an interpreter for English, and many natural languages, based on the fact that it's always evolving - look at chatspeak and textspeak even.

I don't think all languages can have a compiler, based on this.

jamiebarrow
HTML is a structured tree. It's parsed typically by a SAX-style (streaming) parser. Thus, it's parsed element by element, not line by line. These elements need to be interpreted to be transformed into a DOM, but arguably HTML isn't even run.
MSalters
That makes sense, the parsing element by element. So, it builds up a parse tree for the elements to build the DOM? It may not be run, but it's an interpreted language I guess? Or I could be wrong, can't remember the exact definitions of these things anymore.
jamiebarrow
I guess I'm trying to argue that a markup language is an interpreted language. I don't know if that makes sense, but then again, my argument that natural languages can't have a compiler (at least to our current knowledge), stands. I think the possibly infinite grammar stops one from having a compiler/interpreter.
jamiebarrow
It is easy to imagine an HTML compiler, that converts HTML into a set of PRINT statements in your favorite language. In fact, HipHop, the PHP compiler from FaceBook, which compiles PHP into C++, must do essentially this directly.
Ira Baxter
Yes. I was saying that for natural languages (e.g. English) you can't have a compiler. I guess you downvoted because of the HTML remarks.
jamiebarrow