Live data from Hacker News

Writing Linux Modules in Ada (2016)

nihamkin.com

31–40 of 87 posts

Re: Writing Linux Modules in Ada (2016)

#31
post #2

Back in university I took a course in legacy programming. We did a project in each of Fortran, COBOL and Ada. I enjoyed Ada very much. The module system made a lot of sense to me and the compiler found a lot of mistakes (compared to C). Thanks for sharing this article. It brought me back and makes me want to give Ada another go now that I have 10 years of real world experience.

One place where you can easily use ADA syntax is any database that implements ANSI SQL/PSM, and there are many.

"SQL/PSM is derived, seemingly directly, from Oracle's PL/SQL. Oracle developed PL/SQL and released it in 1991, basing the language on the US Department of Defense's Ada programming language."

https://en.m.wikipedia.org/wiki/SQL/PSM

Re: Writing Linux Modules in Ada (2016)

#32
post #6
post #2

Back in university I took a course in legacy programming. We did a project in each of Fortran, COBOL and Ada. I enjoyed Ada very much. The module system made a lot of sense to me and the compiler found a lot of mistakes (compared to C). Thanks for sharing this article. It brought me back and makes me want to give Ada another go now that I have 10 years of real world experience.

I had a digital design course. The instructor hated verilog and preferred VHDL for reason that didn't make much sense to me those days. There was only one VHDL compiler available that time called ghdl which worked fine for course. There was modelsim as well but one had to go to the lab. Later I learnt that VHDL is related to ADA. I've been itching to try it for a long while. Might give it a try this week. Currently I…

I've been meaning to explore ADA as well, since learning that GHDL is itself written in ADA.

Re: Writing Linux Modules in Ada (2016)

#33
post #11

Earlier quoted context omitted.

It's unclear exactly what you mean by your remark that Ada's syntax hasn't aged well, let alone what a 21st-century overhaul would look like. Is there any chance you'd expand on that? I'm curious to know your thoughts.

