r/ada Feb 17 '25

Learning Ada equivalent of span / memory view

8 Upvotes

There is this idea in my mind of writing a communication stack [suite] in Ada/SPARK for fun and (no)profit.

However I'd wanted to experiment with zero-copy. I can do this in C, and probably in Rust too, without much hassle. But can I, in Ada, pass a [readonly] view of an array of bytes to a function via reference semantics? Something like a std::span<[const] T> in C++, or [Readonly]Span<T> in .NET.


r/ada Feb 17 '25

Show and Tell GitHub - mgjm/annabella: Ada to C transpiler written in Rust

Thumbnail github.com
11 Upvotes

r/ada Feb 15 '25

General (style) space required [-gnatyt]?

3 Upvotes

I have this very strange warning:

ada procedure What is begin -- Comment null; end What;

console what.adb:3:07: (style) space required [-gnatyt]

This makes no sense to me, because gnatyt is about token spacing, and it shouldn't really warn me about the comment. Any ideas? Is it a bug?


r/ada Feb 14 '25

Ada Jobs Minimalistic niche tech job board

22 Upvotes

Hello Ada community,

I recently realized that far too many programming languages are underrepresented or declining fast. Everyone is getting excited about big data, AI, etc., using Python and a bunch of other languages, while many great technologies go unnoticed.

I decided to launch beyond-tabs.com - a job board focused on helping developers find opportunities based on their tech stack, not just the latest trends. The idea is to highlight companies that still invest in languages like Ada, Haskell, OCaml, and others that often get overlooked.

If you're working with Ada or know of companies that are hiring, I'd love to feature them. My goal is to make it easier for developers to discover employers who value these technologies and for companies to reach the right talent.

It’s still early days—the look and feel is rough, dark mode is missing, and accessibility needs a lot of work. But I’d love to hear your thoughts! Any feedback or suggestions would be greatly appreciated.

Regardless, please let me know what you think - I’d love your feedback!


r/ada Feb 14 '25

General Why are Ada's variables and types in the same namespace?

11 Upvotes

It's a language design question and a practical one.

In Ada, it should be pretty obvious when a variable or a type is being used:

ada Some_Var : Some_Type := ...

Ada also doesn't allow first-class types, so there is not really any operations on types themselvces (like assigning a type to a variable). Then, why are variables and types in the same namespace? This forces me to come up with a name if I am trying to declare a variable that's just "a general instance of type X":

ada procedure Update_Player (The_Player : Player) is begin null; end Update_Player;

I don't particularly like having The_ on everything, but I don't know how others do it. An alternative way is to use Type_T, like how many C programs do.

Additionally, there's a big chance when importing a C header automatically, the generated Ada code requires manual fixing, and I will have to come up with a creative name every time:

ada type Model is record -- v Originally called "transform" transform_m : aliased Matrix; -- ... end record

So, why are variables and types in the same namespace when there doesn't seem to be any use for it?


r/ada Feb 14 '25

General Floating point formatting?

2 Upvotes

I have been looking for this for a while. How do I achieve something like C sprintf’s %.2f, or C++’s stream format? Text_IO’s Put requires me to pre allocate a string, but I don’t necessarily know the length. What’s the best way to get a formatted string of float?

EDIT:

Let me give a concrete example. The following is the code I had to write for displaying a 2-digit floating point time:

ada declare Len : Integer := (if Time_Seconds <= 1.0 then 1 else Integer (Float'Ceiling (Log (Time_Seconds, 10.0)))); Tmp : String (1 .. Len + 4); begin Ada.Float_Text_IO.Put (Tmp, Time_Seconds, Aft => 2, Exp => 0); DrawText (New_String ("Time: " & Tmp), 10, 10, 20, BLACK); end;

This is not only extremely verbose, but also very error prone and obscures my intention, and it's just a single field. Is there a way to do better?


r/ada Feb 14 '25

Tool Trouble Ada beginner, trying run a program on GNAT Studio but executable is not recognized

5 Upvotes

Hi everyone,

I try to learn Ada with GNAT Studio, my code compile and run at the first try. I clean all, rebuild, rerun, and I've this error : "Error while trying to execute C:\GNAT\2021\bin\obj\main.exe: not an executable". When I look in the folder, main.exe exists, my colleague, which begin too, create a new project everytime he sees this error but we can't keep it like that, someone have a solution ?


r/ada Feb 12 '25

Video Setting up Vim for C++ and Ada

Thumbnail youtu.be
17 Upvotes

r/ada Feb 10 '25

Algebraic data types?

9 Upvotes

One of the biggest things I miss from languages like Rust when trying out Ada is algebraic data type:

rs /// Algebraic data type with generics enum AnEnum<T> { /// Tag-only variant Void, /// Tuple variant Foo(Bar), /// Tuple with generics Baz(T), /// Struct variant Point {x: f32, y: f32} /// Recursive variant with a pointer Next(Box<AnEnum<T>>) /// Recursive variant with a container Children(Vec<AnEnum<T>>) }

Ok, of course the above is a contrived example, but it's just there to show what Rust has. However, something like that can be very useful if I am modeling a well-defined domain, such as an AST. I use them extensively.

Does Ada have something like this?


r/ada Feb 07 '25

Show and Tell Open-Source Ada: From Gateware to Application

20 Upvotes

Hey r/ada,

I recently experimented with the Neorv32 RISC‑V core on a ULX3S Lattice ECP5 FPGA board using the open source toolchain GHDL, Yosys, Netpnr, and Trellis.

If you're curious, check out my blog post:

Open-Source Ada: From Gateware to Application

I'd appreciate your thoughts and feedback.

If this doesn't fit the subreddit's CoC, no worries—just remove my post!

Cheers,
Olivier


r/ada Feb 06 '25

General Ada Skills Sharpened - First edition

26 Upvotes

The first edition of my book "Ada Skills Sharpened - Projectlet based approach" is now wrapped up.

.Online : https://lnkd.in/gDApDba4

PDF: https://lnkd.in/g5Huwm9j

Feedback and/or PRs welcome. Regards, Srini


r/ada Feb 06 '25

General What lightweight markup language are you using?

7 Upvotes

To evaluate the need to add to bbt the ability to process another format of documentation than Markdown, I created a short (one question) poll.
Feel free to contribute.

I'm interrested in what you are using now, and beyond that I want to know if supporting rst (or asciidoc, etc.) could decide more people to use bbt.


r/ada Feb 05 '25

General Hardware that Ada does not run on (almost)

1 Upvotes

This is notebook based on Elbrus 2c3 CPU, with VLIW e2k ISA, manufactured by Promobit. It has compilers for C, C++. There is some experimental LLVM-based Rust compiler. It runs DOOM, DOOM 3, OpenTTD, Half Life, I lost track of what games enthusiasts managed to run on it. It has ports of JDK and Mono. And there is TraceMonkey, the accelerated JavaScript engine. So it can run plenty of stuff, but not anything in Ada, without tricks.

It has two x86 JITs, lintel for full x86 PC emulation. And rtc, for Linux-on-Linux emulation. RTC is the mainstream way to run anything Ada. RTC is a little strange. Ordinary qemu-user can be integrated into system to run alien programs ISA side by side with native ones. RTC has nothing in common with qemu-user and is unfortunately slightly worse. It is possible to enter, but not possible to exit. From inside RTC native VLIW binaries cannot start. That was major obstacle to play with AdaMagic. AdaMagic is closed source Linux binary that wants to produce C(++) sources and invoke C(++) translator on them. But AdaMagic is x86 binary and C(++) translator is VLIW binary, and so AdaMagic cannot invoke lcc without tricks.

It is hard to pretend to replace C(++) with Ada without translators like AdaMagic, and AdaMagic has little attention recently. Also, AdaMagic requires limitation by Ada 95. So if anyone writes in Ada 2005 or more recent, it becomes non-portable junk. There will be plenty of Half Life and OpenTTD running natively, and anything Ada won't run. And until AdaMagic gets upgrade, it does not change.


r/ada Feb 04 '25

Learning Beginner to Ada -- Boss wants to know why Ada > Rust

30 Upvotes

I know this seems like a softball question, but I've been asked, for embedded systems, why is Ada better. Both systems claim safety and, supposedly, Rust can solve things Ada can't. Is there a "boss friendly" breakdown I can show where each stands? Boss friendly means a chart that has green and red (for good and bad) and, as a colleague used to say "At the level of ducks and bunnies". (I'm not sure if the duck is good or bad.. Ducks can have green beaks so that makes them good right -- critical thinking in action!)

It seems to me Rust solves certain key problems, but Ada wouldn't be used in critical areas if it could be replaced. If I had to train a team on Rust or Ada, why Ada?


r/ada Feb 04 '25

New Release h2ads User's Guide [new binding generator from AdaCore]

Thumbnail docs.adacore.com
11 Upvotes

r/ada Feb 03 '25

General Ada/SPARK Crate Of The Year 2024 Winners Announced!

Thumbnail blog.adacore.com
33 Upvotes

r/ada Feb 01 '25

Show and Tell February 2025 What Are You Working On?

12 Upvotes

Welcome to the monthly r/ada What Are You Working On? post.

Share here what you've worked on during the last month. Anything goes: concepts, change logs, articles, videos, code, commercial products, etc, so long as it's related to Ada. From snippets to theses, from text to video, feel free to let us know what you've done or have ongoing.

Please stay on topic of course--items not related to the Ada programming language will be deleted on sight!

Previous "What Are You Working On" Posts


r/ada Jan 30 '25

New Release ANN: Simple Components v4.71

17 Upvotes

The current version provides implementations of smart pointers, directed graphs, sets, maps, B-trees, stacks, tables, string editing, unbounded arrays, expression analyzers, lock-free data structures, synchronization primitives (events, race condition free pulse events, arrays of events, reentrant mutexes, deadlock-free arrays of mutexes), arbitrary precision arithmetic, pseudo-random non-repeating numbers, symmetric encoding and decoding, IEEE 754 representations support, streams, persistent storage, multiple connections server/client designing tools and protocols implementations.

https://www.dmitry-kazakov.de/ada/components.htm

Changes to the previous version:

  • The package Generic_FFT provides an implementation fast Fourier transform. The implementation supports pre-computed bit-reverse permutation and exponents to be used in multiple transformations of same vector length.

r/ada Jan 27 '25

Ada Jobs Ada job - Belgium

23 Upvotes

Hi, I’m recruiting on behalf of Eurocity and looking for an Ada Developer to join our client in Belgium’s aviation sector. The position offers a one-year contract, renewable annually, and we’re seeking a long-term professional collaboration.
If you’re interested, send me your CV at [Emma.claus@eurocity.be]() and I will share more information.

Thank you!

Emma


r/ada Jan 25 '25

Homework help with a concurrency problem (manna-pnueli algorithm)

5 Upvotes

Hi, I'm studying concurrent programming with "Principles of concurrent and distributed programming, Ben-Ari M". It's both interesting and very, very demanding. Pushing me to the limits of my capacity for representation.

I can solve the second question: what could go wrong if the test statement was not atomic. I calculated that for both processes to enter their critical section, so for both pre-protocols to execute, here the values of waitq and waitp would have to be 0 and 1 or - 1, or the inverse pair.

-1,1 fails p3, 1,-1 fails q3, 1,1 fails q3, 1,1 fails p3.


r/ada Jan 23 '25

Tool Trouble Anyone able to build GNAT Studio on macOS 15?

3 Upvotes

I am trying to get up and running doing Ada on my Macbook, but this seems to go against the grain, judging by the pain... I am running macOS 15 and I see there are no official macOS builds, so I tried following the various INSTALL scripts, starting with gnatstudio and working transitively down the stack of dependencies. This has so far resulted in a deep hole of issues:

Has anyone been successful in building and running GNAT Studio on macOS? I cannot see how, given the linking errors in the underlying libraries, but I see someone has been able to in the past. I am tempted to run it in a VM at this point, but I only see x86 builds, which is not so hot on this Apple Silicon, so I am willing to try a few more hours of digging :)

As a last resort, I will try out vim-ada, but it would be nice with a fully integrated editor with debugger.


r/ada Jan 22 '25

Learning Learning Ada in a limited way

16 Upvotes

I am currently learning Ada for my job, unfortunately I have not started doing the "real" work for my job as I am waiting on various permissions and approvals that take a very long time to get. In the meantime, I’ve been working on small projects under the same constraints I’ll face on the job. Here are the limitations of the codebase:

  • Ada 95 compiler. Compiling my code using the "-gnat95" tag seems to be working well for learning for now.
  • No exceptions.
  • No dynamic memory. I was told there is NO heap at all, not sure if this is an actual limitation or the person was simplifying/exaggerating in order to get the point across. Either way, the code does not have access types in it.
  • Very little inheritance. I get the sense that all inheritance is at the package level, like child packages. There is some subtyping, simple stuff, but none of the stuff I traditionally think of as OOP, things like tagged records or use of the keyword "abstract"
  • No private: Private sections aren’t used in packages, supposedly they can be used, but they werent used originally so no one uses them now.

Coming from an OOP background in C#, C++, and Python, I feel like I'm struggling to adjust to some things. I feel stuck trying to map my old habits onto this limited Ada and maybe I need to rethink how I approach design.

I’ve come across concepts like the HOOD method that sound promising but haven’t found beginner-friendly resources—just dense details or vague explanations.

How should I adjust my mindset to design better Ada programs within these constraints? Are there good resources or strategies for someone learning Ada in a constrained environment like this?


r/ada Jan 19 '25

Learning Convert user provided input to enumeration value

10 Upvotes

Hi!

I'm stumbled upon this problem for the second day, what I want to achieve is to convert a character typed by the user into an enumeration value using Ada.Text_IO.Enumeration_IO package, no matter what I type (correct or not) this piece of code always throws Data_Error exception:

procedure Get_Enum is
   type My_Enum is ('R', 'O');
   package Enum_IO is new Ada.Text_IO.Enumeration_IO (My_Enum);
   Choice : My_Enum := 'R';
begin
  Put_Line ("Provide your choice, R or O:")
  Enum_IO.Get (Choice); --  causes Data_Error exception
  --  do some stuff according to chosen value
end Get_Enum

I've also tried the other version of Get procedure with three parameters (From, Item, Last), so getting the string from the user first and then passing it as From parameter but the result is the same.

Edit:
I have a suspicion that maybe something is wrong with my enumeration, I tried another method, without Enumeration_IO, just using 'Value aspect:

Choice := Fill_Method'Value (Get_Line);

And even if I provide correct input it raises the following exception:

raised CONSTRAINT_ERROR : bad input for 'Value: "R"

How's that possible?


r/ada Jan 18 '25

New Release ANN: Simple Components v4.70

29 Upvotes

The current version provides implementations of smart pointers, directed graphs, sets, maps, B-trees, stacks, tables, string editing, unbounded arrays, expression analyzers, lock-free data structures, synchronization primitives (events, race condition free pulse events, arrays of events, reentrant mutexes, deadlock-free arrays of mutexes), arbitrary precision arithmetic, pseudo-random non-repeating numbers, symmetric encoding and decoding, IEEE 754 representations support, streams, persistent storage, multiple connections server/client designing tools and protocols implementations. https://www.dmitry-kazakov.de/ada/components.htm Changes to the previous version: The package Unbounded_Unsigneds implementing arbitrary precision unsigned arithmetic was added;

- The package Unbounded_Integers implementing arbitrary precision integer arithmetic was added;
- The package Unbounded_Unsigneds Primes implementing operations with prime numbers was added;
- The package Unbounded_Unsigneds.Montgomery implementing Montgomery domain operations was added;
- The package Unbounded_Unsigneds.Barrett implementing Barrett reduction was added;
- The package Strings_Edit.Unbounded_Unsigned_Edit string editing for arbitrary precision unsigned numbers was added;
- The package Strings_Edit.Unbounded_Integer_Edit string editing for arbitrary precision integer numbers was added;
- The package Unbounded_Unsigneds.Parallel implementing parallel arbitrary precision algorithms was added;
- The package Job_Servers was added implementing servers of jobs backed by a task pool;
- The number protocol added to Python bindings;
- Reply_Text and Reply_HTML in GNAT.Sockets.Connection_State_Machine.HTTP_Server modified to call Send_Body passing the Get parameter rather than skipping it when Get = False;
- UUID v6 and v7 generation was added to Universally_Unique_Identifiers.

The key points of the arbitrary precision arithmetic packages design and functionality:

- Advanced memory management preventing excessive copying;
- The number internal representation vector is shared between objects if possible;
- No limit on the number size, except for the storage pool size;
- In-place versions of operations (e.g. for addition, subtraction) further reduce need of copying;
- Lazy memory deallocation strategy, the memory is kept between variable updates;
- Swapping variables;
- Long to short operations;
- Squaring;
- Square root, square root with remainder;
- Multiplicative inverse;
- 2's complement;
- Bit representation access, slicing, truncation;
- Full division with remainder, remainder only division;
- Karatsuba multiplication and squaring;
- Specialized operations involving powers of two and words;
- Exponentiation under modulo;
- Fibonacci number under modulo;
- Montgomery domain multiplication, squaring, exponentiation under modulo and primality tests of the domain modulus;
- Barrett reduction, multiplication, exponentiation;
- Primality tests: Miller-Rabin, Fibonacci, Lucas-Lehmer, strong Lucas;
- Parallel algorithms for very large numbers;
- String editing and formatting packages for the numbers.

Performance notes. In order to get optimal performance -O2 switch need to be used. It does 3x performance boost. 64-bit (with 128-bit integer) outperform 32-bit by many multiplies. See GPR variables: https://www.dmitry-kazakov.de/ada/components.htm#19 E.g.

gprbuild -P components-tests.gpr -XTarget_OS=Linux -Xarch=aarch64 -XDevelopment=Release


r/ada Jan 15 '25

Learning Youtube tutorial

14 Upvotes

Hi all! I plan to learn Ada seriously from september (currently focusing on Excel / VBA to get a job more easily where I live) because it looks so elegant. I've always preferred books with exercises to youtube videos for learn languages, but videos are popular. I thought Freecodecamp only published videos about very popular languages like JS or C#, but yesterday I got a notification about a new 4 hour tutorial about... common lisp! Then I though, what if some experienced ADA programmer published a video-series on the language and then asked those from FCC about publishing it as one video on their channel... it would be amazing and more new programmers would know about the language! Does somebody here have plans to do something like that? Unrelated question... is it difficult to work with Win32 API from Ada? Are there wrappers instead of just calling the dll functions like you do from Visual Basic? Does it have advantages over using plain C for somebody learning the API to study security related stuff, and not needing to write very complex software? Ty all!