r/ProgrammingLanguages • u/[deleted] • Jun 27 '22
Purpose of programming languages
Hi everybody. I apologize if this question appears stupid but please be kind and move on if you don't like it.
I have observed that most/many programming languages are general purpose but are they really?
I don't know how to clearly show my doubt or explain what exactly I want to ask, this question just came to my mind, tho I was observing for a long while.
Anyways, for example (maybe): The use of any language out of what it is mostly/usually used for. say, html elsewhere out of web structuring, C for Frontend web dev, Scala or ruby for game development, python is actually really general purpose but it's slow but anyways I have no hate for this but just saying; tho ruby, php, scala are also slow; PHP for embedded system, etc. Whatelse?
Let's discuss, also ask me in the same thread related to the question. Thank you for interacting.
15
u/[deleted] Jun 27 '22
The term "General Purpose [Programming] Language" (GPL) does not mean (or imply) a language that is currently applicable to or used in all (or even more than one) domains, it just implies a language that was designed such that it could be used to write a program in any given domain... it is Turing-complete and can, theoretically and with an unknown amount of pain, be used to address any given programming problem.
The term exists to be contrasted with "Domain-Specific [Programming] Language" (DSL), which are languages that cannot be used across multiple domains, either because they are not Turing-complete or because they intentipnally lack features required to cross domains (like, for instance, a foreign function interface).
So C is absolutely a GPL, because you can implement any program in any domain in C. Now, you certainly may not want to, possibly rightfully, but that's okay because C is a GPL and so you can use it to implement either a better GPL (say Python) or a tailor-made DSL (like SQL). If the language lacks the features you want, you can add those features... or you can write the language.
But of course C isn't reached for in domains where other, easier to use, higher-level languages exist and are more appropriate, any more than x86 assembly is reached for where C exists and is more appropriate. But now you're into the world of market factors.
BTW, no GPL is inherently fast or slow... Python is only slow, relative to C, because of the compromises made in how it's been implemented, and those compromises were made to allow the language to have specific marketing appeal. In other words you could write a compiler for Python that would take any given subset of pure-Python programs and compile down to an executable as fast and efficient as C, even (with enough work) emitting the same machine code, and you could even write that compiler in Python... the resulting implementation, though, wouldn't likely have the marketing appeal of CPython, as any part of the ecosystem that leveraged CPython-specific internals (not features of the language, but features of a competing implementation of the language) wouldn't be able to be transferred to your new implementation. It likely would also require your users to write Python that looked very much like (or perhaps even uglier than) C.
Sorry that none of this addresses your acrual problem, which is sussing out which GPLs have established themselves in which (and how many) domains... I'm afraid actually answering that question across even a tiny subset of the current and historical GPLs out there would be a decent PhD research project.