comp.lang.ada
 help / color / mirror / Atom feed
From: Paul Rubin <no.email@nospam.invalid>
Subject: Re: Adacore joins with Ferrous Systems to support Rust
Date: Wed, 02 Feb 2022 20:22:24 -0800	[thread overview]
Message-ID: <87v8xwy3y7.fsf@nightsong.com> (raw)
In-Reply-To: stfg0v$1luk$1@gioia.aioe.org

"Luke A. Guest" <laguest@archeia.com> writes:
> You don't need to learn both languages inside and out. You pick a
> project and implement it in both languages,

Not realistic, as the saying is that it's possible to write Fortran in
any language.  What I want to see is proper idiomatic usage of both
languages as experts would write them.  Also, it seems to me that one of
Ada's big strengths is its modularity, e.g. the separation of
specification from implementation.  And that makes itself felt more with
large programs than small ones.  A beginner or tryout project wouldn't
exercise this.

> [Ada] Learn the basic part,

I think I have done that, but there is a heck of a lot more.

> [Haskell] So it's no different than a C++ compiler checking against
> classes or a variant of C with strong typing?

It is very different from either of those.

> Still no ranges, subranges, ranges with holes in, etc. This is where
> the power is.

No not really, especially since Ada doesn't enforce ranges with (static)
type checking, although it is sometimes possible in SPARK.  Range types
are a nice Ada feature but only "where the power is" if you haven't used
anything else ;).  Anyway, you can implement ranges (with runtime
checks) in C++ or Haskell with a bit of pain.

>> Example: a red-black tree using Haskell GADT's
> I don't know Haskell. Uni did a shit job at teaching functional, and
> logic languages.

Well are you familiar with red-black trees?  They are a data structure
similar to B-trees which you may have seen.  Basically the trees have
nodes that are coloured either red or black, and there are some rules
such as that internal red nodes can have only black children, and that
enforces some invariants that keep the trees balanced so that lookups
and updates are guaranteed to run fairly fast.

Now these trees have been implemented in many languages, and if you look
at almost any implementation, there is usually a test suite or internal
debugging code to make sure that the invariants are preserved after
doing an update.  It is quite easy to make a mistake after all.  But the
Haskell code doesn't have those tests.  Why not?  Because the invariants
are enforced by the datatype!  If you make a mistake and mess up an
invariant, your code won't compile!  It's the difference between
checking a subscript at runtime, and verifying that it in range with
SPARK.  SPARK lets you get rid of the runtime check.  Haskell's type
system is able to do similar things.

> 1. What do you want to do?

I have too many obligations and wannado projects to embark on anything
well suited for either Ada or Rust right now, unless someone is paying
me.  Also, I see Ada and Rust not really aiming at the same areas.  I
think of Ada as being more for control programs (they might compute a
lot, but tend not to make complex use of dynamic memory allocation)
while Rust is the opposite (handling dynamic allocation reliably is a
big part of the design motivation).

> 4. Ada is comparable to C++.
>   4a. Ada > C++ in many ways.

I don't see Ada and C++ as really comparable.  Ada > C++ in reliability
for sure, but C++ > Ada in convenience a lot of the time.

Particularly, a lot of effort in Ada programming goes into making
programs never crash.  For example, if the program runs out of memory
during operation it might crash, so Ada programs are often written to
never allocate new memory after a startup phase.  In C++ or Rust, it's
important not to get wrong answers like 2+2=5, but if your program runs
out of memory and crashes, go get a bigger computer.  So idiomatic C++
and Rust programming uses dynamic allocation freely, and that makes some
kinds of programming more convenient, at the expense of tolerating
possible crashes.

  reply	other threads:[~2022-02-03  4:22 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02  8:57 Adacore joins with Ferrous Systems to support Rust Paul Rubin
2022-02-02 13:04 ` Luke A. Guest
2022-02-02 15:29   ` Marius Amado-Alves
2022-02-02 16:36     ` Luke A. Guest
2022-02-04 17:51       ` Stephen Leake
2022-04-18 16:01       ` Rene
2022-02-02 20:07     ` G.B.
2022-02-03 23:29     ` John McCabe
2022-02-11 17:40     ` amo...@unizar.es
2022-02-11 19:24       ` Luke A. Guest
2022-02-12 17:34         ` Alejandro R. Mosteo
2022-02-12  5:22       ` John Perry
2022-02-12 10:08         ` Marius Amado-Alves
2022-02-12 18:24         ` Alejandro R. Mosteo
2022-02-13  8:10           ` J-P. Rosen
2022-02-14 23:25           ` Randy Brukardt
2022-02-15  4:29             ` Paul Rubin
2022-02-12 23:59         ` John Perry
2022-02-18 13:24     ` Kevin Chadwick
2022-02-02 20:06   ` Paul Rubin
2022-02-03  1:34     ` Luke A. Guest
2022-02-03  2:20       ` Paul Rubin
2022-02-03  2:52         ` Luke A. Guest
2022-02-03  4:22           ` Paul Rubin [this message]
2022-02-03  9:54             ` Björn Lundin
2022-02-04  3:38             ` Randy Brukardt
2022-02-04  5:19               ` Paul Rubin
2022-02-03 11:30           ` Simon Wright
2022-02-03 12:51             ` Luke A. Guest
2022-02-04  3:20               ` Randy Brukardt
2022-02-04 10:28                 ` Luke A. Guest
2022-02-04 17:51                   ` Andreas ZEURCHER
2022-02-05  4:31                   ` Randy Brukardt
2022-02-02 16:19 ` Stephen Leake
2022-02-02 18:48 ` Gautier write-only address
2022-02-02 20:03   ` Paul Rubin
2022-02-02 20:45     ` Dennis Lee Bieber
2022-02-12  4:42 ` 25.BZ943
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox