Is scripting language always built on another language?

Asked

Viewed 515 times

13

I was reading more about what characterizes a language of script. Namely:

What is a scripting language?

And the question itself quotes the languages I know of script PHP, Python and Ruby, possibly the best known in general. The definition of what is a language of script seems to be not very well defined, but of the three cited, I know that PHP and Python are built on the C and Ruby language, which I’m not so familiar with, I found the phrase "The standard 1.8.7 implementation is written in C" (Source).

So, all the languages said of script are developed on another language or is this a particularity of the mentioned languages? Is there any clear reason for developing a language about another language?

  • 1

    Define "'built on another language" :) This is important, I think you even know it.

  • @bigown be implemented in another language, as the three cited are in C. I do not know if I made confusion and ended up passing a simple detail that would answer the question.

  • I’ll answer because it’s more complicated than that.

  • I believe your question has to do with "High-level programming language" and "Low-level programming language".

  • 1

    I think there’s an identical question in the O.R. :)

  • PyPy is the Python interpreter written in Python.

Show 1 more comment

1 answer

9


I’ll start casting some links important to understand about languages, compilers, interpreters, etc.:

Languages are specifications, then they exist by themselves, they exist "on paper". In general the way they will be implemented does not matter.

Compilers or interpreters are implemented always in some language, whether machine code, Assembly, C, or other language, no matter.

Runtime

Furthermore, it is common for languages to have a standard library that can be written in the language itself, in another more suitable, possibly faster, or a hybrid of it. There will also be a Runtime which can be absurdly simple as in C (or existing as Assembly), or monstrously large as Java, C#, and others, plus of course the languages interpreted or running on virtual machines.

Interpreted languages need a Runtime interpreting. Compiled languages that generate a bytecode also need an interpreter of this bytecode. Jittadas languages like JS or Java, (C# can also, but there is native variation) need the Jitter. Note that I speak of languages, but in the background are their implementations.

That one Runtime needs to be written in some language. At least one part of it needs to be done in another language to give the bootstrap. In general a bootstrap needs to be done in Assembly and/or C to be very simple and access the lowest level.

There are cases that need a virtual machine to run this and other things necessary for the language infrastructure. It’s still part of Runtime.

Dynamic typing languages need an infrared memory access and problem handling at runtime, this requires something at Runtime which must be written in some language that understands memory directly, it cannot be a very abstract language. C is very suitable for this.

Many languages nowadays work with managed memory which was one of the largest boosts programming productivity after the advent of high-level language and code modularization. Absurdly more than OOP that many think is the 8a. wonder of nature :) This has a cost that many secondary languages cannot afford.

Languages of script

Let’s agree which languages of script are interpreted or run on a virtual machine, have dynamic typing, managed memory and do not usually have the maximum performance on their own.

So to make this Runtime needs another language more powerful, flexible and fast. Whether to interpret, manage memory or perform other tasks. A part of it can even be written in the language itself, but it would be terrible. A part has no way, it needs something different. Even C needs a little bit of another language.

The compiler can write on itself, but it will certainly be very unsuitable. The interpreter does not give 100%, although I imagine a gambiarra that gives a share, but does not make the slightest sense.

Even by performance, much of the standard library of a language script usually written in C or C++.

Some languages may be script only in a certain implementation. This changes a little, they are languages that were originally not intended to be script, but they were implemented like this, so you can implement almost 100% in itself, but only because it doesn’t have all these characteristics. It’s the case of C who only needs one bootstrap tiny in Assembly.

Implementations

Several languages have several implementations, although only one is official and so is the most popular. It is true that secondaries are often of inferior quality, receive less love and in fact many are experiments.

Lua has several implementations, has even VM written on it. This does not mean that they are appropriate.

Python also has, with emphasis on Pypy which is written in Python itself.

The same goes for Javascript.

Ruby is also available alternatively, but I don’t know if any were written in Ruby.

It certainly occurs with other languages.

Completion

So no language is that self-sufficient except the Assembly. But if the doubt is about all that I said above, yes, the language of script is always built upon another language, whether in part, or the whole.

Performance is the main reason for opting for another language to write almost 100% of a implementation to a language of script.

I will contribute to other repositories:

  • 1

    In short, the language itself is basically a structured text that will be analyzed by the compiler/interpreter. The compiler/interpreter which is, in fact, written in another language. Succinctly this would be?

  • 1

    That, but the compiler is the least. The Runtime is much more important. So much so that the compiler is often written 100% in the language itself, except the languages of script :) I’ll find script language which has its compiler written in the language itself, more like experiment than real use.

  • PyPy? That’s what you’re after?

  • 1

    @Jeffersonquesado I was going by anyway, then forgot, already edited, thanks for remembering.

  • @moustache at your command

Browser other questions tagged

You are not signed in. Login or sign up in order to post.