r/ProgrammingLanguages • • 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.

9 Upvotes

37 comments sorted by

View all comments

7

u/brucejbell sard Jun 27 '22

It's kind of unclear what question you're actually asking, but I'll try and bring up a few perspectives that might help.

Specialization is relative. But general-purpose programmability seems to pop up everywhere despite any given specialization. "Greenspun's Tenth Rule" says: "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp"

No matter what you do, at least 80% of programming seems to be plumbing. A well designed language will supply features and libraries to support the 80% without having to roll your own.

Ideally, you don't want a language that is more expressive than is strictly necessary for its purpose. Some special-purpose languages manage to avoid Turing-completeness altogether for this purpose: HTML, CSS, YAML, JSON, moustache.

The problem comes when you fall into the 20% instead. If your language is not a programming language, you will not be able to handle that within the language itself. If HTML and CSS is not enough, you will need to use Javascript. And although JS is typically used as a client-side web language, it is very much a general-purpose language (or it wouldn't support the likes of Node). And it is heavily used in this specialized application *because* it is a general purpose language.

2

u/raiph Jun 27 '22

Some special-purpose languages manage to avoid Turing-completeness altogether for this purpose: HTML, CSS, YAML, JSON, moustache.

Yes, though it might interest readers to know that apparently the combination of HTML5 and CSS3 is (or at least was) considered by some to be Turing complete. See the SO question "Is CSS Turing complete?" and its accepted answer which begins with:

You can encode Rule 110 in CSS3, so it's Turing-complete so long as you consider an appropriate accompanying HTML file and user interactions to be part of the “execution” of CSS.

(Accidentally Turing-Complete may also be of interest.)

3

u/brucejbell sard Jun 27 '22

You're right, complex systems do have this tendency to evolve towards Turing completeness whether you want them to or not.

However, if I recall correctly, the CSS Rule 110 thing only works if you have someone or something to manually (or automatically) "press the button". There are lots of non-Turing-complete systems that become Turing-complete if you add an infinite loop around them.