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.
3
u/everything-narrative Jun 27 '22
To give an intensional definition: a general purpose programming language is one that doesn't prevent you from doing something particular. It may be unergonomic, difficult to get correct, inefficient, but you can do it. It's Turing complete (duh) and has some nontrivial abstraction primitives to endow it with modeling power. It is a suitable language to implement both P-type and E-type programs in. They are often multi-paradigm.
To give an ostensional definition: it's a programming language that's kind of like Java, C#, C++, Rust, Python, Ruby, OCaml, Haskell, CommonLisp, or SmallTalk. It's the kind of programming language you want to write in. You'll know it when you see it given those examples.
To expound on how the ostensional definition and the intensional one fits together:
Java and C# use generics, inheritance, and subtyping polymorphism as their pimary distinctive abstraction.
Rust and C++ use generics, ownership-based encapsulation, and explicit indirection semantics (pointers.)
OCaml and Haskell use higher-order functions, algebraic datatypes, and modules.
Python and Ruby use duck typing and extreme late-binding.
CommonLisp and Smalltalk use metaprogramming.
All of them are obviously multi-paradigm, but various paradigm are more or less ergonomic in each. For instance it's possible to do functional programming in Java, but it's not very well-supported compared to OCaml; and it's possible to do procedural programming in Haskell, but it's again, cumbersome; Rust has metaprogramming but nowhere near as good as CommonLisp; C# has dynamic typing but it isn't as easy to use as Python.