6 ms·
So how does Ada go speed wise (real world not micro benchmarks)? Were/are there legitimate reasons to opt for c over Ada?
by flukus 10y ago
So how does Ada go speed wise (real world not micro benchmarks)? Were/are there legitimate reasons to opt for c over Ada?
- pavlov 10y agoOn early PCs, Pascal and C were pretty much tied in popularity. Both were free to implement, and small enough that you could make a fast compiler on a typical PC with only 256-640 kB RAM. C won because it was more flexible and was chosen by Microsoft, but Pascal definitely had a strong following (it was the original Mac's API language, and on PC it was a major contender thanks to the nice and fast Turbo Pascal IDE). Ada was a complicated and rigid language designed by a Department of Defense committee. That was not great PR for those early individualist PC users. (Who wants to program in the language of "The Man"?) If Pascal was a Cessna and C was a Learjet, then Ada was the F-35 -- complex, expensive, late.
- breeze_em_out 10y agoAda is the F14. Expensive, works well, but ya really just don't need it most of the time.
- taneq 10y agoSo what's the F/A-18?
- rpeden 10y agoMaybe Java? It's everywhere, can fulfill just about any role you throw at it, but isn't really the world's absolute best tool for most of those roles.
- breeze_em_out 10y agoI almost said Javascript out of ubiquity, but it'd be a grave insult to the plane. Java is a good answer, maybe C#, maybe Python. The language needs to be one that gets a lot of work done, and is reliable. What's a language that's just always got your back in a situation? That's the F/A18.
- efalis 10y agoIt's written in Ada, if memory serves. ;-)
- pjmlp 10y agoThe sad part is that it turned out that Ada compilers were actually easier to implement than C++ ones. And while we can do Ada style programming in C++, the lack of control over the C copy-paste compatibility features hinders that, unless one is allowed to turn all security knobs on (warnings as errors, sanitizers, code guidelines compliance).
- krylon 10y agoOn the other hand, C++ has become fairly popular, and IMHO it is at least as complex as Ada, with Ada being more readable and harder to use as a foot-seeking shotgun. I remember reading about a (compiler-checked) subset of Ada for deterministic realtime code. If I was writing code that had to meet hard realtime requirements, I would certainly love it if the compiler could help me with that.
- flukus 10y agoWas anyone building things like operating systems or drivers in pascal? AFAIK that was always the realm of c. Turbo pascal was the first language I was taught, I have a soft spot for it but I think it had largely faded away by then.
- steveklabnik 10y agohttp://wiki.osdev.org/Pascal#Past_uses_in_OS_development http://wiki.osdev.org/Pascal#Past_uses_in_OS_development I have vague memories of trying to write MacOS apps in CodeWarrior and needing to mark C functions as having a Pascal ABI...
- monocasa 10y agoApollo built a whole Unix-like in Pascal that ran on their workstations. https://en.wikipedia.org/wiki/Domain/OS https://en.wikipedia.org/wiki/Domain/OS
- defined 10y agoI wrote some pretty low-level stuff in VAX PASCAL, which had extensions to let you do just about anything. It was a nice language.
- efalis 10y agoYeah, when I was working at Burroughs in 1980, they were doing printer drivers and a distributed OS prototype in their version of Pascal. Problem was, everyone needed to beef up Pascal in their own way to make it industrial level.
- Hasknewbie 10y ago> Ada was a complicated and rigid language designed by a Department of Defense committee Ada was designed by Jean Ichbiah, and although there was a committee he did override them on multiple occasions. So not really a design-by-committee. The reasons it got no traction were: it was too complex/heavyweight, and too dissimilar to C to warrant a change (businesses waited for C++ instead, since it was around the corner at that time); due to its complexity it took a while for certified compilers to show up, and when they did they were quite expensive. Since it was properly established in high margin markets, the community (mainly AdaCore, since they are the main compiler vendor) did little to improve its standing -- the only open-source projects they have pushed are all under GPLv3, which is not going to help with its popularity (not a judgement on GPLv3, it's just that basic lib are almost always under more liberal licenses, e.g. Boost). It really feels as if these OSS projects were pushed only to attract new programmers, while trying to prevent[1] an actual independent community from springing up. Odd behaviour. Every 6 months or so someone on HN or Reddit posts an Ada article that get people's interest, and then they discover they cannot write their project with it due to its licensing. [1]: "...it is the intention of the GPL distribution of GNAT to restrict your freedom" in: http://libre.adacore.com/tools/gnat-gpl-edition/faq/ http://libre.adacore.com/tools/gnat-gpl-edition/faq/
- atweiden 10y agoAda is a beautiful language, but the licensing issues, the archaic and bloated IDE tooling combined with the proliferation of ancient bitrotting libraries are crippling Ada's potential. Drake [1] is a promising new Ada runtime with non-GPL license that deserves more support. Similarly, DRACO is ISC licensed [2]. Of course, these projects aren't backed by moneyed interests like AdaCore is, so they get no love. [1]: https://github.com/ytomino/drake/wiki/Why-a-new-Ada-runtime%3F https://github.com/ytomino/drake/wiki/Why-a-new-Ada-runtime%... [2]: http://www.dragonlace.net/questions/quest_004/ http://www.dragonlace.net/questions/quest_004/
- JohnStrange 10y agoIt depends on which compiler you use. Assuming you use GNAT, the compiler is written in Ada and the backend is gcc, and you have the same optimization options as C in gcc. I'd say its performance is usually in the range of C++ performance. You can make it as fast as C, of course, because nobody forces you to do object-oriented programming (tagged types in Ada) and all runtime checks can be switched off with pragmas. However, I don't think that many Ada programmers are interested in that. In a nutshell, speed is not a reason to opt for Ada over C. Safety and maintainability are. As for reasons for going the other way, there are plenty of them. Getting Ada programs to compile can take a long time, especially when you're learning the language, and the learning curve is relatively steep. Ada is a huge language in comparison to C and it's syntax is "per-construct" - it looks easy but there is a lot more to learn in comparison to, say, Pascal. Another reason: Lack of external libraries. C has way more.
- krylon 10y agoI wrote one simple but computation-heavy toy program in Ada (check the Goldbach conjecture), and performance was about as good as my C and C++ versions. Although I am not sure if that counts as read world usage. ;-)
- Raphael_Amiard 10y agoIn theory, it's just as fast as C/C++, when you compare GNAT against GCC/G++. In practice, some language constructs are not as optimized as their C++ counterpart. The end result is that you can expect the Ada 83 subset to be extremely fast, but more recent constructs like OO and controlled types (equivalent to C++ virtual destructors) to be slower. All in all it has a pretty good performance story !
- flukus 10y ago> In theory, it's just as fast as C/C++, when you compare GNAT against GCC/G++. Is this the same theory that makes java is just as fast? Ie, if I wrote idiomatic Ada would the levels of indirection (pointers to pointers to pointers and virtual functions everywhere) by more like c or more like java?
- Raphael_Amiard 10y agoWell, yes and no :) Ada is very close to C++ in terms of runtime abstraction, unlike Java, so it's not relying so much on the "sufficiently smart compiler" fallacy. Also, there are several idiomatic dialects of Ada, because Ada has a facility to deactivate language features at compile time. Some people in safety critical don't want any dispatch for example. FWIW I ported a quite large code base from C++ to Ada so I'm have first hand experience with this.