They probably mean that they can’t get past the fact that it looks more like Algol or Pascal than C. Which is, frankly, a pretty silly argument. I’ve heard this exact argument about VHDL versus Verilog, with the former being explicitly based on Ada’s syntax and the latter being explicitly based on C’s. (Turns out though that VHDL is also strictly better than at least traditional Verilog, as it requires separate inter…

It always makes me grin when newbies complain that VHDL is too verbose. The pain of hooking up the Xilinx AXI interconnect in about three feet of (pre-system)verilog is something I will not forget in a hurry. Having wrapped it in VHDL with nice neat record types, I can now hook it up in just a few lines of VHDL.

I think of it a bit like rat's nest wiring vs. nice neat labelled cable looms.

Re: Writing Linux Modules in Ada (2016)

#35
post #28
post #16

Earlier quoted context omitted.

Usually many forget that their beloved C, JavaScript, Webassembly, OpenGL, Vulkan, Web, POSIX,... are equally design by committee.

The benevolent dictator cachet comes mostly from Python microcosm.

And Perl before that.

It's not a bad way to go, in practice, as long as it lasts.

Re: Writing Linux Modules in Ada (2016)

#36
post #17

Earlier quoted context omitted.

Ada’s take on memory safety is pretty limited. Heap allocation is explicit; there’s a procedure literally named Unchecked_Deallocation to free a pointer. It does have thread-scoped locals and arenas, but nothing like declared lifetimes or borrowing. The spec allows for GC but I believe it’s rarely offered. It’s safer than C, but I’m not quite sure where recent specs line up against C++.

Only true for those stuck in Ada83. People keep repeating this nonsense without updating themselves beforehand. EDIT: To simply education on Ada, Yes there was an optional GC, no one ever implemented it, so in Ada2012 got removed from the standard. Almost everything can be allocated on the stack, so a strategy is to catch exceptions of not enough stack space and retry the same function with a smaller size for the dat…

>Ada95 introduced controlled types, which is basically Ada's version of RAII, no need to call Unchecked_Deallocation outside implementation details. Hardly any different from Rust code that uses unsafe underneath.

This is basically like C++ destructors, but the problem is there are no move semantics in Ada, so you can't implement something like unique_ptr.

It's hardly comparable with Rust.

Re: Writing Linux Modules in Ada (2016)

#37
post #21
post #7

Earlier quoted context omitted.

I completely agree. 'Design-by-committee' gets a bad rap, but Ada's designers got a lot of things right when it came to bare-metal programming. The ability to specify the in-memory representation of a type is one of my personal favourites. I don't think Ada's syntax has aged well. I wish it would get a 21st-century overhaul. I don't think that's likely though, but we can all dream. AdaCore do great work, and contribu…

For what it is worth, Ada was not "designed by committee" more than most languages. It was designed by a design team, and in each revision, there was a strong technical leader of the design team, with the whole design team sharing a strong design aesthetic. I doubt you could say even that about many mainstream languages these days.

Thank you for clearing this up. My use of the phrase 'designed by committee' was more of a reference to a common criticism of Ada, than to any actual historical fact. Not that I was actually any the wiser, I admit. I'm a big fan of your work. Thanks for taking the time to reply.

Re: Writing Linux Modules in Ada (2016)

#38
post #23
post #8

I've never used Ada, and I also don't really do systems stuff, but it does seem like it's a pretty neat language, at least compared to C. From what I have seen, it looks like it has better memory guarantees while still being fast and low-level. With be the popularity of Rust, it makes me kind of wonder why Ada isn't more popular. I should give the language a go.

There wasn't an open source compiler from the beginning, and thus a lot of the compilers where expensive. You could only use the language in an awful legacy setting behind a wall of NDAs and security clearances. Not my experience, just a bunch comments on HN of actual retired Ada devs on why the language didn't take when I was researching the language. Adacore in the last few years have been investing heavily in mode…

This is true, I've worked on a actively maintained Ada codebase in aerospace industry and we had to use a proprietary Ada Xd compiler that was being sold for hundreds of thousands of dollars per installation by company not interested in doing any updates, that came with a phonebook-size paper errata of known bugs.

Re: Writing Linux Modules in Ada (2016)

#39
post #11
post #7

Earlier quoted context omitted.

I completely agree. 'Design-by-committee' gets a bad rap, but Ada's designers got a lot of things right when it came to bare-metal programming. The ability to specify the in-memory representation of a type is one of my personal favourites. I don't think Ada's syntax has aged well. I wish it would get a 21st-century overhaul. I don't think that's likely though, but we can all dream. AdaCore do great work, and contribu…

It's unclear exactly what you mean by your remark that Ada's syntax hasn't aged well, let alone what a 21st-century overhaul would look like. Is there any chance you'd expand on that? I'm curious to know your thoughts.

Sure. I write a lot of Ada, and I'm a big fan of the language overall. My criticisms are minor, and it doesn't stop me enjoying the language: I feel like the 'begin', and 'end' tokens can be a bit verbose, and their verbosity doesn't add much to the language's clarity; I also dislike the fact that I need to place the same subprogram specification in both the specification and body file; I'm also on the fence about some of Ada's pointer semantics; For what it's worth, I'm also not a big fan of the particular style that the Ada language server auto-formats code into.

I'll use this chance to say that I'm a fan of Ada's declarative blocks, which you could say are part of its syntax. There's a lot to like about Ada, and I'd encourage anyone interested in bare-metal programming to give it a try. Even if you don't intend to use it long-term, there's a lot of good language design ideas in Ada that can be learned from.

To address a sibling comment alleging that I'd rather it look like C, that's not necessarily true. I know this is much more controversial, but I'm actually more of a fan of Python's syntax.

Re: Writing Linux Modules in Ada (2016)

#40
Ahh, Lovely Ada. When I was a wee lad, toiling as an Email consultant, having my mind slowly destroyed by Sendmail configurations, the constant fear induced by anything related to Microsoft and Email, and, well, let's not mention Lotus Notes, some wounds never heal, I had the grand idea of writing a secure collection of Email tools.

This included SMTP, IMAP, POP3 daemons, and various other tools. I was going to write them all in Ada. I had a basic SMTP daemon that would accept mail and deliver it. But then, one of the various Outlook worms generated a ton of revenue at the expense of sleep, hygiene, and dignity, and I decided to get out of the Email business ASAP.

Still wish I would have kept working with Ada. I really liked it, and one could write tight code with it.

Post reply on HN