4 ms·
Still waiting on Rust. I have attempted to use it beyond toy programs, and it wasn't clicking for me. I am using SPARK2014[0], a big subset of Ada, that has a
by eggy 3y ago
Still waiting on Rust. I have attempted to use it beyond toy programs, and it wasn't clicking for me.
I am using SPARK2014[0], a big subset of Ada, that has a 25-year track record in high-integrity, safety-critical applications in civil and military applications in many fields. It's also very easy to pick up with integrated tooling and a package manager called Alire.
I used to despise verbose syntax, and when I first tried learning Ada over 12 years ago, I now see SPARK2014's syntax and methods as much easier and to work with especially with the surrounding and supportive ecosystem.
I worked through the book, "Building High Integrity Applications with Spark"[1] that is a very nice summary and intro to SPARK based on its use in the CubeSAT program.
Here's a cute little article on how SPARK2014 was used to replace some low-level stabilization routine in a bigger C program for a specific consumer drone:
https://blog.adacore.com/how-to-prevent-drone-crashes-using-spark https://blog.adacore.com/how-to-prevent-drone-crashes-using-...
[0] https://www.adacore.com/about-spark https://www.adacore.com/about-spark
[1] https://a.co/d/fgtRXxt https://a.co/d/fgtRXxt
- anta40 3y ago"alr is tailored to userspace, in a similar way to Python’s virtualenv. A project or workspace will contain all its dependencies." So, each time I create a new project with alr, an Ada toolchain will be downloaded into its project directory?
- Georgelemental 3y ago> It wasn't clicking for me. Out of curiosity, was the problem with the language itself, the embedded library/tooling ecosystem, or something else?
- eggy 3y agoTo be fair, I started programming back in 1978 with Commodore PET 2001 and went into C and assembly (6502) after that. I then picked up Pascal. Then J and APL after that. While trying Rust for the first time, nailing some of the concepts and syntax (borrow checker, etc.) to express those concepts was very confusing or too verbose to me. Then the second time I tried Rust, I was also learning Zig, and Zig came much easier to me and I could program things quicker albeit without the features of SPARK2014 or Rust for that matter, but a nice sweet spot. But when I saw the goals of Rust and I had already tried SPARK2014, it became apparent that the wish list for Rust was a reality in SPARK2014 and its tooling. The safety, integrity, verifiability, clear and simple syntax along with the formally proven language of SPARK2014, and Ada's legacy seemed the obvious choice to get actual software written for safety-critical applications. I am working on Show Control software which demands high integrity and safety. One leading package, Navigator, runs on QNX. When you are flying things over people's heads at high speeds and accelerations or flying people, you need something that is track proven for such applications. I think Rust can get there someday. I have put Rust on shelf until it matures more on this front. As others have mentioned, Adacore is not so much an PL evangelist as might be thought of by its name, but is cooperating with Ferrous Systems and others to bring Ada/SPARK2014 goodness to Rust. Rust just isn't there yet, and I am a bit too far along to devote my next 10 years to growing and learning Rust when I can apply SPARK2014 today. PL syntax is subjective, and I just find myself tripping over the verbosity in a C++/C-like syntax that Rust adds. I know there are strides to improve this, but
- genter 3y agoDon't disagree with you about Rust, but the Spark website has no download link, just a link to "Request Pricing", which requires a "professional" email. As much as I'd like to, don't think I'm going to spend my Saturday morning playing with it.
- Georgelemental 3y agoI believe you want https://www.adacore.com/download https://www.adacore.com/download?
- Jtsummers 3y agoOr use Alire which wraps it up and manages multiple installations for you. This is my preferred way to install it, and it makes it easy to select compilers for cross-compilation (like for embedded targets) or to select particular compiler versions. https://alire.ada.dev/ https://alire.ada.dev/
- ArtixFox 3y agoIs Ada really as good as its touted to be? How good is the cross compilation, metaprogramming and FFI story?
- Jtsummers 3y agoFFI is described here: http://www.ada-auth.org/standards/22rm/html/RM-B.html http://www.ada-auth.org/standards/22rm/html/RM-B.html Here with some examples using gcc and gnat: https://gcc.gnu.org/onlinedocs/gnat_ugn/Mixed-Language-Programming.html https://gcc.gnu.org/onlinedocs/gnat_ugn/Mixed-Language-Progr... And finally here with the Adacore learning site: https://learn.adacore.com/courses/intro-to-ada/chapters/interfacing_with_c.html https://learn.adacore.com/courses/intro-to-ada/chapters/inte... I have limited experience with FFI in Ada, but never had any issues. Cross compilation is about the same as you'd expect from any mature language ecosystem. Metaprogramming, it does not have macros but it has a very good generics systems. Also for some reason your comment was dead (not flagged dead) so you may want to email the HN mods (see contact at the bottom of the page) about that.
- Veliladon 3y agoI miss coding in Ada. I wish Rust would pillage more of its features. Range types especially seem like they would be at home in the Rust ecosystem.
- bobbylarrybobby 3y agoRust does have ranges? (They have their problems, namely that they're Iterator instead of IntoIterator and all the problems that entails, but they certainly exist.)
- Jtsummers 3y agoRust ranges aren't types. In Ada you can specify a type like: type Temperature is range -100 .. 300; -- in Celsius, operating range for an aircraft or system perhaps You cannot assign anything outside that range to variables of that type, if the value is known at compile time it won't compile otherwise you get a runtime error (unless you disable checks). You cannot assign an arbitrary integer variable's value (that holds a value in that range) into a variable of type Temperature, you have to cast it. T : Temperature := 500; -- won't compile ... T : Temperature; N : Integer := 50; ... T := N; -- won't compile T := T1 + T2; -- two other temperatures; runtime error if sum is outside -100 .. 300 If you want a subtype range you might do something like: type Days is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday); -- an enumeration subtype Weekdays is Days range Monday .. Friday; -- ranges are inclusive in Ada Now you can have a variable of type Days and try to put its value into a variable of type Weekdays and you'll get a runtime error if it's Saturday or Sunday. And you can use these for array indices. These are actual arrays, not dictionaries, so you don't get the performance penalty of a map/dictionary (though generic maps are also available): Schedule : array (Weekdays) of ...; -- fill in with some useful type; Weekdays is the index range D : Days; W : Weekdays; ... W := D; -- will compile, may error at runtime D := Saturday; W := D; -- will error at runtime W := Sunday; -- won't compile W := Monday; -- will compile Schedule(W) := ...;
- pjmlp 3y agoAs an addendum, this is something that most Pascal derived languages also support, Object Pascal, Mesa, Modula variants, (with exception of Oberon and its linage), and sadly many associate only to Ada.
- sam_bristow 3y agoOne interesting development is the collaboration between the Ada/spark communities and the Rust community. For example, Adacore is releasing a certified Rust compiler pretty soon [1]. I seem to recall they were using Spark for some of the core libraries then exposing all the goodness to the Rust code. [1]https://www.adacore.com/gnatpro-rust https://www.adacore.com/gnatpro-rust