-2

Is it true that one doesn't "implement a programming language"? I was told that in some comment around here several years ago and I read that actually you do "implement a programming language".

The background is that I was trying to check if it is true that python is a "programming language" and not a scripting language. I think I found that the difference is meaningless and I have to know how the language is used.

For example: Perl has a compiler and therefore it is a programming language if the compiler is used. The same goes for python doesn't it?

So if one is gonna categorize "programming language", "scripting language", "compiled language" and/or "interpreted language" then you can't know just from knowing the language, you must know how it is used or implemented.

Hence I now think that Python and Ruby not necessarily are "interpreted languages", it depends on if you use a compiler or an interpreter.

Did I understand correctly?

  • 2
    Possible duplicate of Understand scripting language – gnat Feb 27 '17 at 8:34
  • 3
    I'd say, programming language is the language that allows you to make a program. How that program is executed and which steps are taken to make it executable it is to somewhat irrelevant, as there is a huge blurring area between interpretation, compilation, and all variants in between (like JIT in JS, HotSpot, metacode as in .NET JVM python perl6 etc) Traditional views are not applicable any more. – ljgww Feb 27 '17 at 9:39
6

A programming language is some specification written in some report. It is not a software. For examples of programming languages specifications, see R5RS (for some Scheme), n1570 (draft spec of C11), etc. That specification should care about syntax and about semantics to define what are the "correct" programs and how should they behave.

I strongly recommend reading Scott's programming languages pragmatics, the latest Dragon Book, SICP, Queinnec's Lisp In Small Pieces.

Compilers and interpreters are software implementing some programming language. Actually, there is some continuum between them, and most implementations can have both compiled & interpreted aspects (e.g. printf is generally "interpreting" its format control string specified by the C standard, and many "interpreters" -e.g. Lua, Guile, Python, ...- are "compiling" to some bytecode, or using some JIT compilation library). Notice that (as an extreme) SBCL is an implementation of Common Lisp which compiles to machine code every REPL interaction and every call to eval. And you could find interpreters for C (even if I prefer using a compiler like GCC or Clang/LLVM for my C code).

I'm not sure that "scripting language" has any clear definition (but see its wikipage). Perhaps a pragmatic "definition" of them on Linux is to have some implementation usable with shebang which is processed by execve(2). I agree that definition is a hack (but so are "scripting" languages). Some languages (Ocaml notably) have both interpreters and compilers and could be seen as "scripting" languages. And TinyC can be used with a shebang (but is a compiler generating very naive and inefficient machine code) for scripts in C.

  • One could "define" the term scripting language to refer to languages (or better their most prominent implementations) which are designed with the primary goal to be used to extend the functionality of other programs. But then that definition is as arbitrary as any other. – Daniel Jour Feb 27 '17 at 8:55
  • How would Python, AWK, Perl fit into your definition? And C has standardized system(3) but is generally not considered as a scripting language... – Basile Starynkevitch Feb 27 '17 at 8:57
  • system does not extend other programs, it just calls them. Python could qualify as "scripting language" (because it can relatively easy be embedded into other programs, like blender for example). Don't know about Perl and AWK. It was my impression that both are more used in e.g. an UNIX pipe to filter data. – Daniel Jour Feb 27 '17 at 9:02
  • But as I wrote, it's very vague and arbitrary, that definition. – Daniel Jour Feb 27 '17 at 9:03
3

Is it true that one doesn't "implement a programming language"?

No, that's not true.

You certainly can implement a programming language. For example, Clang, GCC, icc, xlc, PathScale, Metrowerks, pcc, and tcc are all implementations of the C programming language. Oracle javac and Eclipse ecj are both implementations of the Java programming language. Zend Engine, Quercus, and P8 are all implementations of the PHP programming language. YARV, Rubinius, JRuby, Opal, MRuby, MagLev, IronRuby, Cardinal, Ruby.NET, XRuby, RubyGoLightly, MRI, tinyrb, Alumina, IoRuby, Smalltalk.rb, SmallRuby, BlueRuby, Carbone, Topaz, RubyMotion, MacRuby, Corundum, and Red Sun are (or were) all implementations of the Ruby programming language. CPython, PyPy, IronPython, Jython, pynie, and Pyston are all implementations of the Python programming language.

I was told that in some comment around here several years ago and I read that actually you do "implement a programming language".

Yes, you can implement a programming language. You don't have to, though: a programming is no less a programming language if it isn't implemented. You just can't run the programs written in it if you don't have an implementation.

For example: the Plankalkül programming language was created by Konrad Zuse in 1942–1946, but it wasn't implemented until 1972. However, in the 30 years in between, it certainly was a programming language.

The background is that I was trying to check if it is true that python is a "programming language" and not a scripting language. I think I found that the difference is meaningless and I have to know how the language is used.

Scripting is a specific kind of programming, so a scripting language is a specific kind of programming language. Asking if Python is a programming language and not a scripting language is like asking if a ThinkPad is a computer and not a laptop.

For example: Perl has a compiler and therefore it is a programming language if the compiler is used. The same goes for python doesn't it?

No. This makes no sense: why would whether or not Perl is a programming language change depending on whether or not I use a compiler? What if you use a compiler for Perl and I use an interpreter for Perl? Does that mean that Perl is at the same time a programming language and not a programming language? How would that work?

It should be obvious by this example, that a language being a programming language depending on how someone chooses to execute programs written in that language is logically non-sensical.

So if one is gonna categorize "programming language", "scripting language", "compiled language" and/or "interpreted language" then you can't know just from knowing the language, you must know how it is used or implemented.

The terms "compiled language" and "interpreted language" are non-sensical: compilation and interpretation are traits of a language implementation, not traits of a language. The language stays the same, regardless of how you or I chose to execute programs written in it.

Again, imagine the following situation: both you and I execute the exact same Python program; I use an interpreter, you use a compiler: now, is Python a compiled language or an interpreted language?

There is no such thing as a compiled language or an interpreted language. The terms make no sense.

"Scripting" is a specific kind of programming, where the program (aka the "script") is part of a larger environment and where the majority of objects being manipulated by the script, the majority of operations being used for manipulating objects, and the majority of data types, are provided by that environment. Also, the lifetimes of objects manipulated by the script are typically independent of the lifetime of the script itself.

Some examples are browser scripting with ECMAScript, where the DOM types, DOM objects, and DOM API are not part of ECMAScript but rather part of the browser, and the lifetime of DOM objects depends on the browser, not the script. Or OS scripting with something like Bash, Perl, Python, or Ruby, where the processes, files, and directories exist independent of the script, and the utilities used to manipulate them are part of the OS, not the language.

Hence I now think that Python and Ruby not necessarily are "interpreted languages", it depends on if you use a compiler or an interpreter.

No, it doesn't depend on anything. They are languages. Period. The term "interpreted language" doesn't make sense. If English were a typed language, it would be a type error.

Again, just think about it logically: IFF Python being an interpreted language depends on whether you use a compiler or an interpreter, what would it be if I use an interpreter and you use a compiler? And if I delete the interpreter and install a compiler, why would the definition of Python suddenly change for everybody on the planet?

It just doesn't make sense.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.