5
$\begingroup$

If someone realizes that a computer language is deficient under some aspect or the other, couldn't he just create a library for the new language instead of a new language?

Couldn't you have a library In C that lets you process list as if they were lisp? Or that write simple code as if it was Python?

Why does evolution have to mean breaking with the past?

$\endgroup$
  • 4
    $\begingroup$ Answers to this question provide part of what you are looking for. $\endgroup$ – Dave Clarke Jan 22 '14 at 13:46
  • $\begingroup$ Other languages provide abstract syntactical elements that have no equivalent in C. Therefore, these elements can not be expressed (concisely) in C. You could construct, say, Lisp expressions as linked records (build the tree) and evaluate them using delegation, but that wouldn't quite be the same, now would it? (cf. XML implementation via DOM objects in e.g. Java: very unwieldy) $\endgroup$ – Raphael Jan 22 '14 at 15:37
  • $\begingroup$ This is probably a better question at Programmers.SE, but as you've asked it here: different abstractions lead to different languages, not just different libraries. $\endgroup$ – Mark Hurd Jan 28 '14 at 5:06
7
$\begingroup$

There are many features that cannot be simulated by a library (or rather - are very hard to simulate by a library), for example garbage collection, or exception handling. And even features which can, say object-oriented programming, are much easier to use when they're part of the core language.

You can certainly have a library in C implementing an interactive python interpreter, and then you can just put python code in quotes as input. There are several problems with this: it will be hard to debug, and syntax highlighting could be a nightmare. However, the real issue here is that if you've gone that far, you actually have a python interpreter.

Simulating python in any other way seems difficult: how would you implement control structures, for example? How would you implement message passing, operator overloading and so on? You will need to replace the usual operators by named functions like add and so on, which aren't going to be very easy to use. And to implement message passing you will need to use variadic functions with string parameters, taking care to handle somehow named parameters. You will do all that, and still lack the interactive python interpreter.

You can say the same regarding any other language - even if you could simulate language features, it would be awkward. This even goes to object-oriented programming in the C++ tradition. You will need to have a special calling mechanism which wouldn't be able to do static type-checking, for example. And how about templates? This sounds even harder. You will need to have void* pointers, and to instantiate the code yourself.

Summarizing, modern languages are more than just syntactic sugar above C, and even if they were just that, it would still be very awkward to program them directly in C.

$\endgroup$

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.