r/AskComputerScience • • Aug 04 '20

Why so many computer programming languages?

Is it possible to do everything with one language like Python or C++?

I am wondering why there is so many different programming languages.

55 Upvotes

33 comments sorted by

55

u/Aerandyl_argetlam Aug 04 '20 edited Aug 04 '20

As a recent grad, I only know yay much, but i think a simple answer is that:

Sure, in all likelihood one language could suffice for accomplishing most applications. But doing them all well, as in efficiently, makes the difference. Some languages are better at certain things than others.

I'd hazard to claim that most languages these days have developed because Person McPersons did not find languageA to be sufficient for their needs/wants, so they made their own in a way that suited them "best", and then those langauges evolved from there.

E: see next comment for a better answer than my own alone

46

u/DonaldPShimoda Aug 04 '20

Hmm.

Language design and development tends to be more about expressive capability more than efficiency.

Somebody wrote a quote on the whiteboard in my old lab attributed (without citation) to Larry Wall, which said something like:

Programming languages are distinguished not by what they make possible, but by what they make easy.

On a very fundamental level, you could write every program in the lambda calculus, or with a Turing machine. But these are not very expressive systems. There aren't any types or classes or... anything, really! There's not even support for naming variables on a Turing machine — but you can emulate the functionality with enough layers of complexity.

We develop new languages because they allow us to express these complex ideas more succinctly, and that brevity of expression gives us a certain power over using the concept in question. Haskell allows for expressing things that cannot be expressed as easily in Java or C, and vice versa.

There's a great paper from the '90s, I think, by Matthias Felleisen titled "On the Expressive Power or Programming Languages" (or something very similar to it) that explains how we can formally compare languages in terms of expressivity. Although we don't actually do this in practice, the theoretical foundation of the work supports my assertions here.


The reason I'm drawing this distinction between efficiency and expressiveness in the first place is because performance is not actually a characteristic of a language — not really. Performance is a characteristic of a language implementation. And while some languages only have one major implementation, there is still a separation between the language proper (which is exposed the programmer) and the compiler or interpreter (which determines the performance characteristics observable by the programmer).

5

u/Aerandyl_argetlam Aug 04 '20

Thank you for clarifying :) expressive capability sounds more accurate than what I was trying to convey.

2

u/DonaldPShimoda Aug 04 '20

It seemed like that was what you were getting at, but I wanted to correct the specific use of terminology for the benefit of OP and others seeking to learn about it. Thanks for understanding! Cheers. :)

3

u/thingsinjars Aug 04 '20

Well put. Recently, I wrote a short sci-fi story inspired by the expressive capability of programming languages. Bit of a niche audience but relevant here:

https://thingsinjars.com/lab/kyral/

2

u/HasFiveVowels Aug 04 '20

That quote is an excellent point.

3

u/RazarTuk Aug 04 '20

1

u/XKCD-pro-bot Aug 05 '20

Comic Title Text: Fortunately, the charging one has been solved now that we've all standardized on mini-USB. Or is it micro-USB? Shit.


Made for mobile users, to easily see xkcd comic's title text (source)

10

u/sierrawhiskeyfoxtrot Aug 04 '20

Just like natural languages, different programming languages express things differently. While many people only know one language (and may therefore have to rely on the structures provided to express some complex thought), many programmers can choose which language they use to express a solution, based on the vocabulary or grammar of the language.

Besides that, there's also a lot of historical reasons related to, for example, system development, time for correspondence, different approaches, etc.

Edit: Almost all modern programming languages are "expressively equivalent", which means they can all do more or less the same things. However, doing something in one language may be easy compared to another for a variety of reasons.

10

u/claytonkb Aug 04 '20

We know from basic computer science that it is possible to do everything[1] with a universal Turing machine. On first brush, it might seem like we can "simplify" computer design by converging on just one language (so that everyone can speak the same language) but it turns out that, while it's theoretically possible, the practical obstacles outweigh any marginal benefits of not having to learn more than one programming language.

See switching barriers for further reading/research.

As for why there are various programming languages, it is helpful to look at the problem of program design from the perspective of programming paradigms. A paradigm is a "way of thinking" and it turns out that different ways of thinking naturally conform to different programming frameworks. These frameworks can all be translated from one to another, in principle. But there are large costs associated with such translations. Instead, certain problem domains tend to gravitate towards certain paradigms that are a "natural fit" for that domain.

And if you thought there were a lot of programming languages listed on Wikipedia, wait until you look at the list of esoteric programming languages (oddly, an NSFW link). I tend to enjoy the esoteric perspective because it decouples the form and function of a language from "what it's for" (use-cases). While use-cases are important from a commercial standpoint, starting from use-cases is not necessarily the "right way" to design a language. The creative spark within me tends to believe that the ideal programming language would have no real-world use cases. It would just ... be.

[1] -- We mean "everything" in the sense of symbol-manipulations... any task which can be expressed as manipulations on (a finite set of) symbols can be performed by a universal Turing machine. This is often called the Church-Turing thesis. There is also a strong version of this thesis which makes the metaphysical claim that everything (ontologically, that is, anything whatsoever, whether physical, symbolic, mental, emotional or otherwise) can be represented (simulated) by some computation of a universal Turing machine. Of course, this is not a scientific or mathematical claim, this is philosophy...

5

u/Kalsifur Aug 04 '20

