Live data from Hacker News

Ada: a C Developer's Perspective

methodsandtools.com

81–90 of 157 posts

Re: Ada: a C Developer's Perspective

#81
post #49
post #40

Earlier quoted context omitted.

What kind of semantics cannot be well expressed with Rust type systems, compared to Ada? The type system is algebraic, and pretty powerful.

first thing that comes to mind are bounds on integer subtypes. classic example is to declare an array to be indexed with such a type, then all out-of-bounds errors can be checked at compile time.

GHC Haskell lets you implement that as a normal library: https://nikita-volkov.github.io/refined/

Hopefully Rust will get type-level numbers and stuff someday :)

Re: Ada: a C Developer's Perspective

#82
post #6

It's not only a language that is key to success. Libraries. I searched for LDAP support for ADA (old protocol used by many companies). I found library ( http://savannah.nongnu.org/projects/adaldap/ ) with latest news from 2002 and CVS repo :) Then I search for SNMP (another dinosaur still in wildly use) - similar result. Second - many solutions/libraries are purely commercial. You need basic open protocols support by…

This idea that Rust and Ada are somehow alternatives continually pops up, and I still don't understand it. They each have their own ideas on what "safety" is, and how to address it. I'll admit I'm biased towards Ada, but I think it is pretty safe to say that "Rust safety" is a subset of "Ada safety" - but Rust does it's section and run further with it than Ada. Rust is obsessed with memory safety. That's it's thing.…

I've always had a massive soft spot for Ada but I've never been able to find a use for it in actual work (not much call for it on the web).

I think the reason I like the language is the type system which is like the pascal one on steroids and I love Pascal, it was the language that taught me you could reason about a program by building up from primitives.

Re: Ada: a C Developer's Perspective

#83

Earlier quoted context omitted.

This idea that Rust and Ada are somehow alternatives continually pops up, and I still don't understand it. They each have their own ideas on what "safety" is, and how to address it. I'll admit I'm biased towards Ada, but I think it is pretty safe to say that "Rust safety" is a subset of "Ada safety" - but Rust does it's section and run further with it than Ada. Rust is obsessed with memory safety. That's it's thing.…

I've always had a massive soft spot for Ada but I've never been able to find a use for it in actual work (not much call for it on the web). I think the reason I like the language is the type system which is like the pascal one on steroids and I love Pascal, it was the language that taught me you could reason about a program by building up from primitives.

> (not much call for it on the web)

Server-side stuff is a big focus of the upcoming year, so maybe then? :)

