32 ms·
Learning Ada
- eddieh 8y agocamelCase, snake_caske, PascalCase, kebab-case, so I think I'd call that Pascal_Snake_Case or something. Other than that this is really great, Ada is pretty neat and used in the most critical systems in the world: https://www2.seas.gwu.edu/~mfeldman/ada-project-summary.html https://www2.seas.gwu.edu/~mfeldman/ada-project-summary.html
- deleted 8y ago[deleted]
- Mikhail_Edoshin 8y agoIf you separate words with underscores and feel like pressing the Shift key now and them, you can simply write in proper case, like `Convert_vCard_to_XML` :) To me it seems the most readable way.
- steveklabnik 8y agoYeah, I got hung up on exactly what to say and then was like "Steve, you're trying to learn Ada, not trying to determine what this case is called" and just wrote something. I like Pascal_Snake_Case, I'll update the post. Thanks.
- 0815test 8y agoAIUI Ada is case-insensitive so there's nothing preventing you from using snake_case instead, even when referencing external identifiers. Pascal_Case is purely a matter of visual style.
- xnXY 8y agoThe title should be "Why Rust is superior to Ada in 5 minutes". He is not trying to learn Ada.
- jonathanstrange 8y agoIf he really wanted to, he could take a look at the Consolidated Ada 2012 Language Reference Manual [1] and get his mind blown. Don't get me wrong - I'm not claiming the reference manual is a good learning source, for that I would recommend Barnes's book, but that it's an example of a language specification. Having precise specs is a minimum requirement for a safe language. Rust is too complicated as a C replacement but arguably a good C++ replacement. Unfortunately, it's not well-defined (yet) for writing safe programs. Without spec you cannot even tell compiler bugs from intended behaviour. [1] http://www.ada-auth.org/standards/ada12_w_tc1.html http://www.ada-auth.org/standards/ada12_w_tc1.html
- steveklabnik 8y agoI am planning on looking into more reference material eventually, but I prefer to do that after reading tutorials and writing code, as a way to answer the questions that I have. And yes, the lack of a spec is a weakness in Rust. We've been working on it for a while, and are gonna push it even harder this year. > Without spec you cannot even tell compiler bugs from intended behaviour. So this is true, but it's also a bit more subtle than that. For example, "there should be no undefined behavior in safe Rust" is a design principle that, while we don't have a spec, can say if something is a bug or not. (And we do have a few of those bugs.) This is, of course, not as good as a full spec, but guiding principles can really help.
- GenKali 8y agoI've read through this article twice now and I still fail to see your point. Steve is most likely more familiar with Rust than any other language - which is why I would expect comparisons between it and Ada - but he doesn't go out of his way to insist on Rust's superiority.
- Raphael_Amiard 8y agoI'm one of the writers of learn.adacore.com and I disagree. This is a thought log from somebody who knows and loves Rust and is learning a new language. Steve if you're around: there is an error I think in your post, you write > Ranged integers are something people always say Rust is better at than Ada And I think you meant the opposite ;)
- EugeneOZ 8y agoJust some log of initial negative emotions. Maybe author forgot, but Rust can raise negative emotions on the initial stage also. It takes some effort and it worth it. Maybe with Ada it's the same.
- steveklabnik 8y agoI wrote down anything that stuck out: there’s a lot of questions, but also a lot of positive things! I just had more to say about things I was unsure about then things that are like “yes, this is good.”
- GolDDranks 8y agoHow did you read negative emotions into that? Most of it was "oh, cool! I wonder if..." or something like that.
- EugeneOZ 8y agoIt mostly "it doesn't work as I expect, cool". So yes, I read it as negative emotions.
- kbenson 8y agoWere you reading that as sarcasm? From Steve's other writing I've seen, and his comments here, I don't think he was being sarcastic. I think he's literally expressing something along the lines of "Oh, that's not what I would have assumed, but it's an different way that I may or may not have thought about much. That's cool, I'll see how it goes." If that interpretation comes across as negative, then I think you either must view most interactions with the world as negative or you've somehow managed to surround yourself with "yes" men...
- jaco8 8y agoWell , besides Rust currently I would consider Nim , the core team there is getting many things right .
- 8y ago
- noneeeed 8y agoI miss working in Ada, but I don't miss the industry. Working in SPARK Ada and Prolog early in my career taught me the importance of understanding what the "philosophy" of a language was in order to use it well. After far too much time spent trying to make them behave like a different language it clicks and then you get productive. I think it's made me much more tolerant of new languages and more forgiving of my struggles when first learning them. Some times it can take a while to understand what idomatic programs look like in a new language, especially when it's a very differnt model to ones you have been used to.
- eithed 8y agoI've learned Ada at uni - while I didn't appreciate it at that time, probably currently (almost 10 years later) I'd find it more interesting. Fact that your application doesn't compile if you don't write assertions validating it certainly has gained more appeal to me.
- fuball63 8y agoWhen I learned Ada, I used the wikibook [1] and bought an inexpensive used textbook from Amazon. I have a basic competency of the language, and really like the quality of the compiler toolset, the type system, the "DIY" OOP (as I call it), and the packaging system. My biggest issues with it are that bindings for databases, graphics libs, and web development libs are few and far between and usually just a lonely github repo. But, as another positive, writing bindings to C libs seems pretty easy [2], so someday I'll give it a try. [1] https://en.wikibooks.org/wiki/Ada_Programming https://en.wikibooks.org/wiki/Ada_Programming [2] https://flyx.org/2012/06/13/adabindings1/ https://flyx.org/2012/06/13/adabindings1/
- xemdetia 8y agoI think this is the death knell of most people trying to casually pick up Ada or most used-but-not-extremely-popular languages from the 70's and 80's, our expectation of doing something meaningful and sensible has just moved so far that not having the supporting libraries means a lot of upfront work. I think I've gotten stuck here for LISP, getting back into Pascal, Ada, and probably some other languages I wanted to experiment building a modest size application with. It really shows how valuable having that very active and mature core library or managed package library is to a language. I did the same learning path as the prior poster but then just ended up stuck.
- fuball63 8y agoPart of it is admittedly laziness and used to a certain convenience. There's no package manager for the language, and OS package managers rarely carry used-but-not-extremely-popular language bindings. But the code is out there, like this SDL2 binding: https://github.com/Lucretia/sdlada https://github.com/Lucretia/sdlada
- kqr 8y agoWriting bindings for C libraries is ridiculously easy. You can run a script that generates the corrects .ads for a header file and then... wait, there is no step 2. That's it!
- eggy 8y agoSyntax is a sore point for me, but as a polyglot, I push through my bias. I am learning Spark instead of full Ada, and instead of Rust for a project simply because there is a lot of precedent and libraries for what I need to do - a machinery controls package with high-level safety. I do like Rust though, but I am also playing with Zig for good measure.
- gvb 8y agoWRT "out" parameters, it means that very literally. There the variable is only passed out, it is not passed "in." Steve's test never assigns "A" in Foo() so "A" is an uninitialized variable that then gets stored in the mainline "A" (which has the same name, but is an entirely different variable). The mainline "A" is assigned the value 12 but then gets overwritten by the uninitialized value passed out by Foo(). with Ada.Text_IO; use Ada.Text_IO; procedure Outp is procedure Foo (A : out Integer) is begin Put_Line (Integer'Image (A)); end Foo; A : Integer := 12; begin Foo(A); end Outp; A clearer example would be: with Ada.Text_IO; use Ada.Text_IO; procedure Outp is procedure Foo (A : out Integer) is begin Put_Line (Integer'Image (A)); -- Uninitialized variable, random value A := 42; Put_Line (Integer'Image (A)); end Foo; A : Integer := 12; begin Put_Line (Integer'Image (A)); Foo(A); Put_Line (Integer'Image (A)); end Outp; This will still give the uninitialized variable warning (typically can and should configure the compiler to turn that into an error, not a warning). Playing compiler, the output should be 12 -- Outp() <random value> -- Foo() 42 -- Foo() 42 -- Outp() You can make variables in and out by saying that (literally). This will do what Steve expected: with Ada.Text_IO; use Ada.Text_IO; procedure Outp is procedure Foo (A : in out Integer) is begin Put_Line (Integer'Image (A)); end Foo; A : Integer := 12; begin Foo(A); end Outp;
- 0xDEEPFAC 8y agoAlso, added in a recent version of the language (as part of 2020) you can simply use 'Image directly on an object saving you a bit of typing : ). And let me let you in on a secret Ada programmers don't talk about or put in examples - you don't have to type the Identifier at the end of the procedures! with Ada.Text_IO; use Ada.Text_IO; procedure Outp is procedure Foo (A : in out Integer) is begin Put_Line (A'Image); end; A : Integer := 12; begin Foo (A); end;
- thestoicattack 8y agoOoh, I like that new 'Image usage. I was told that adding the identifier to the end of blocks is just a good practice, since the compiler can tell you if you misread the nesting and wrote the wrong name.
- jcadam 8y agoI learned Ada because I took a new job back in 2008 (at Boeing, doing spacecraft modeling and simulation) and discovered on my first day that I would be using Ada. Naturally, I was expected to just pick it up on my own (Not complaining, that's pretty much how it goes these days). My mother (who found it amusing I was going to be coding Ada in 2008) gave me her old Ada books from the 80s (her employer at the time sent her to an actual course to learn the new DoD mandated language, back in the days when employers invested in their people), which I still have. I ended up programming in Ada up until 2012, when I managed to get a job using Java. The language itself I rather liked (better than Java, for sure). It's the only language I've ever used that tended to produce programs that worked correctly on their first run (getting them to compile was the difficult part). The aerospace industry OTOH, I don't miss.
- majewsky 8y ago> It's the only language I've ever used that tended to produce programs that worked correctly on their first run I've had the same experience with Rust. (Never used Ada/Spark myself.)
- bibyte 8y ago> It's the only language I've ever used that tended to produce programs that worked correctly on their first run From my experience that is generally true with languages that have strong static type systems (like Haskell and Rust).
- syrrim 8y agoFrom my experience it's true in python (ie not a static type system). Removing the distinction between compiling and running makes this point even stronger.
- 59nadir 8y agoThis is not at all my experience, neither with my own code or code other people produce. Unless the problem is extremely trivial the solution is very unlikely to work without a few test runs. The bigger point in all of this is that statically typed languages at least have some kind of check mark they can put on your code to say "Yeah, at least the types make sense". They also encourage designing with types in order to enforce business logic, which is something you don't get in any of the dynamic languages.
- agumonkey 8y agoFunny how trends work, Ada is popping up in mainstream places (considering HN mainstream somehow, also reddit) recently.
- ainar-g 8y agoAda has always had a reputation for being a more secure system-level programming language, and thankfully security is very much in right now. I think Rust has played a significant role in this mini-resurrection of Ada.
- agumonkey 8y agoMuch probably. Safe + low level was synonymous with Ada but it wasnt trendy
- layoutIfNeeded 8y agoInteresting. I would have guessed that a person contributing to what's touted as the new safest language ever, should already be familiar with prior art in the field. Otherwise one would be prone to unnecessarily reinventing the wheel... Better late than never I guess.
- lukebitts 8y agoWhat a weird expectation
- AnimalMuppet 8y agoYes and no. No, if one is designing something that will be state of the art, it is not unreasonable to expect that the designer knows what the previous state of the art is. But yes, it's weird. First, he's not a designer of the language. Second, there are too many languages for anyone to be intimately familiar with all of them. And third, there's just this weird bunch of very negative comments. What's up with that? You don't like Rust? (Not you, lukebitts, but the original commenter.) Fine. Don't use it. You don't like the publicity it's getting? You think your language is better? Languages are tools; they're not rock bands. Feel free to like and use yours. Rust doesn't take anything away from that. You don't like Steve? You think he's getting too much attention? He's getting it for useful, informative contributions. You want that kind of attention? Go and do likewise, rather than whining and sniping because someone else is getting attention.
- eeZah7Ux 8y agoSeriously? Reinventing the wheel with no reason other than ignorance sounds bad to me.
- steveklabnik 8y agoThere is a lot of prior art in the field of PLT, and I did not get a graduate computer science degree, where much of this is taught. In undergrad, the closest classes were very broad overviews of programming paradigms generally. There's also the difference between being familiar and knowing things in-depth; I was previously aware of the broad strokes of Ada and many of its features, but only at a high level. The point is to deepen this understanding. (Also, I'm not on the language design team.)
- bibyte 8y agoI really like the format of this article. From my very brief experience with Ada it seemed like a very well designed language to me. It's a shame it didn't get popular enough to compete with C and C++.
- 0xDEEPFAC 8y agoYea Ada 95 was set to take off in some sort of way, but Java came out just a bit earlier and crushed it with publicity - and then Javascript was "birthed" in 2 weeks and ruined software forever..
- afiori 8y agoIt is fair to mention that when javascript was created it was indeed the best tool for the job
- 0xDEEPFAC 8y agoThats very subjective and I respectfully disagree : ). It was indeed literally created in the order of weeks (not even a full month) and it morphed into a monster quickly and punished users with its many half baked ideas and short-sided design. http://blogopod.com/image/2014/javascript-comparison-table.png http://blogopod.com/image/2014/javascript-comparison-table.p... The software world could easily go without javascript and be a less toxic, buzzfilled, electron bloated swarm.
- gambler 8y agoIf browsers used SmallTalk we would leapfrog about 30 years of reinventing the broken wheel and everyone would be better off (except maybe a few overpaid framework experts).
- kbenson 8y agoAssuming there would have been the same rate of adoption. I don't know, is it as easy to learn SmallTalk and do small tasks with it? The existing ecosystem may have been pretty good, all things considered. Fast ramp-up, with eventual shift into supporting bytecode efficiently so any language can run. Would you rather be coding around the inconsistencies in the SmallTalk implementations of Microsoft, Google and Mozilla, or just delivering a bytecode package of your code in whatever your favorite SmallTalk implementation (or any other language) is?
- cdeutsch 8y agoAda was the first language I learned at the University of North Dakota's Computer Science program in 1996. Since the university is known for its Areospace program, I guess that made sense to pick Ada as their primary language.
- protomyth 8y agoInteresting, in Fall of 1988, University of North Dakota was using Modula-2 as the starting language for their core classes having switched from Pascal in the Summer. The classes were taught on an IBM 370, so students also got to learn the joys of Xedit, IBM terminals, EBCDIC, and batch processing. They only used Ada for the Software Engineering class which I took and was very disappointed in, but not the language which I liked. Lisp was not fun on the VAX. One of the things I'm a bit ticked about is that they moved the CompSci program from Aerospace to the School of Mines and Engineering. So, just as the drone era is starting they move CompSci to better align with other colleges. What a crock.
- barryp 8y agoOh cool, a UND Computer Science Alumni hangout. I started with Pascal on the IBM mainframe VSPC in the fall of '83. Batch processing was a shock coming from an Apple ][ background in high school. Was nicer when we got access to the interactive machines like the VAX and the PDP/11. I liked Ada, vaguely remember it being on the VAX. Still have my photocopied manual for BSD 2.9 on the PDP/11 - never imagined at the time that that Unix stuff would take over the world. Nice to have had that early exposure.
- protomyth 8y agoThey still had VSPC in 85, but had switched to CMS by 87. The punch card reader / printer ended in 85, and somewhere in a box I got a stack of cards. I took C on the VAX (they bought a AT&T 3B2 somewhere around 90 or 91), and I do vaguely remember Ada was on the VAX also. My early hate of Lisp was a direct result of them teaching it on the VAX. I was told the VAX had 4MBytes of actual memory and the each Lisp instance took 5. I played poker in the basement of Upson II while the damn thing loaded my program and played more while it ran. Being a lover of Forth at that point, tended to make me think Lisp was a bit of a hog. Somehow the school got a Cray (I think from a oil company), but they weren't given the manuals right away. The manuals that they printed came from microfiche I had. I'm not sure if any students ever got to use it. UND did give a unique experience in a CompSci degree.
- tombert 8y agoI've never used Ada, but some of the graybeards I talk to have said that it's sort of like a predecessor to Rust, at least in some of the same concepts of safety with an emphasis on performance. With the risk of having my foot planted in my mouth, how "systems-ey" is Ada? Could I conceivably write an OS in nothing but Ada (and obviously a bit of assembly to kickstart it), similar to something like Redox-OS in Rust?
- steveklabnik 8y agoI'm still learning, of course, but it's my understanding that Ada is used almost exclusively in systems contexts.
- acomjean 8y agoIf I remember correctly Ada has some non-sytem things, like its own threads (tasks). For our compiler (Rational) they weren't handled by the OS. Many of the closed source compiler vendors stopped supporting them (probably too much work for too few customers), thus GNAT/ Adacore and actual OS threads. [1] http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/node14.htm http://www.iuma.ulpgc.es/users/jmiranda/gnat-rts/node14.htm Its been a while. The ada runtime didn't have a lot of things built in so for our project we built a ada library that would call out to some C code that allowed ada to call to the OS for networking/shared memory/message queues and such. Sizing of types passed from ada to C was important, but wasn't too difficult. Ada also has a record type that seemed to map well to structs.
- steveklabnik 8y agoI've seen embedded RTOSes that are focused on task-like abstractions, I don't think that means it disqualifies.
- nn3 8y agoYes early versions of https://en.wikipedia.org/wiki/RTEMS https://en.wikipedia.org/wiki/RTEMS were written in Ada. I believe modern versions are large in C with just an Ada API though.
- deleted 8y ago[deleted]
- ThomasBHickey 8y agoI watched the whole Ada process (a series of reports that developed into the language spec). While often criticized at the time of being 'designed by committee' that wasn't really the case, but did have a lot of people critiquing it. It was a great language once you understood how to structure your programs. I think it would have had much better uptake if there were free/open source implementations of it back then, but I don't think the DoD even considered that, so it cost quite a bit of money to experiment with it and very few students had a chance to use it.
- 4thaccount 8y agoI'd argue it is largely true now. If the free version is GPL'd, students can easily use it, but a lot of folks won't want to develop in something that has what is likely to be a high commercial cost. I'm still curious how much they would charge me to use the commercial version to write some scientific software that will likely have no customers. Would they be lenient and not try to charge what they would for a developer at Boeing? I'd love to know as Ada and Spark just seem really cool.
- ThomasBHickey 8y agoThere is GNAT https://www.gnu.org/software/gnat https://www.gnu.org/software/gnat
- 4thaccount 8y agoThat's what I'm referring to. I believe there is a runtime clause that means a program (Ex: hello world) isn't automatically under the GPL. However, a lot of the Adacore libraries are either GPL or commercial. At least this is how it has been explained to me.
- inetsee 8y agoI started reading about Ada back when it was still called "Green". One of my co-workers was one of the (very large) group of people invited to evaluate the candidate languages, and he let me read the draft proposal for the Green language. I learned Ada and used it in several projects throughout my career. It was one of those "good ideas" the Defense Department came up with that didn't quite work out. At the time the programming language that became Ada was proposed, the Defense Department had somewhere around 700 programming languages being used in various projects. A project looking to add staff had very little chance of finding someone who knew the language being used. They had to hire an experienced programmer and expect that he would be able to get up to speed on the language being used in time to meet the (often unreasonable) deadlines. Ada was intended to replace many or most of those 700 programming languages. It sort of worked for a while. A lot of smart people worked on developing the language, and it was used in a lot of projects. The problem was that it never got wide adoption outside of defense contractor companies and aviation companies, and sometime back the Defense Department dropped the mandate that all new projects had to use Ada. Ada is still being used in some fields, especially in some Defense Department projects, avionics and air traffic control, but it isn't in the TIOBE top 20 list of programming languages. Unless you're planning on making a career of working on defense projects, Ada probably isn't a language you should think about learning.
- Raphael_Amiard 8y ago> Ada is still being used in some fields, especially in some Defense Department projects, avionics and air traffic control, but it isn't in the TIOBE top 20 list of programming languages. Unless you're planning on making a career of working on defense projects, Ada probably isn't a language you should think about learning. I guess it depends: 1. Ada, associated with SPARK, constitutes one of the most cutting edge technologies when it comes to automated proof for embedded code. This has encouraged some very cutting edge users such as NVIDIA to invest into Ada/SPARK (https://blog.adacore.com/nvidia-blogpost-announcement https://blog.adacore.com/nvidia-blogpost-announcement) 2. Learning a new language is always interesting. If you are interested in embedded programming in general, there are few languages more interesting than Ada today IMHO. I would probably tell somebody "Learn C/C++, Ada and Rust".
- 8y ago
- mr_overalls 8y agoAda looks extremely similar in syntax to PL/SQL - Oracle's database-side programming language. In fact, I wasn't too surprised to find out that its original syntax was borrowed from Ada. http://www.orafaq.com/wiki/Ada http://www.orafaq.com/wiki/Ada
- mcguire 8y agoI believe they're descendants of ALGOL along with PL/1 and Pascal, which explains the similar syntax.
- xhrpost 8y agoWikipedia > "Ada was originally designed by a team led by French computer scientist Jean Ichbiah of CII Honeywell Bull under contract to the United States Department of Defense (DoD) from 1977 to 1983 to supersede over 450 programming languages used by the DoD at that time." Wow, it is mind blowing to me that 450 different programming languages existed in the late 70's. Do we know what most of these were? Do most exist today or have they been lost to time?
- GoblinSlayer 8y agoThis still lives in mainframes to some extent: every mainframe has its own programming language due to differences in hardware and software and legacy.
- earthicus 8y agoAccording to an amazon reviewer [1], Sammet's book Programming Languages: History and Fundamentals (from 1969) already discusses ~120 different languages! And gives code examples in 30 of them. [1] https://www.amazon.com/Programming-Languages-Fundamentals-Automatic-Computation/dp/0137299885/ref=sr_1_2?keywords=programming+language+history&qid=1553789596&s=books&sr=1-2 https://www.amazon.com/Programming-Languages-Fundamentals-Au...
- pjmlp 8y agoPlenty of them were variations of Algol, PL/I and Lisp, including for systems programming. Some surviving ones are NEWP and PL/S, if you happen to touch an IBM or Unisys mainframe.
- Jtsummers 8y agoMany were variants or specific implementations of other languages (like Algol), or assembly languages for numerous machines. Remember, this was pre-Internet. A lot of languages were developed because an office needed them for a specific application. Or they knew the theory (enough at least) of a language but didn't have an implementation for their hardware or OS, so they made a new one if they couldn't purchase one. And when you develop the language in tandem with the application, you end up with something custom and non-portable (or hard to port).
- marcodave 8y agoBack in university (~2005/06) I still remember the "concurrent and distributed programming" course, held by an extremely opinionated professor who was an Ada enthusiast and spent half of the lessons bashing Java and its lack of proper constructs for concurrent programming. We all at the time commonly agreed to hate on Ada :) (it was not a popular professor)
- agumonkey 8y agothe <receiver>'<method> syntax killed me as a student, killed me hard. That's half the reason I went deep into Lisp.