Here's my ELI5 version: It's like saying "why are there multiple types of hammers when any hammer can bang a nail". Well you have special hammers for special purposes. You wouldn't use a rubber mallet to tear down a concrete wall (but you could). And, you even have hammers that are just for looks, or joke hammers, or ceremonial hammers.

Obviously this is a pretty simplistic view but I think it gets the point across.

1

u/RazarTuk Aug 04 '20

joke hammers

Hey, now. Malebolge is an amazing language, and it's merely a coincidence that it's named after the 8th Circle of Hell

1

u/blu3tu3sday Aug 04 '20

So now that we’ve established why so many programming languages exist, my question is:

In which case(s) would you use which language? Looking for concrete examples.

1

u/[deleted] Aug 05 '20

Upvote!

1

u/blu3tu3sday Aug 05 '20

Nice job taking my question and making a whole new post with it

1

u/[deleted] Aug 05 '20

it was an awesome question :) and I hope it gets a lot of feed back cause I think it's a great follow up :)

2

u/[deleted] Aug 04 '20 edited Aug 04 '20

Yes it is possible to do everything in a single language as long as it is Turing Complete.

However, that is not a good idea, different use cases need different languages.

For example, few languages support differentiable programming, also it is very easy to get lost in the chaos when there aren't good abstractions. Python for example allows researchers to do their computations fast because they can leverage C under the hood without worrying about optimizations because the solutions tend to be fast enough.

In contrast, GameDevs want control over everything to leverage as much performance from the hardware.

Other systems need to be able to spawn multiple processes for cheap, without interference, or, if one breaks, to avoid crashing the whole program, e.g. Erlang allows this.

Other cases include parallel computation. With a pure language, you don't have to worry about state because the objects are immutable, this enables you to fearlessly parallelize operations such as map.

Furthermore, you need low level access for stuff, this is where C comes in, because C is almost like assembly, if you know your C and your x86, you know what cc -S produces.

Last but not least, we also need verification, imagine how powerful the ability to prove that a program is correct is. Some languages allow just that and are the de-facto languages for airplains or rockets.

-1

u/agree-with-you Aug 04 '20

I agree, this does seem possible.

1

u/khedoros Aug 04 '20

Languages are designed with different uses in mind, and make different tradeoffs that are suited to the things they're used for or the circumstances they were developed under. They're also built around different core ideas, and developed according to different philosophies. And sometimes, a new language is written just to fix the perceived shortcomings of a predecessor, or to combine features from two languages in a way that the designer believes will be useful.

Most languages could be used for most things, with some adaptations and extensions. But...no one wants to build something much more complex than a launcher in Bash or Batch scripting. No one really wants to write their web backend in Cobol, their quick utility script in C, and their AAA video game in Ruby. No one wants to try to write their OS kernel in Javascript or their web frontend in Haskell.

1

u/deong Aug 04 '20

It's possible to do anything in any of these languages, but possible isn't the right metric to focus on.

Programming languages serve a number of purposes. One of them is to provide a way to generate executable code for a given architecture while allowing programmers to abstract away some of the details. In that regard, they're all the same.

However, they also serve as human communication. People prefer different ways of reading and writing high level code. People have different types of problems to solve. On top of that base of Turing Completeness, languages make choices about what they're going to be good at. Python and C can perform equivalent tasks, but they don't do it in the same way. Programmers want to be able to choose which way they solve a problem based on what's most important to them.

And then there's just "fashion", for lack of a better word. Over time, tastes tend to change and people develop new languages to provide a vehicle for programming in whatever way they find tasteful.

-1

u/agree-with-you Aug 04 '20

I agree, this does seem possible.

1

u/SilverLightning926 Aug 04 '20

So many different things to do...

1

u/v579 Aug 04 '20

The same reason bridges are built from steel and planes from aluminum. You need different strengths in different situations

1

u/knovhov Aug 04 '20

With new trends in the modern age, Action Script, C#, D, F#, Go, Rust, Kotlin, Elixir, Julia, Typescript, Swift are the latest trending programming languages. Latest Trends are mainly pointed towards the wider capabilities, software development, better efficiency, easy customization and many more factors. Read more here: https://knovhov.com/computer-programming-latest-trends-2020/

1

u/PBMagi Aug 04 '20

Given that any sufficiently advanced program ends up being a poor implementation of either LISP or Prolog, I can only assume it's because people don't like parenthesis and are illogical.

1

u/Geekspiration Aug 05 '20

There's an old joke about someone deciding to make a new standard consolidate the competing standards, and in result there is now 1 more competing standard. I feel like that's how programming is, people create languages to replace others, only to have more languages.

0

u/tehleel_mir_official Aug 04 '20

why so many food items? Because there is not an item which includes all the properties. same goes to computer languages.

-2

u/kstamps22 Aug 04 '20

Ultimately, everything is executed in Machine Language (0s and 1s).

1

u/ogGarySe7en Aug 04 '20

This (or Assembly) was the comment I was looking for. 10010011

-8

u/MugiwarraD Aug 04 '20

simple, no. because, python is interpreted, so u need to write a program that interpret python , now in what u write that? no python def so there u have it.

2

u/Dragonvarine Aug 04 '20

I think it was more hypothetical. You're missing 99% of the point.

-3

u/MugiwarraD Aug 04 '20

Ok , then I say only language is probably c