(I've been doing more of it lately and found it surprisingly pleasant)

Re: Ada: a C Developer's Perspective

#84
post #50

Earlier quoted context omitted.

Range types are probably the main thing I miss from the Rust type system. But even without range constraints, wrapper types (called newtypes in Haskell and Rust) are great. Let's say you have a function that accepts a temperature. A temperature is a float, but you want to prevent the user from mixing up celsius and fahrenheit. This is what newtype looks like in Rust: struct Celsius(pub f64); struct Fahrenheit(pub f64…

This is exactly what C does. #include typedef struct { double v; } Celsius; typedef struct { double v; } Fahrenheit; void print_celsius(Celsius temperature) { printf("Temperature is %f", temperature.v); } void compile_error(Fahrenheit temperature) { print_celsius(temperature); } I suspect LLVM will clean this up to plain floats as well.

Yeah, C and Rust work the same way here (as far as I can tell). Rust can also define type aliases (with the 'type' keyword) but they're not new types much like C typedefs.

The only advantage of Rust in this case is that its tuple syntax can be a bit nicer than C structs and the language supports overloading so that you can reimplement the comparison operators for instance (or do more complicated things, for instance if you have a "decibel" type that must have a special addition implementation)

Re: Ada: a C Developer's Perspective

#85
post #37

Earlier quoted context omitted.

If you start a project today that depends on a library that was last updated in 2002, then may God help you.

Why? Ada libraries from 2002 without outside dependencies work perfectly fine. I'm using that old libraries all the time. Ada has been designed specifically for that, it's been used in the aviation industry that runs the same code for 20+ years minimum. That you think otherwise only shows that you've never seriously used Ada in a larger project.

The last version of DOS also works really well for the things it was designed for. You still wouldn't start new projects targeting DOS if you could help it, even if it would satisfy your current requirements.

Re: Ada: a C Developer's Perspective

#86
post #49

Earlier quoted context omitted.

first thing that comes to mind are bounds on integer subtypes. classic example is to declare an array to be indexed with such a type, then all out-of-bounds errors can be checked at compile time.

GHC Haskell lets you implement that as a normal library: https://nikita-volkov.github.io/refined/ Hopefully Rust will get type-level numbers and stuff someday :)

See https://github.com/rust-lang/rfcs/pull/1931 and https://internals.rust-lang.org/t/lang-team-minutes-const-ge...

> We believe that we can have an RFC accepted and const generics available on nightly by the end of 2017. :tada:

Re: Ada: a C Developer's Perspective

#87
post #6

It's not only a language that is key to success. Libraries. I searched for LDAP support for ADA (old protocol used by many companies). I found library ( http://savannah.nongnu.org/projects/adaldap/ ) with latest news from 2002 and CVS repo :) Then I search for SNMP (another dinosaur still in wildly use) - similar result. Second - many solutions/libraries are purely commercial. You need basic open protocols support by…

This idea that Rust and Ada are somehow alternatives continually pops up, and I still don't understand it. They each have their own ideas on what "safety" is, and how to address it. I'll admit I'm biased towards Ada, but I think it is pretty safe to say that "Rust safety" is a subset of "Ada safety" - but Rust does it's section and run further with it than Ada. Rust is obsessed with memory safety. That's it's thing.…

I don't really understand the "Rust is obsessed with memory safety" meme.

When pitching Rust to others of course memory safety and thread safety get hyped a lot; because it's talking about something that most languages just can't do -- safety without compromise.

But actually ... memory safety is a small part of the reasons why I like Rust, and there are plenty of other cool bits in the language. It stands out a bit because it's different, but that doesn't make it the end-all goal.

Re: Ada: a C Developer's Perspective

#88

Earlier quoted context omitted.

This idea that Rust and Ada are somehow alternatives continually pops up, and I still don't understand it. They each have their own ideas on what "safety" is, and how to address it. I'll admit I'm biased towards Ada, but I think it is pretty safe to say that "Rust safety" is a subset of "Ada safety" - but Rust does it's section and run further with it than Ada. Rust is obsessed with memory safety. That's it's thing.…

I don't really understand the "Rust is obsessed with memory safety" meme. When pitching Rust to others of course memory safety and thread safety get hyped a lot; because it's talking about something that most languages just can't do -- safety without compromise. But actually ... memory safety is a small part of the reasons why I like Rust, and there are plenty of other cool bits in the language. It stands out a bit b…

https://brson.github.io/fireflowers/ for example

Re: Ada: a C Developer's Perspective

#89
post #6

It's not only a language that is key to success. Libraries. I searched for LDAP support for ADA (old protocol used by many companies). I found library ( http://savannah.nongnu.org/projects/adaldap/ ) with latest news from 2002 and CVS repo :) Then I search for SNMP (another dinosaur still in wildly use) - similar result. Second - many solutions/libraries are purely commercial. You need basic open protocols support by…

However, interfacing C code from Ada is a very straightforward process, where most types and procedures can be mapped automatically to corresponding Ada types. So if there exists a C library for the thing you want to do, you can easily use it from Ada.

Re: Ada: a C Developer's Perspective

#90
post #29

I had a strange internship topics involving Ada. I tried to run a huge program (a simple stdio wrapper around a huge library actually) on an Android machine (Android 2.3, ARM). At that time, the only ADA compiler for ARM was available on BSD so I had used a Windows machine for development and a OpenBSD laptop for compiling the wrapper. The subtyping feature I love the most. You see the benefit when you need to call a…

> The subtyping feature I love the most. I only have very little experience with Ada, but being able to define a type whose values are integers in the range, say, 1 .. 7, to represent days of a week was an eye opener.

Though if you're dealing in days of the week, you probably want an enumeration to avoid the whole "does 1 mean Sunday" thing.
Post reply on HN