why so many languages when C / C++ is faster and can do anythning?

why would anyone bother with other higher level languages, like java, when C code runs multiple times faster and is powerfull / expansive enough to do anything?

is it because C / C++ is too dificult to learn or use? if so then are C / C++ programmers considered better than others?
If execution speed was the only criterion by which software is judged, everything would be written in assembly language (and cost enormous amounts of money)

If a task can be naturally expressed in Prolog, Haskell, or Erlang, then shoehorning it into C++ would be a waste of effort. If a task manipulates a web page, it makes sense to write it in Javascript -- not everything needs to be native.

Each language has some areas in which it is best, some in which it is not much better or worse than competitors, and some where it's useless.

In before bogus speed comparisons with Java get posted.
Why learn French instead of Spanish? They both achieve the same end. Maybe some people have preferences in style and syntax as well as Cubbi's explanation.
1
2
qsort (x:xs) = let (ys,zs) = partition (<) xs in qsort ys ++ (x:qsort zs)
qsort [] = []


is powerfull / expansive enough to do anything?
Turing completeness doesn't say anything about the expressiveness of the language I'm afraid. C/C++ programs can be several times faster than programs written in other languages if they are properly optimized, but for many programs speed isn't a primary concern (that is, the necessary execution speed required for the program to function properly can often be reached without great effort). Garbage collected languages have less problems with memory leaks (though of course garbage collectors come with their own set of problems as well).

It's a matter of taste, convention, and what goals you're trying to achieve. For example - a video game has rather strict performance constraints (graphics need to updated at least 20-30 times per second for transitions to appear fluent, etc). On the other hand, they also have an upper bound at which further performance increases will produce no noticeable effects, for example most screens have a refresh rate of either 60 or 100Hz, so updating graphics faster than that is just a waste of time (and resources).
being esoteric in your coding is not something you have to do or should do. C++ gives you the power to do this but it is not a requirement, obviously. you can also typedef almost anything to make the code as easy as possible on the eyes.

my point is that the effort required to learn multiple slower languages just because they are easier to use doesn't add up in the end when you can just invest that same amount of time (or even less time, i bet) and gain mastery of the C language and in the end produce faster code in less time and, maybe, virtually bug-free.

it reminds me of being in highschool where most of the classmates were touting to choose spanish class over german because it's easier when in fact germany has been one of the leading economic powers.

my former trade was kitchen designing and remodeling. i can design a kitchen with a product that can be fully modified to meet the design template and therefor have less work for the installation crew to do. since the product comes already made to fit (because i ordered it this way) the job gets done quicker and with less chances of installation errors and handling issues. cabinets like these cost more and this is passed into the consumer.

now i can instead design the same thing with a cabinet line that doesn't have such modifications, order the parts and pieces seperately have haven them assemble and installed by the installation crew. the cabinets are cheaper and i will have the tendancy of offering a lower price to the client BUT at the expense of clobbering the installer with more to do and more chances of errors and delayes during the job. if you want effiecency you pick the better cabinet line that offers more choices.

so to make the comparison, use a slower language and pass the speed concerns to the other aspect, the hardware.
It's not a matter of being esoteric, easy or just "beautiful to look at". It's a matter of actual expressiveness of a language - how much effort does it take to get from an "idea" to an "implementation"?

And learning a programming language doesn't take much time. A week tops for most languages. Getting to know the provided libraries and common idioms takes much longer of course, but that gets easier over time to (just like it's much easier to learn Portuguese when you already know Spanish, just for the sake of having an analogy in this text).

As someone here already pointed out - everything you can do in C++ you can do just as well in assembly. Programs written in assembly are, properly optimized, a lot faster and having much lower memory footprints than C++ programs. The logical conclusion, going by your logic, would then be that real programmers should program in assembly. Now, the reason why nobody does this should be obvious - development in Assembly is slow. Reasoning over assembly programs is difficult, and debugging them is a nightmare.
Actually the main reason for the existence of many languages is "generalisation", putting taste aside, where we have seen that Visual Basic completely failed and is a dead language nowadays just because it followed the "taste". Fortran is still going, but it's considered everywhere a "lame" language, and its used only by people who don't care about the infrastructure of the program, and usually it's used by scientists who just want "results".

If you think about it, assembly talks to processors, which means, each processor type has to have a different program. C/C++ came to solve this problem in the cost of some efficiency. But C++, nevertheless, is still system dependant, compile-wise. So if you compile a program on linux, don't ever think you could just "run" it on Windows without huge losses.

After that, Java came to solve this last problem, where a single program runs on all operating systems, with additional loss in performance.

Internet websites development added another dimension to the problem, where websites have to be as much as possible system independent, that's why you find them usually very easy compared to C++, while they have a completely different purpose.

It's a general rule in life, generalisation has always its costs.

Actually you want the really really really best fastest system? I have even something else even faster than assembly, and way lower, which is VHDL and Verilog, where you design electronics. If each program had its electronics programmed with VHDL, it's just gonna be PERFECT!!! and definitely thousands of times faster that what we have now; but on the other hand... it's gonna take just FOREVER to get a simple Hello World! program done. Debugging? don't get me started on that!!!
Last edited on
Topic archived. No new replies allowed.