(Programming) What language do language interpreters use?

For example, say I made a script in JavaScript. I know what the interpreter does, but what language is it written in? Does it matter what language it's interpreting? I'm asking because I want to make my own language, and I want to program the interpreter too

6 Answers

Relevance
  • 3 years ago
    Favorite Answer

    The Chrome V8, the JavaScript engine for Google Chrome, is written in C++, according to

    https://developers.google.com/v8/

    One can write an interpreter for any programming language, using almost any programming language - some languages are too cumbersome to program with. It's even possible to write a compiler/interpreter of a language in itself! One example is PyPy:

    http://pypy.org/

    Use the language you are most comfortable with. If the interpreter of the language you plan turns out to be too slow, you can write a compiler instead (generating either machine code or other language's code) or reimplement the interpreter in a faster language (like C or C++).

    By the way, please read:

    https://en.wikipedia.org/wiki/Compiler

    https://en.wikipedia.org/wiki/Interpreter_(computi...

    https://en.wikipedia.org/wiki/Compilers:_Principle...

  • Anonymous
    3 years ago

    I would recommend understanding how the hardware works with data. Go from low to high level to high to low level languages back and forth until you grasp how. If that's what you desire, but there's already languages for what we need on screen.

  • Andy T
    Lv 7
    3 years ago

    Most likely C/C++, otherwise it is too slow, those languages fit the bill, speed and low level. But obviously there are others being used. Just don't consider Assembly is one since it is too low for modern computing environment.

  • 3 years ago

    Interpreted languages tend to be slower in computation time than compiled languages. Just make sure you're aware of that. An example of an interpreted language is PHP.

    Interpreted languages are usually written in C or C++ for performance and max control on how computers execute methods.

    All a compiler does is parse files and create machine-readable code. An interpreter simply is a compiled program that, instead of converting code to machine-readable language, executes its own methods depending on what you wrote. But it has more overhead because it has to parse and read every file whenever it's being executed... That's part of the reason PHP includes are so expensive. A compiled language only has to be parsed and read once, reducing overhead.

    There's also Just-In-Time compilation... But I think that's out of the scope of your question.

    To answer your question... Any language that can read files can be used as an interpreter. You could even write an interpreter out of PHP (though this would have horrible performance). JavaScript is a little weird since it's meant to be, for the most part, run in browsers.. But if can run JavaScript as a stand-alone, then yes, you can write an interpreter out of JavaScript too.... Whether that's a good idea or not is another question...

  • How do you think about the answers? You can sign in to vote the answer.
  • ?
    Lv 7
    3 years ago

    The fact that you want to write the interpreter in XML suggests you are not ready to do this, by far. XML isn't a programming language, it's a markup language.

    Anyway, interpretation starts with parsing, so why not write a parser first? Try writing one in JavaScript or some other actual programming language and make it parse expressions like (4 + 5) * 3 and evaluate them.

  • 3 years ago

    You can write an interpreter (or compiler) in just about any language you like.

    They are often written in C (or C++) as that's the single fastest and most efficient language, but you could write eg. a Pascal interpreter in BASIC or a BASIC interpreter in Python.

    I've written a quick-and-dirty compiler for a PLC in PHP before now..

Still have questions? Get your answers by asking now.