HN user

glacia01

22 karma
Posts0
Comments15
View on HN
No posts found.

See this fascinating article about Western CNCs used in the production of Iskander missiles

Pretty much all Russian factories run on US/Europe equipment. It's not really a secret, not sure what's surprising about that.

Think also secondary sanctions, i.e. sanctions against countries and organizations that help circumvent sanctions. For example, companies in, say, China or Uzbekistan profiteer by selling to Russian companies components bought from the West. Let’s make them face a dilemma: if you do business with Russia or NK you will be cut off from the West.

You'll have to sanction dozen of countries then. It's not really practical.

If west really wants to deal a blow to Russia then they need to make oil super cheap somehow, that would stop Russia really fast. Unfortunately that will never happen too...

But the thing is, we're talking embedded here. Most ucontrollers I use have 8b address space, no MMU or any form of virtual memory, separated instruction/data bus (MVHA). That kind of thing don't play well with funky fat pointers.

You can definitely use Ada on 8bit microcontrollers, for example on 8bit AVR: https://docs.adacore.com/gnat_ugx-docs/html/gnat_ugx/gnat_ug...

You can make runtime as small as you want.

As for exceptions and threads: I mentioned them because thats what comes to mind first, there are more benefits obviously.

I know berating C is trendy, but it feels a bit gratuitous and uncalled for in your comment...

Sorry about that, English is not my first language so i might sound rude sometimes. I actually dont hate C, but if you used it you know its flaws. I think stuff i mentioned about C is objectively bad, hence why i called them dumb stuff.

Not sure I would like fat pointers, exceptions and threads in my embedded code though

Fat pointers are just pointer + size of an object. You have to pass array size anyway, so its just convenient. Obviously, if you need to just pass a pointer there are ways to do that.

As for exceptions and threads: As i said, you can disable or modify them just by using Restrictions pragma. Its a language defined thing. For example, Ada 2022 defines two profiles for safety-critical hard real-time computing:

https://en.wikipedia.org/wiki/Ravenscar_profile http://www.ada-auth.org/standards/22rm/html/rm-d-13.html

It does have Rust like borrowing in SPARK subset of the language.

There was attempt to have it in Ada 2022 Standard, but it came late. Committee decided it's best not to rush and let compiler vendors implement how they think is best and go from there.

It’s safer than C, but I’m not quite sure where recent specs line up against C++.

Ada allows to return objects of variable size, so it's not that common that you actually need to explicitly allocate stuff. The general guideline for dynamic memory allocation is:

1) Use Second stack (this is how Ada allows to return object of variable size) 2) If cant use containers 3) If cant use controlled types (RAII) 4) Only then use New.

There are a lot of aspects where Ada is better than C. Just a few things that came to mind:

General lack of dumb C stuff like switch fallthrough, null terminated strings (Arrays in Ada are passed with fat pointers), undefined behavior, no need for memcpy, no preprocessor bullshit etc.

Ada is more like C++ in functionality so it has Generics, Tasks (Threads), Exceptions, Packages, Strong types, Design by contract etc (All much much saner than C++ stuff)

Despite all of the features it's very embedded friendly. Language allows you to disable features you dont wont with Restrictions Pragma (Very long list of restrictions you can apply: https://docs.adacore.com/gnat_rm-docs/html/gnat_rm/gnat_rm/s...). You can also fairly easily change runtimes: https://docs.adacore.com/gnat_ugx-docs/html/gnat_ugx/gnat_ug....

Just look at the performance costs of bounds-checking array access in C++ code.

If your compiler can prove you dont need bounds-checking it will remove the check and the performance would be the same. Hence, if your program has been proven to have no runtime errors you dont need them.

Just for context, people asked for C "+=" type of assignment since Ada 83. Target Name Symbol solves that. Note that Target Name Symbol is actually more useful than C "+=", since you can do stuff like

My_Data (To_Index (1)) := @ * 2 - 3.0 * @;