comp.lang.ada
 help / color / Atom feed
* Beginning Ada Programming, by Andrew T. Shvets (2020)
@ 2019-12-03  4:05 Paul Rubin
  2019-12-03 12:11 ` AdaMagica
                   ` (2 more replies)
  0 siblings, 3 replies; 76+ messages in thread
From: Paul Rubin @ 2019-12-03  4:05 UTC (permalink / raw)


This is not out yet, but it looks interesting and is due at the end of
the month:

  https://www.springer.com/us/book/9781484254271

Is the author the same Andrew Shvets who posts here sometimes?

Andrew if you're here, what does the book cover in terms of e.g. new Ada
features, SPARK, etc.?

It's great that new books are coming out about Ada.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03  4:05 Beginning Ada Programming, by Andrew T. Shvets (2020) Paul Rubin
@ 2019-12-03 12:11 ` AdaMagica
  2019-12-03 12:33   ` Lucretia
  2020-04-17  4:04   ` Andrew Shvets
  2019-12-10  5:17 ` Jerry
  2020-04-17  3:58 ` Andrew Shvets
  2 siblings, 2 replies; 76+ messages in thread
From: AdaMagica @ 2019-12-03 12:11 UTC (permalink / raw)


Am Dienstag, 3. Dezember 2019 05:05:27 UTC+1 schrieb Paul Rubin:
> This is not out yet, but it looks interesting and is due at the end of
> the month:
> 
>   https://www.springer.com/us/book/9781484254271
> 
> Is the author the same Andrew Shvets who posts here sometimes?

Yes, he is. I had a little conversation on the very first edition with him.
I esp. objected that he started his examples with using Integer rather than user-defined types (which IMHO is the very heart of Ada). I do not know whether he changed this.

The very first exercise in my basic Ada course was to find a type definition for a given problem: What is the range of values you expect to need? Just using Integer here is like cheating - i.e. refusal to think about the problem.

> Andrew if you're here, what does the book cover in terms of e.g. new Ada
> features, SPARK, etc.?
> 
> It's great that new books are coming out about Ada.

Anyway, it's favorable that there is another Ada book out there now that is up to date.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 12:11 ` AdaMagica
@ 2019-12-03 12:33   ` Lucretia
  2019-12-03 13:21     ` J-P. Rosen
  2020-04-17  4:04   ` Andrew Shvets
  1 sibling, 1 reply; 76+ messages in thread
From: Lucretia @ 2019-12-03 12:33 UTC (permalink / raw)


On Tuesday, 3 December 2019 12:11:11 UTC, AdaMagica  wrote:
> Am Dienstag, 3. Dezember 2019 05:05:27 UTC+1 schrieb Paul Rubin:
> > This is not out yet, but it looks interesting and is due at the end of
> > the month:
> > 
> >   https://www.springer.com/us/book/9781484254271
> > 
> > Is the author the same Andrew Shvets who posts here sometimes?
> 
> Yes, he is. I had a little conversation on the very first edition with him.
> I esp. objected that he started his examples with using Integer rather than user-defined types (which IMHO is the very heart of Ada). I do not know whether he changed this.

There's nothing wrong with using integer to start off and then moving onto defined types.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 12:33   ` Lucretia
@ 2019-12-03 13:21     ` J-P. Rosen
  2019-12-03 13:57       ` Lucretia
                         ` (2 more replies)
  0 siblings, 3 replies; 76+ messages in thread
From: J-P. Rosen @ 2019-12-03 13:21 UTC (permalink / raw)


Le 03/12/2019 à 13:33, Lucretia a écrit :
>> Yes, he is. I had a little conversation on the very first edition
>> with him. I esp. objected that he started his examples with using
>> Integer rather than user-defined types (which IMHO is the very
>> heart of Ada). I do not know whether he changed this.

> There's nothing wrong with using integer to start off and then moving
> onto defined types.
Yes there is! (see my paper at the last Ada-Europe). The first message
when you teach Ada is that it is all about defining proper types. You
have to start by fighting bad habits from other languages.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 13:21     ` J-P. Rosen
@ 2019-12-03 13:57       ` Lucretia
  2019-12-03 14:04         ` AdaMagica
  2020-04-17  4:08         ` Andrew Shvets
  2019-12-03 19:14       ` Paul Rubin
  2020-04-17  4:07       ` Andrew Shvets
  2 siblings, 2 replies; 76+ messages in thread
From: Lucretia @ 2019-12-03 13:57 UTC (permalink / raw)


On Tuesday, 3 December 2019 13:21:25 UTC, J-P. Rosen  wrote:
> Le 03/12/2019 à 13:33, Lucretia a écrit :
> >> Yes, he is. I had a little conversation on the very first edition
> >> with him. I esp. objected that he started his examples with using
> >> Integer rather than user-defined types (which IMHO is the very
> >> heart of Ada). I do not know whether he changed this.
> 
> > There's nothing wrong with using integer to start off and then moving
> > onto defined types.
> Yes there is! (see my paper at the last Ada-Europe). The first message
> when you teach Ada is that it is all about defining proper types. You
> have to start by fighting bad habits from other languages.

People coming from other languages might not grasp types easily, so start them off with an integer type and show them the range of it, then natural and positive explaining how they are defined and their ranges. Then drop them into their own types.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 13:57       ` Lucretia
@ 2019-12-03 14:04         ` AdaMagica
  2019-12-03 14:15           ` AdaMagica
                             ` (2 more replies)
  2020-04-17  4:08         ` Andrew Shvets
  1 sibling, 3 replies; 76+ messages in thread
From: AdaMagica @ 2019-12-03 14:04 UTC (permalink / raw)


Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> People coming from other languages might not grasp types easily,

Hey, what's difficult to understand in

type Temperature is range -40 .. 40;  -- Celsius

for a home thermometer?


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 14:04         ` AdaMagica
@ 2019-12-03 14:15           ` AdaMagica
  2019-12-03 14:39             ` Simon Wright
  2019-12-03 15:04           ` Lucretia
  2020-04-17  4:10           ` Andrew Shvets
  2 siblings, 1 reply; 76+ messages in thread
From: AdaMagica @ 2019-12-03 14:15 UTC (permalink / raw)


Define a type for values you can read from a foldable meter rod (0 to 2 m).

type Length is digits  4   range 0.0 .. 2.000;  -- Meter
type Length is delta 0.001 range 0.0 .. 2.000;

A meter rod allows one millimeter as maximal precision:
Floating point or fixed point number.

What's difficult to grasp here?


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 14:15           ` AdaMagica
@ 2019-12-03 14:39             ` Simon Wright
  2019-12-03 14:45               ` Shark8
  2019-12-03 17:38               ` J-P. Rosen
  0 siblings, 2 replies; 76+ messages in thread
From: Simon Wright @ 2019-12-03 14:39 UTC (permalink / raw)


AdaMagica <[email protected]> writes:

> Define a type for values you can read from a foldable meter rod (0 to
> 2 m).
>
> type Length is digits  4   range 0.0 .. 2.000;  -- Meter
> type Length is delta 0.001 range 0.0 .. 2.000;
>
> A meter rod allows one millimeter as maximal precision:
> Floating point or fixed point number.
>
> What's difficult to grasp here?

I think what's difficult to grasp is the need for such a type. Nothing
wrong with

   float len;

or, for the more enlightened,

   typedef float length;
   ...
   length len;

:-) :-)

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 14:39             ` Simon Wright
@ 2019-12-03 14:45               ` Shark8
  2019-12-03 17:38               ` J-P. Rosen
  1 sibling, 0 replies; 76+ messages in thread
From: Shark8 @ 2019-12-03 14:45 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 7:39:23 AM UTC-7, Simon Wright wrote:
> AdaMagica writes:
> 
> > Define a type for values you can read from a foldable meter rod (0 to
> > 2 m).
> >
> > type Length is digits  4   range 0.0 .. 2.000;  -- Meter
> > type Length is delta 0.001 range 0.0 .. 2.000;
> >
> > A meter rod allows one millimeter as maximal precision:
> > Floating point or fixed point number.
> >
> > What's difficult to grasp here?
> 
> I think what's difficult to grasp is the need for such a type. Nothing
> wrong with
> 
>    float len;
> 
> or, for the more enlightened,
> 
>    typedef float length;
>    ...
>    length len;
> 
> :-) :-)

On that note, I think we should propose "statistical types" -- the underlying bit pattern will be treated as floating- or fixed-point or BCD according to some statistical probability:

There's a 40% chance you're using floating-point this run, a 40% chance it's fixed-point, and a 20% chance it's BCD!
Good luck debugging!
there's a 


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 14:04         ` AdaMagica
  2019-12-03 14:15           ` AdaMagica
@ 2019-12-03 15:04           ` Lucretia
  2019-12-03 15:29             ` Optikos
  2020-04-17  4:11             ` Andrew Shvets
  2020-04-17  4:10           ` Andrew Shvets
  2 siblings, 2 replies; 76+ messages in thread
From: Lucretia @ 2019-12-03 15:04 UTC (permalink / raw)


On Tuesday, 3 December 2019 14:04:24 UTC, AdaMagica  wrote:
> Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> > People coming from other languages might not grasp types easily,
> 
> Hey, what's difficult to understand in
> 
> type Temperature is range -40 .. 40;  -- Celsius
> 
> for a home thermometer?

I don't have a problem, I get it, I'm saying that apparently other people do. But still, there's nothing wrong with just starting with pre-defined types, they're there for a reason. Jesus!

Luke.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 15:04           ` Lucretia
@ 2019-12-03 15:29             ` Optikos
  2019-12-03 16:06               ` Lucretia
                                 ` (2 more replies)
  2020-04-17  4:11             ` Andrew Shvets
  1 sibling, 3 replies; 76+ messages in thread
From: Optikos @ 2019-12-03 15:29 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 9:04:13 AM UTC-6, Lucretia wrote:
> On Tuesday, 3 December 2019 14:04:24 UTC, AdaMagica  wrote:
> > Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> > > People coming from other languages might not grasp types easily,
> > 
> > Hey, what's difficult to understand in
> > 
> > type Temperature is range -40 .. 40;  -- Celsius
> > 
> > for a home thermometer?
> 
> I don't have a problem, I get it, I'm saying that apparently other people do. But still, there's nothing
> wrong with just starting with pre-defined types, they're there for a reason. Jesus!

There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying.

strict) AdaMagica appears to be saying that rock-solid analysis of finding the upper & lower bounds of the integer's range (or fixed or floating point or BCD for that matter) is of crucial insight & importance to understanding the problem.

loose) You appear to be saying that for rapid prototyping that that deep analysis can be postponed.

midling) The middle ground is to use a named type* of a predefined** (not range-restricted subtype of) predefined type that represents the problem domain's meaning.  Then at a (perhaps much) later time restrict the range of that named type only at the single point of declaration in the package specification, which then takes effect at all points of usage of that named type in other declarations and in the package body without modifying all those points of usage to refer to a different name(d type).

* the same named type in midling as in strict)

**  the same unsubtyped predefined type as in loose)

Midling hence achieves loose's rapid prototyping and strict's ease of deploying the most-correct subtype restricted range—hence the wisdom.  (Perhaps midling is actually what either or both AdaMagica & Lucretia speakers were actually intending to say more tersely, but perhaps some readers were missing these finer points in the terseness.)


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 15:29             ` Optikos
@ 2019-12-03 16:06               ` Lucretia
  2019-12-03 16:26                 ` Optikos
  2019-12-03 20:40               ` Björn Lundin
  2020-04-17  4:16               ` Andrew Shvets
  2 siblings, 1 reply; 76+ messages in thread
From: Lucretia @ 2019-12-03 16:06 UTC (permalink / raw)


On Tuesday, 3 December 2019 15:29:15 UTC, Optikos  wrote:

> There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying.
> 
> strict) AdaMagica appears to be saying that rock-solid analysis of finding the upper & lower bounds of the integer's range (or fixed or floating point or BCD for that matter) is of crucial insight & importance to understanding the problem.
> 
> loose) You appear to be saying that for rapid prototyping that that deep analysis can be postponed.

That's not what I'm saying at all!

I'm saying to get someone used to the language, there is no problem with starting them off with the ready defined types, but explaining ranges a little later on, literally, within pages of themselves.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 16:06               ` Lucretia
@ 2019-12-03 16:26                 ` Optikos
  2019-12-03 16:50                   ` Lucretia
  2020-04-17  4:27                   ` Beginning Ada Programming, by Andrew T. Shvets (2020) Andrew Shvets
  0 siblings, 2 replies; 76+ messages in thread
From: Optikos @ 2019-12-03 16:26 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 10:06:58 AM UTC-6, Lucretia wrote:
> On Tuesday, 3 December 2019 15:29:15 UTC, Optikos  wrote:
> 
> > There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying.
> > 
> > strict) AdaMagica appears to be saying that rock-solid analysis of finding the upper & lower bounds of the integer's range (or fixed or floating point or BCD for that matter) is of crucial insight & importance to understanding the problem.
> > 
> > loose) You appear to be saying that for rapid prototyping that that deep analysis can be postponed.
> 
> That's not what I'm saying at all!
> 
> I'm saying to get someone used to the language, there is no problem with starting them off with the
> ready defined types, but explaining ranges a little later on, literally, within pages of themselves.

Oh, then I agree with AdaMagica wholeheartedly if restricted to only learning a new language.  I once worked for a long-time Fortran programmer who self-taught himself C; every line of code that he wrote was 110% pure Fortran-think without any resemblance (other than surface syntax) to anything more modern:  PL/I, C, Ada, Pascal.  Just about the only way that it was C code beyond force-fitting his thinking into C syntax minimally was that he eventually refrained from keeping the caps-lock key on all the time for all identifiers.  Full immersion in the new language's own better way of thinking from the very start is the only productive way to learn a new programming language.  Learning Ada the way that you describe is likely to perpetuate C-think or C++-think or Python-think in Ada, due to the new learner falsely believing “I got this!” far far too soon.

Learning a new programming language needs to have exciting revelatory “oh, wow!  I've never been able to do •that• before in any prior language!” moments early on to quell ho-hum boredom.  This ho-hum boredom is caused by nearly all the mainstream programming languages (with the exception of ML family) being minor variations on Algol 60's syntax and relatively minor extensions of Algol 60's control-flow constructs, so differentiating the newly-learned language from all other Algol60-esque fellow languages ASAP is crucial.  Burying the revelatory differences later in the book does a mind-numbing disservice to the reader by falsely lulling the reader into thinking Ada's key contributions are in syntax & beauty, not in semantic-meaning expressivity & crisp well-ordered-mind thinking.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 16:26                 ` Optikos
@ 2019-12-03 16:50                   ` Lucretia
  2019-12-03 17:02                     ` Shark8
  2019-12-03 17:39                     ` Optikos
  2020-04-17  4:27                   ` Beginning Ada Programming, by Andrew T. Shvets (2020) Andrew Shvets
  1 sibling, 2 replies; 76+ messages in thread
From: Lucretia @ 2019-12-03 16:50 UTC (permalink / raw)


On Tuesday, 3 December 2019 16:26:55 UTC, Optikos  wrote:

> > That's not what I'm saying at all!
> > 
> > I'm saying to get someone used to the language, there is no problem with starting them off with the
> > ready defined types, but explaining ranges a little later on, literally, within pages of themselves.
> 
> Oh, then I agree with AdaMagica wholeheartedly if restricted to only learning a new language.  I once worked for a long-time Fortran programmer who self-taught himself C; every line of code that he wrote was 110% pure Fortran-think without any resemblance (other than surface syntax) to anything more modern:  

...aaaaaaaaaaaaaaand you missed my point entirely. I said to introduce them to typing concepts after getting them used to the very basics, i.e. first few simple programs adding numbers and printing them out, how the build using the compiler, then handle types and explaining how they're different to something like typedef in C.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 16:50                   ` Lucretia
@ 2019-12-03 17:02                     ` Shark8
  2019-12-03 17:29                       ` AdaMagica
  2019-12-05 16:35                       ` Dirk Heinrichs
  2019-12-03 17:39                     ` Optikos
  1 sibling, 2 replies; 76+ messages in thread
From: Shark8 @ 2019-12-03 17:02 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 9:50:40 AM UTC-7, Lucretia wrote:
> 
> I said to introduce them to typing concepts after getting them used to the very basics, i.e. first few simple programs adding numbers and printing them out, how the build using the compiler, then handle types and explaining how they're different to something like typedef in C.

Perhaps the easiest way to do this is by doing something that's (e.g.) much more complex in C, but relatively straightforward in Ada -- perhaps modeling a Password in the software:

Type Digit      is Character Range '0'..'9';
Type Upper_Case is Character Range 'A'..'Z';
Type Lower_Case is Character Range 'a'..'z';
Type Symbol is Character
  with Static_Predicate => Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*';

Minimum_Length : Constant :=  8;
Maximum_Length : Constant := 32;

Type Password is new String
  with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length 
    and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol);

You can then explain what each of these are ans how they compose the type Password that is guaranteed by the type-system to have the modeled properties.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 17:02                     ` Shark8
@ 2019-12-03 17:29                       ` AdaMagica
  2019-12-05 16:35                       ` Dirk Heinrichs
  1 sibling, 0 replies; 76+ messages in thread
From: AdaMagica @ 2019-12-03 17:29 UTC (permalink / raw)


Thanks to all of you. I like it that you are discussing the very basics of thinking in Ada.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 14:39             ` Simon Wright
  2019-12-03 14:45               ` Shark8
@ 2019-12-03 17:38               ` J-P. Rosen
  1 sibling, 0 replies; 76+ messages in thread
From: J-P. Rosen @ 2019-12-03 17:38 UTC (permalink / raw)


Le 03/12/2019 à 15:39, Simon Wright a écrit :
> I think what's difficult to grasp is the need for such a type. Nothing
> wrong with
> 
>    float len;
> 
> or, for the more enlightened,
> 
>    typedef float length;
>    ...
>    length len;
That's exactly why it should be stressed right from the start that in
Ada, you differentiate between machine types and abstract types that
model the problem domain.

That's the difference between teaching the syntax and teaching the way
to use Ada.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 16:50                   ` Lucretia
  2019-12-03 17:02                     ` Shark8
@ 2019-12-03 17:39                     ` Optikos
  2019-12-03 19:12                       ` Paul Rubin
                                         ` (2 more replies)
  1 sibling, 3 replies; 76+ messages in thread
From: Optikos @ 2019-12-03 17:39 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 10:50:40 AM UTC-6, Lucretia wrote:
> On Tuesday, 3 December 2019 16:26:55 UTC, Optikos  wrote:
> 
> > > That's not what I'm saying at all!
> > > 
> > > I'm saying to get someone used to the language, there is no problem with starting them off with the
> > > ready defined types, but explaining ranges a little later on, literally, within pages of themselves.
> > 
> > Oh, then I agree with AdaMagica wholeheartedly if restricted to only learning a new language.  I once worked for a long-time Fortran programmer who self-taught himself C; every line of code that he wrote was 110% pure Fortran-think without any resemblance (other than surface syntax) to anything more modern:  
> 
> ...aaaaaaaaaaaaaaand you missed my point entirely. I said to introduce them to typing concepts after
> getting them used to the very basics, i.e. first few simple programs adding numbers and printing them
> out, how the build using the compiler, then handle types and explaining how they're different to
> something like typedef in C.

Although I don't have a copy of any of Andrew Shvets books to see how quickly he leaves the rudimentary level of hello-world dip-your-toe-in-the-water content, I took AdaMagica's criticism of the 1st edition as lingering far far far too long in the predefined hello-world dip-toe-in-water stage.

IMHO, the best pedagogical books always have a chapter 0 (after the Preface) that provides all the hello-world dip-toe-in-water rudimentary this-isn't-scary this-is-actually-accessible content, which would provide also the crash-course whirlwind-handwaving answer to the question of “gee, how do I actually minimally get this to compile on commonplace compilers and commonplace operating systems”.  But then Chapter 1 introduces the topic in the topic's native terms instead of as a play-baby toy.  Then back on say Chapter 11 every detail of the nuances of subtleties of how to make the build system sit up and sing for its supper can be introduced in their full glory, because it is so non-standard and vendor/OS dependent.

Paul Rubin, btw, I find Alan Burns's & Andy Wellings's 512-page _Analysable Real-Time Systems Programmed in Ada_ (2016; self-published) to be an exemplary book that truly shows off Ada's strong points in full Ada-think, but it is aimed at a different sector of the market than Schvet's introductory/general book, I suspect.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 17:39                     ` Optikos
@ 2019-12-03 19:12                       ` Paul Rubin
  2019-12-14  4:34                       ` Paul Rubin
  2020-04-17  5:14                       ` Andrew Shvets
  2 siblings, 0 replies; 76+ messages in thread
From: Paul Rubin @ 2019-12-03 19:12 UTC (permalink / raw)


Optikos <[email protected]> writes:
> Paul Rubin, btw, I find Alan Burns's & Andy Wellings's 512-page
> _Analysable Real-Time Systems Programmed in Ada_ (2016;
> self-published) to be an exemplary book that truly shows off Ada's
> strong points in full Ada-think, but it is aimed at a different sector
> of the market than Schvet's introductory/general book, I suspect.

Thanks, I'll look for Alan Burns and Andy Welling's book.  It sounds
like what I want.  I looked more carefully at the blurb for Andrew
Shvets' book, and it looks more introductory than what I was hoping for.
I felt that Ada 95 Distilled did a reasonable job of covering the
basics, but that even after reading it, I still can't follow much of the
discussion here on comp.lang.ada.  So I'm hoping for something that goes
deeper.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 13:21     ` J-P. Rosen
  2019-12-03 13:57       ` Lucretia
@ 2019-12-03 19:14       ` Paul Rubin
  2019-12-04  6:47         ` J-P. Rosen
  2019-12-04  6:49         ` J-P. Rosen
  2020-04-17  4:07       ` Andrew Shvets
  2 siblings, 2 replies; 76+ messages in thread
From: Paul Rubin @ 2019-12-03 19:14 UTC (permalink / raw)


"J-P. Rosen" <[email protected]> writes:
> Yes there is! (see my paper at the last Ada-Europe). The first message
> when you teach Ada is that it is all about defining proper types. You
> have to start by fighting bad habits from other languages.

Is your paper online?  I'm interested in seeing it.  I think Haskell is
even more type-intensive than Ada, but nobody has problems using
Haskell's ground types (e.g. Integer) when appropriate.  

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 15:29             ` Optikos
  2019-12-03 16:06               ` Lucretia
@ 2019-12-03 20:40               ` Björn Lundin
  2020-04-17  4:16               ` Andrew Shvets
  2 siblings, 0 replies; 76+ messages in thread
From: Björn Lundin @ 2019-12-03 20:40 UTC (permalink / raw)


Den 2019-12-03 kl. 16:29, skrev Optikos:
> 
> There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying.
> 
> midling) The middle ground is to use a named type* of a predefined** (not range-restricted subtype of) predefined type that represents the problem domain's meaning.  Then at a (perhaps much) later time restrict the range of that named type only at the single point of declaration in the package specification, which then takes effect at all points of usage of that named type in other declarations and in the package body without modifying all those points of usage to refer to a different name(d type).


Then you lost some/most advantages with declaring such a type, like 
looping over it, and get exceptions for data outside of the range.
To me, that is a major point. Without using the type, why not go for a 
predefined ?
You declare a type to use it as an integral part of your code
('range, 'first, 'last etc)
If you put on constraints in a (much) later time, you have won little,
you might as well put in asserts instead.


-- 
Björn

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 19:14       ` Paul Rubin
@ 2019-12-04  6:47         ` J-P. Rosen
  2019-12-04  6:49         ` J-P. Rosen
  1 sibling, 0 replies; 76+ messages in thread
From: J-P. Rosen @ 2019-12-04  6:47 UTC (permalink / raw)


Le 03/12/2019 à 20:14, Paul Rubin a écrit :
> "J-P. Rosen" <[email protected]> writes:
>> Yes there is! (see my paper at the last Ada-Europe). The first message
>> when you teach Ada is that it is all about defining proper types. You
>> have to start by fighting bad habits from other languages.
> 
> Is your paper online?  I'm interested in seeing it.  I think Haskell is
> even more type-intensive than Ada, but nobody has problems using
> Haskell's ground types (e.g. Integer) when appropriate.  
> 

It has been published (like any industrial paper) in the latest issue of
the Ada User Journal. It will appear online 4 issues from now (there
must be some benefit in becoming a member of Ada-Europe)!

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 19:14       ` Paul Rubin
  2019-12-04  6:47         ` J-P. Rosen
@ 2019-12-04  6:49         ` J-P. Rosen
  2019-12-04  9:46           ` Paul Rubin
  1 sibling, 1 reply; 76+ messages in thread
From: J-P. Rosen @ 2019-12-04  6:49 UTC (permalink / raw)


Le 03/12/2019 à 20:14, Paul Rubin a écrit :
> "J-P. Rosen" <[email protected]> writes:
>> Yes there is! (see my paper at the last Ada-Europe). The first message
>> when you teach Ada is that it is all about defining proper types. You
>> have to start by fighting bad habits from other languages.
> 
> Is your paper online?  I'm interested in seeing it.  I think Haskell is
> even more type-intensive than Ada, but nobody has problems using
> Haskell's ground types (e.g. Integer) when appropriate.  
> 
PS: send me your email privately, and I'll send it to you.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-04  6:49         ` J-P. Rosen
@ 2019-12-04  9:46           ` Paul Rubin
  0 siblings, 0 replies; 76+ messages in thread
From: Paul Rubin @ 2019-12-04  9:46 UTC (permalink / raw)


"J-P. Rosen" <[email protected]> writes:
> PS: send me your email privately, and I'll send it to you.

Sent, thanks!

Paul

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 17:02                     ` Shark8
  2019-12-03 17:29                       ` AdaMagica
@ 2019-12-05 16:35                       ` Dirk Heinrichs
  2019-12-05 17:12                         ` AdaMagica
  2019-12-06 18:34                         ` Shark8
  1 sibling, 2 replies; 76+ messages in thread
From: Dirk Heinrichs @ 2019-12-05 16:35 UTC (permalink / raw)


Am 03.12.19 um 18:02 schrieb Shark8:

> Perhaps the easiest way to do this is by doing something that's (e.g.) much more complex in C, but relatively straightforward in Ada -- perhaps modeling a Password in the software:
> 
> Type Digit      is Character Range '0'..'9';
> Type Upper_Case is Character Range 'A'..'Z';
> Type Lower_Case is Character Range 'a'..'z';
> Type Symbol is Character
>    with Static_Predicate => Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*';
> 
> Minimum_Length : Constant :=  8;
> Maximum_Length : Constant := 32;
> 
> Type Password is new String
>    with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
>      and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol);

That's a really nice one. How would the predicate look like if the PW 
was to start with a lowercase character?

Bye...

	Dirk
-- 
Dirk Heinrichs <[email protected]>
GPG Public Key: D01B367761B0F7CE6E6D81AAD5A2E54246986015
Sichere Internetkommunikation: http://www.retroshare.org
Privacy Handbuch: https://www.privacy-handbuch.de


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-05 16:35                       ` Dirk Heinrichs
@ 2019-12-05 17:12                         ` AdaMagica
  2019-12-09 19:08                           ` Dirk Heinrichs
  2019-12-06 18:34                         ` Shark8
  1 sibling, 1 reply; 76+ messages in thread
From: AdaMagica @ 2019-12-05 17:12 UTC (permalink / raw)


Am Donnerstag, 5. Dezember 2019 17:36:00 UTC+1 schrieb Dirk Heinrichs:
> > Type Password is new String
> >    with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
         and Password (Password'First) in Lower_Case
> >      and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol);
> 
> That's a really nice one. How would the predicate look like if the PW 
> was to start with a lowercase character?

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-05 16:35                       ` Dirk Heinrichs
  2019-12-05 17:12                         ` AdaMagica
@ 2019-12-06 18:34                         ` Shark8
  2019-12-06 20:29                           ` Jeffrey R. Carter
  2019-12-14  4:21                           ` Keith Thompson
  1 sibling, 2 replies; 76+ messages in thread
From: Shark8 @ 2019-12-06 18:34 UTC (permalink / raw)


On Thursday, December 5, 2019 at 9:36:00 AM UTC-7, Dirk Heinrichs wrote:
> Am 03.12.19 um 18:02 schrieb Shark8:
> 
> > Perhaps the easiest way to do this is by doing something that's (e.g.) much more complex in C, but relatively straightforward in Ada -- perhaps modeling a Password in the software:
> > 
> > Type Digit      is Character Range '0'..'9';
> > Type Upper_Case is Character Range 'A'..'Z';
> > Type Lower_Case is Character Range 'a'..'z';
> > Type Symbol is Character
> >    with Static_Predicate => Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*';
> > 
> > Minimum_Length : Constant :=  8;
> > Maximum_Length : Constant := 32;
> > 
> > Type Password is new String
> >    with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
> >      and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol)
> >      and Password(Password'First) Lower_Case;
> 
> That's a really nice one. How would the predicate look like if the PW 
> was to start with a lowercase character?
See the modification.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-06 18:34                         ` Shark8
@ 2019-12-06 20:29                           ` Jeffrey R. Carter
  2019-12-06 21:05                             ` Shark8
  2019-12-14  4:21                           ` Keith Thompson
  1 sibling, 1 reply; 76+ messages in thread
From: Jeffrey R. Carter @ 2019-12-06 20:29 UTC (permalink / raw)


On 12/6/19 7:34 PM, Shark8 wrote:
>>>
>>> Type Password is new String
>>>     with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
>>>       and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol)
>>>       and Password(Password'First) Lower_Case;

It looks like you left out an "in".

I bet the coders among us are having heart attacks about the "inefficiency" of 
checking the first character twice. I'd be interested in hearing from compiler 
writers whether their optimizers would optimize that.

-- 
Jeff Carter
"Brave Sir Robin ran away."
Monty Python and the Holy Grail
59


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-06 20:29                           ` Jeffrey R. Carter
@ 2019-12-06 21:05                             ` Shark8
  2019-12-07  0:47                               ` Randy Brukardt
  0 siblings, 1 reply; 76+ messages in thread
From: Shark8 @ 2019-12-06 21:05 UTC (permalink / raw)


On Friday, December 6, 2019 at 1:29:57 PM UTC-7, Jeffrey R. Carter wrote:
> On 12/6/19 7:34 PM, Shark8 wrote:
> >>>
> >>> Type Password is new String
> >>>     with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
> >>>       and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol)
> >>>       and Password(Password'First) Lower_Case;
> 
> It looks like you left out an "in".
> 
> I bet the coders among us are having heart attacks about the "inefficiency" of 
> checking the first character twice. I'd be interested in hearing from compiler 
> writers whether their optimizers would optimize that.
Why?
Seriously, why worry about inefficiency at this level? Almost all your observable problems are going to be algorithmic, and attaching assertions to a type allows for optimizations.

Example:
Function Copy( Object : Password ) return Password is (Object);
We know that passing in parameter object, the item must be conformant to Password [checked on call) and so can copy and pass out the Password without checking its validity... MORE, given a variable X --X : Password:= Create_Password("ThisPassword#1!")-- we know that X must conform to the definition, so then Y : Password:= Copy( X ); needn't make any check at all.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-06 21:05                             ` Shark8
@ 2019-12-07  0:47                               ` Randy Brukardt
  0 siblings, 0 replies; 76+ messages in thread
From: Randy Brukardt @ 2019-12-07  0:47 UTC (permalink / raw)


"Shark8" <[email protected]> wrote in message 
news:[email protected]
...
>Example:
>Function Copy( Object : Password ) return Password is (Object);
>We know that passing in parameter object, the item must be conformant to
>Password [checked on call) and so can copy and pass out the Password
>without checking its validity... MORE, given a variable X --X :
>Password:= Create_Password("ThisPassword#1!")-- we know that X must
>conform to the definition, so then Y : Password:= Copy( X ); needn't make
>any check at all.

Such an optimization is not true in the most general case, since the 
predicate might have a side effect or have its result changed by some side 
effect of another operation. In this case, of course, it could be done. 
There's a rule that implies that predicates (and other assertions) that 
change values when only assertion expressions are being evaluated can be 
rejected (and thus aren't portable), but that does not apply if some other 
operation occurs in between the evaluations (such as the call to Copy here).

                                  Randy.


                                       Randy.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-05 17:12                         ` AdaMagica
@ 2019-12-09 19:08                           ` Dirk Heinrichs
  0 siblings, 0 replies; 76+ messages in thread
From: Dirk Heinrichs @ 2019-12-09 19:08 UTC (permalink / raw)


Am 05.12.19 um 18:12 schrieb AdaMagica:

> Am Donnerstag, 5. Dezember 2019 17:36:00 UTC+1 schrieb Dirk Heinrichs:
>>> Type Password is new String
>>>     with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
>           and Password (Password'First) in Lower_Case
>>>       and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol);
>>
>> That's a really nice one. How would the predicate look like if the PW
>> was to start with a lowercase character?

Thanks a lot...

	Dirk
-- 
Dirk Heinrichs <[email protected]>
GPG Public Key: D01B367761B0F7CE6E6D81AAD5A2E54246986015
Sichere Internetkommunikation: http://www.retroshare.org
Privacy Handbuch: https://www.privacy-handbuch.de


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03  4:05 Beginning Ada Programming, by Andrew T. Shvets (2020) Paul Rubin
  2019-12-03 12:11 ` AdaMagica
@ 2019-12-10  5:17 ` Jerry
  2020-04-17  3:58 ` Andrew Shvets
  2 siblings, 0 replies; 76+ messages in thread
From: Jerry @ 2019-12-10  5:17 UTC (permalink / raw)


Except for the title, this looks like the same book I bought about a year ago, "Introduction to Ada Programming, 2nd edition, apparently self-published.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-06 18:34                         ` Shark8
  2019-12-06 20:29                           ` Jeffrey R. Carter
@ 2019-12-14  4:21                           ` Keith Thompson
  2019-12-14 11:34                             ` AdaMagica
  1 sibling, 1 reply; 76+ messages in thread
From: Keith Thompson @ 2019-12-14  4:21 UTC (permalink / raw)


Shark8 <[email protected]> writes:
> On Thursday, December 5, 2019 at 9:36:00 AM UTC-7, Dirk Heinrichs wrote:
>> Am 03.12.19 um 18:02 schrieb Shark8:
>> 
>> > Perhaps the easiest way to do this is by doing something that's
>> > (e.g.) much more complex in C, but relatively straightforward in
>> > Ada -- perhaps modeling a Password in the software:
>> > 
>> > Type Digit      is Character Range '0'..'9';
>> > Type Upper_Case is Character Range 'A'..'Z';
>> > Type Lower_Case is Character Range 'a'..'z';
>> > Type Symbol is Character
>> >    with Static_Predicate => Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*';
>> > 
>> > Minimum_Length : Constant :=  8;
>> > Maximum_Length : Constant := 32;
>> > 
>> > Type Password is new String
>> >    with Dynamic_Predicate => Password'Length in Minimum_Length..Maximum_Length
>> >      and (For all C of Password => C in Digit|Upper_Case|Lower_Case|Symbol)
>> >      and Password(Password'First) Lower_Case;
>> 
>> That's a really nice one. How would the predicate look like if the PW 
>> was to start with a lowercase character?
> See the modification.

Don't those 4 types need to be subtypes?

-- 
Keith Thompson (The_Other_Keith) [email protected]
    [Note updated email address]
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 17:39                     ` Optikos
  2019-12-03 19:12                       ` Paul Rubin
@ 2019-12-14  4:34                       ` Paul Rubin
  2020-04-17  5:14                       ` Andrew Shvets
  2 siblings, 0 replies; 76+ messages in thread
From: Paul Rubin @ 2019-12-14  4:34 UTC (permalink / raw)


Optikos <[email protected]> writes:
> Paul Rubin, btw, I find Alan Burns's & Andy Wellings's 512-page
> _Analysable Real-Time Systems Programmed in Ada_ 

This appears to be mostly about realtime programming in general, and is
based on an earlier book by the same authors that used Java.  I don't
get the impression it goes much into the details of Ada.  But it looks
like a good book anyway, so I've ordered it.  Thanks for the rec.


^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-14  4:21                           ` Keith Thompson
@ 2019-12-14 11:34                             ` AdaMagica
  0 siblings, 0 replies; 76+ messages in thread
From: AdaMagica @ 2019-12-14 11:34 UTC (permalink / raw)


Am Samstag, 14. Dezember 2019 05:21:55 UTC+1 schrieb Keith Thompson:

> >> > Type Digit      is Character Range '0'..'9';
> >> > Type Upper_Case is Character Range 'A'..'Z';
> >> > Type Lower_Case is Character Range 'a'..'z';
> >> > Type Symbol is Character
> >> >    with Static_Predicate => Symbol in '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*';

> Don't those 4 types need to be subtypes?

Of course all these four should be subtypes.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03  4:05 Beginning Ada Programming, by Andrew T. Shvets (2020) Paul Rubin
  2019-12-03 12:11 ` AdaMagica
  2019-12-10  5:17 ` Jerry
@ 2020-04-17  3:58 ` Andrew Shvets
  2020-05-09 12:39   ` Chris Collings
  2 siblings, 1 reply; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  3:58 UTC (permalink / raw)


On Monday, December 2, 2019 at 11:05:27 PM UTC-5, Paul Rubin wrote:
> This is not out yet, but it looks interesting and is due at the end of
> the month:
> 
>   https://www.springer.com/us/book/9781484254271
> 
> Is the author the same Andrew Shvets who posts here sometimes?
> 
> Andrew if you're here, what does the book cover in terms of e.g. new Ada
> features, SPARK, etc.?
> 
> It's great that new books are coming out about Ada.

Hi,

I just stumbled across this thread (I haven't been here a while).  Hence the very late reply.

The book is pretty much the same as my "Introduction to Ada Programming".  The one key advantage in the Apress version is that the Index is much much much better now.  Also, I feel like that the formatting is vastly improved than what it was before.

Lastly, by going with Apress, it improves the status and visibility of Ada.  It's no longer the language of someone that programmed when Reagan was president.  It gives it a new feel of vitality and drives home the point that Ada is not "dead".

I'm under contract with Apress for a 2nd edition for this book.  That one will have much more information (such as a chapter on making GUIs).  I'm still working on that one.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 12:11 ` AdaMagica
  2019-12-03 12:33   ` Lucretia
@ 2020-04-17  4:04   ` Andrew Shvets
  1 sibling, 0 replies; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:04 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 7:11:11 AM UTC-5, AdaMagica wrote:
> Am Dienstag, 3. Dezember 2019 05:05:27 UTC+1 schrieb Paul Rubin:
> > This is not out yet, but it looks interesting and is due at the end of
> > the month:
> > 
> >   https://www.springer.com/us/book/9781484254271
> > 
> > Is the author the same Andrew Shvets who posts here sometimes?
> 
> Yes, he is. I had a little conversation on the very first edition with him.
> I esp. objected that he started his examples with using Integer rather than user-defined types (which IMHO is the very heart of Ada). I do not know whether he changed this.

You have to understand something from the perspective of a newbie.  If you're new to Ada, heard all the wonderful things about it and then get started... most of the time you get stuck in a long chapter about types that go down the rabbit hole of explaining the entire type system of Ada right away.

Don't get me wrong, this is a core strength of Ada and it's absolutely awesome.  However, when you're just starting out, it can be daunting, frustrating and discouraging.  It was for me.

My personal take on this was to ease the reader into the subject.  I wanted to give an overhead of how powerful types are in Ada, but not dump the reader at the deep end of the pool.  As a result, I had a chapter on the basic types and then moved on to control structures, methods, OOP, etc.  Later on, I went back and revisited this topic.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 13:21     ` J-P. Rosen
  2019-12-03 13:57       ` Lucretia
  2019-12-03 19:14       ` Paul Rubin
@ 2020-04-17  4:07       ` Andrew Shvets
  2020-04-17  5:49         ` J-P. Rosen
  2020-04-17 17:59         ` AdaMagica
  2 siblings, 2 replies; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:07 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 8:21:25 AM UTC-5, J-P. Rosen wrote:
> Le 03/12/2019 à 13:33, Lucretia a écrit :
> >> Yes, he is. I had a little conversation on the very first edition
> >> with him. I esp. objected that he started his examples with using
> >> Integer rather than user-defined types (which IMHO is the very
> >> heart of Ada). I do not know whether he changed this.
> 
> > There's nothing wrong with using integer to start off and then moving
> > onto defined types.
> Yes there is! (see my paper at the last Ada-Europe). The first message
> when you teach Ada is that it is all about defining proper types. You
> have to start by fighting bad habits from other languages.
> 
> -- 
> J-P. Rosen
> Adalog
> 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> http://www.adalog.fr

*shrug* You have your own way of looking at this.  However, I really did not want to leave someone that is just starting with a long and academic chapter on types in Ada.  It would be boring and discourage someone from learning Ada.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 13:57       ` Lucretia
  2019-12-03 14:04         ` AdaMagica
@ 2020-04-17  4:08         ` Andrew Shvets
  1 sibling, 0 replies; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:08 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 8:57:53 AM UTC-5, Lucretia wrote:
> On Tuesday, 3 December 2019 13:21:25 UTC, J-P. Rosen  wrote:
> > Le 03/12/2019 à 13:33, Lucretia a écrit :
> > >> Yes, he is. I had a little conversation on the very first edition
> > >> with him. I esp. objected that he started his examples with using
> > >> Integer rather than user-defined types (which IMHO is the very
> > >> heart of Ada). I do not know whether he changed this.
> > 
> > > There's nothing wrong with using integer to start off and then moving
> > > onto defined types.
> > Yes there is! (see my paper at the last Ada-Europe). The first message
> > when you teach Ada is that it is all about defining proper types. You
> > have to start by fighting bad habits from other languages.
> 
> People coming from other languages might not grasp types easily, so start them off with an integer type and show them the range of it, then natural and positive explaining how they are defined and their ranges. Then drop them into their own types.

That was my main motivation.  It would be needlessly painful for someone just starting out.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 14:04         ` AdaMagica
  2019-12-03 14:15           ` AdaMagica
  2019-12-03 15:04           ` Lucretia
@ 2020-04-17  4:10           ` Andrew Shvets
  2020-04-17  5:02             ` Andrew Shvets
  2 siblings, 1 reply; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:10 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 9:04:24 AM UTC-5, AdaMagica wrote:
> Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> > People coming from other languages might not grasp types easily,
> 
> Hey, what's difficult to understand in
> 
> type Temperature is range -40 .. 40;  -- Celsius
> 
> for a home thermometer?

That's not fair, now is it?  You and I know full well what that means.  But drop someone who has done C/C++/Java/Python into the same situation and it's a sure-fire way of having that person give up and declare that Ada is "too hard" or use some other excuse.

What does that accomplish?

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 15:04           ` Lucretia
  2019-12-03 15:29             ` Optikos
@ 2020-04-17  4:11             ` Andrew Shvets
  2020-04-17 15:32               ` Luke A. Guest
  1 sibling, 1 reply; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:11 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 10:04:13 AM UTC-5, Lucretia wrote:
> On Tuesday, 3 December 2019 14:04:24 UTC, AdaMagica  wrote:
> > Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> > > People coming from other languages might not grasp types easily,
> > 
> > Hey, what's difficult to understand in
> > 
> > type Temperature is range -40 .. 40;  -- Celsius
> > 
> > for a home thermometer?
> 
> I don't have a problem, I get it, I'm saying that apparently other people do. But still, there's nothing wrong with just starting with pre-defined types, they're there for a reason. Jesus!
> 
> Luke.

I'm 1/3 of the way through this thread... yeah, this topic seems to be a touchy one :)

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 15:29             ` Optikos
  2019-12-03 16:06               ` Lucretia
  2019-12-03 20:40               ` Björn Lundin
@ 2020-04-17  4:16               ` Andrew Shvets
  2 siblings, 0 replies; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:16 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 10:29:15 AM UTC-5, Optikos wrote:
> On Tuesday, December 3, 2019 at 9:04:13 AM UTC-6, Lucretia wrote:
> > On Tuesday, 3 December 2019 14:04:24 UTC, AdaMagica  wrote:
> > > Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> > > > People coming from other languages might not grasp types easily,
> > > 
> > > Hey, what's difficult to understand in
> > > 
> > > type Temperature is range -40 .. 40;  -- Celsius
> > > 
> > > for a home thermometer?
> > 
> > I don't have a problem, I get it, I'm saying that apparently other people do. But still, there's nothing
> > wrong with just starting with pre-defined types, they're there for a reason. Jesus!
> 
> There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying.
> 
> strict) AdaMagica appears to be saying that rock-solid analysis of finding the upper & lower bounds of the integer's range (or fixed or floating point or BCD for that matter) is of crucial insight & importance to understanding the problem.
> 
> loose) You appear to be saying that for rapid prototyping that that deep analysis can be postponed.
> 
> midling) The middle ground is to use a named type* of a predefined** (not range-restricted subtype of) predefined type that represents the problem domain's meaning.  Then at a (perhaps much) later time restrict the range of that named type only at the single point of declaration in the package specification, which then takes effect at all points of usage of that named type in other declarations and in the package body without modifying all those points of usage to refer to a different name(d type).

That's _literally_ what my book does.  In fact, in the first chapter I explain the advantages of restricting types.  I simply choose to cover the complexities of Ada's types later on so that a new reader does not feel like he/she is lost.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 16:26                 ` Optikos
  2019-12-03 16:50                   ` Lucretia
@ 2020-04-17  4:27                   ` Andrew Shvets
  2020-04-17 12:44                     ` Ludovic Brenta
  1 sibling, 1 reply; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  4:27 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 11:26:55 AM UTC-5, Optikos wrote:
> On Tuesday, December 3, 2019 at 10:06:58 AM UTC-6, Lucretia wrote:
> > On Tuesday, 3 December 2019 15:29:15 UTC, Optikos  wrote:
> > 
> > > There is a wise middle ground between the 2 extremes between what you & AdaMagica are saying.
> > > 
> > > strict) AdaMagica appears to be saying that rock-solid analysis of finding the upper & lower bounds of the integer's range (or fixed or floating point or BCD for that matter) is of crucial insight & importance to understanding the problem.
> > > 
> > > loose) You appear to be saying that for rapid prototyping that that deep analysis can be postponed.
> > 
> > That's not what I'm saying at all!
> > 
> > I'm saying to get someone used to the language, there is no problem with starting them off with the
> > ready defined types, but explaining ranges a little later on, literally, within pages of themselves.
> 
> Oh, then I agree with AdaMagica wholeheartedly if restricted to only learning a new language.  I once worked for a long-time Fortran programmer who self-taught himself C; every line of code that he wrote was 110% pure Fortran-think without any resemblance (other than surface syntax) to anything more modern:  PL/I, C, Ada, Pascal.  Just about the only way that it was C code beyond force-fitting his thinking into C syntax minimally was that he eventually refrained from keeping the caps-lock key on all the time for all identifiers.  Full immersion in the new language's own better way of thinking from the very start is the only productive way to learn a new programming language.  Learning Ada the way that you describe is likely to perpetuate C-think or C++-think or Python-think in Ada, due to the new learner falsely believing “I got this!” far far too soon.

1 - Well, to look at this another way, bringing in ideas from other languages can have a benefit as well.  After all, just about every language has its roots in a different programming language.

2 - In regards to the Fortran programmer that wanted to make Fortran in C, that does happen, but that is not the case with most people.

> Learning a new programming language needs to have exciting revelatory “oh, wow!  I've never been able to do •that• before in any prior language!” moments early on to quell ho-hum boredom.  This ho-hum boredom is caused by nearly all the mainstream programming languages (with the exception of ML family) being minor variations on Algol 60's syntax and relatively minor extensions of Algol 60's control-flow constructs, so differentiating the newly-learned language from all other Algol60-esque fellow languages ASAP is crucial.  Burying the revelatory differences later in the book does a mind-numbing disservice to the reader by falsely lulling the reader into thinking Ada's key contributions are in syntax & beauty, not in semantic-meaning expressivity & crisp well-ordered-mind thinking.

*shrug* The way I look at my book is that it's an on-ramp.  There's this wonderful Ada highway, but due to the lack of up to date and relevant intro Ada books, it's pretty much impossible for others to get on the said road.  Once you're on it, there are other books that can help you become more proficient in Ada.

So what's the best way to interest someone new, while not ignoring the crucial parts of Ada that make it so good?  I'm honestly not 100% sure, but my book is a damn good stab at this issue.

I mean, I have "Chapter 2: Basic Types" where it talks about the primitives that exist in Ada.  Then there is "Chapter 12: Advanced Types" where I talk about creating your own types and subtypes and etc.  Chapter 3 to 11 talk about Ada so that you can get started and feel comfortable in the language.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17  4:10           ` Andrew Shvets
@ 2020-04-17  5:02             ` Andrew Shvets
  0 siblings, 0 replies; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  5:02 UTC (permalink / raw)


On Friday, April 17, 2020 at 12:10:03 AM UTC-4, Andrew Shvets wrote:
> On Tuesday, December 3, 2019 at 9:04:24 AM UTC-5, AdaMagica wrote:
> > Am Dienstag, 3. Dezember 2019 14:57:53 UTC+1 schrieb Lucretia:
> > > People coming from other languages might not grasp types easily,
> > 
> > Hey, what's difficult to understand in
> > 
> > type Temperature is range -40 .. 40;  -- Celsius
> > 
> > for a home thermometer?
> 
> That's not fair, now is it?  You and I know full well what that means.  But drop someone who has done C/C++/Java/Python into the same situation and it's a sure-fire way of having that person give up and declare that Ada is "too hard" or use some other excuse.
> 
> What does that accomplish?

Darn, I can't edit my original post.

But, the example that you've provided is very simple, but when it comes to types in Ada, it's a vast subject and type Temp is range -40 .. 40; does not do it justice.  There is so much more to this than that and to have someone new to try to untangle the different concepts and make sense of them will only have them abandon Ada.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2019-12-03 17:39                     ` Optikos
  2019-12-03 19:12                       ` Paul Rubin
  2019-12-14  4:34                       ` Paul Rubin
@ 2020-04-17  5:14                       ` Andrew Shvets
  2020-04-17  6:17                         ` Teaching Ada types J-P. Rosen
  2 siblings, 1 reply; 76+ messages in thread
From: Andrew Shvets @ 2020-04-17  5:14 UTC (permalink / raw)


On Tuesday, December 3, 2019 at 12:39:27 PM UTC-5, Optikos wrote:
> On Tuesday, December 3, 2019 at 10:50:40 AM UTC-6, Lucretia wrote:
> > On Tuesday, 3 December 2019 16:26:55 UTC, Optikos  wrote:
> > 
> > > > That's not what I'm saying at all!
> > > > 
> > > > I'm saying to get someone used to the language, there is no problem with starting them off with the
> > > > ready defined types, but explaining ranges a little later on, literally, within pages of themselves.
> > > 
> > > Oh, then I agree with AdaMagica wholeheartedly if restricted to only learning a new language.  I once worked for a long-time Fortran programmer who self-taught himself C; every line of code that he wrote was 110% pure Fortran-think without any resemblance (other than surface syntax) to anything more modern:  
> > 
> > ...aaaaaaaaaaaaaaand you missed my point entirely. I said to introduce them to typing concepts after
> > getting them used to the very basics, i.e. first few simple programs adding numbers and printing them
> > out, how the build using the compiler, then handle types and explaining how they're different to
> > something like typedef in C.
> 
> Although I don't have a copy of any of Andrew Shvets books to see how quickly he leaves the rudimentary level of hello-world dip-your-toe-in-the-water content, I took AdaMagica's criticism of the 1st edition as lingering far far far too long in the predefined hello-world dip-toe-in-water stage.
> 
> IMHO, the best pedagogical books always have a chapter 0 (after the Preface) that provides all the hello-world dip-toe-in-water rudimentary this-isn't-scary this-is-actually-accessible content, which would provide also the crash-course whirlwind-handwaving answer to the question of “gee, how do I actually minimally get this to compile on commonplace compilers and commonplace operating systems”.  But then Chapter 1 introduces the topic in the topic's native terms instead of as a play-baby toy.  Then back on say Chapter 11 every detail of the nuances of subtleties of how to make the build system sit up and sing for its supper can be introduced in their full glory, because it is so non-standard and vendor/OS dependent.
> 
> Paul Rubin, btw, I find Alan Burns's & Andy Wellings's 512-page _Analysable Real-Time Systems Programmed in Ada_ (2016; self-published) to be an exemplary book that truly shows off Ada's strong points in full Ada-think, but it is aimed at a different sector of the market than Schvet's introductory/general book, I suspect.

Well, yes.  In the first chapter, I explicitly state that this book will gently guide you into Ada and do a lot of hand-holding, that was the goal of the book.  The appendix details how you can install the compiler from AdaCore (which is very easy).

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17  4:07       ` Andrew Shvets
@ 2020-04-17  5:49         ` J-P. Rosen
  2020-04-17 17:59         ` AdaMagica
  1 sibling, 0 replies; 76+ messages in thread
From: J-P. Rosen @ 2020-04-17  5:49 UTC (permalink / raw)


Le 17/04/2020 à 06:07, Andrew Shvets a écrit :
>>> There's nothing wrong with using integer to start off and then
>>> moving onto defined types.
>> Yes there is! (see my paper at the last Ada-Europe). The first
>> message when you teach Ada is that it is all about defining proper
>> types. You have to start by fighting bad habits from other
>> languages.
> 
> *shrug* You have your own way of looking at this.  However, I really
> did not want to leave someone that is just starting with a long and
> academic chapter on types in Ada.  It would be boring and discourage
> someone from learning Ada.
> 
It does not need to be long and boring. I usually tell:
"You've been taught at elementary school not to add apple and oranges.
Surprisingly enough, Ada is the only language that prevents you from
doing it! "

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Teaching Ada types
  2020-04-17  5:14                       ` Andrew Shvets
@ 2020-04-17  6:17                         ` J-P. Rosen
  2020-04-29 13:07                           ` Mehdi Saada
  0 siblings, 1 reply; 76+ messages in thread
From: J-P. Rosen @ 2020-04-17  6:17 UTC (permalink / raw)


(was: Re: Beginning Ada Programming, by Andrew T. Shvets (2020))

Here is how I explain the Ada approach:

Whatever the language, when you need to represent data, it is important
to choose an appropriate type. This involves two steps:
1) Analyze your problem to determine the requirements (range f.e.) on
your type
2) Make a representation choice, i.e. choose a machine type that covers
the requirements of 1)

Ada saves you step 2), by allowing you to express your needs directly,
and leaving the choice of representation to the compiler.

The trouble is that other languages offer only machine types (for basic
types). Therefore, most people tend to think directly in terms of
machine types and skip step 1.

--------------------------------------------------------
Of course, this assumes that you teach how to create software, and not
just a language. Some times ago, a little niece of mine started a
software school. I was especially interested in how design was taught!
Well, the school taught the syntax of C, and then gave programming
exercises. I asked: "but how did they teach you how to go from a problem
statement to its solution?" She didn't even understand what I was
talking about. Sigh...

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17  4:27                   ` Beginning Ada Programming, by Andrew T. Shvets (2020) Andrew Shvets
@ 2020-04-17 12:44                     ` Ludovic Brenta
  2020-04-17 13:07                       ` Jere
  2020-04-17 14:31                       ` Optikos
  0 siblings, 2 replies; 76+ messages in thread
From: Ludovic Brenta @ 2020-04-17 12:44 UTC (permalink / raw)


Andrew Shvets <[email protected]> writes:
> 1 - Well, to look at this another way, bringing in ideas from other
> languages can have a benefit as well.  After all, just about every
> language has its roots in a different programming language.

That's very true if your audience consists of language designers; not if
your audience consists of end users of a language.

> 2 - In regards to the Fortran programmer that wanted to make Fortran
> in C, that does happen, but that is not the case with most people.

I think the crux of the matter is who you decide your audience to be.

If you decide that you want to write a "Ada for Fortran/Pascal/C
programmers" then they already know all about control structures etc;
and you should dive into the type system upfront.

If, on the other hand, you are writing "Ada as a first language" (or
even "Ada for Lisp programmers") then yes, by all means, postpone the
discussion of user-defined types until after the basics of variables,
subprograms and control structures.

So I don't think there should be real opposition; both approaches have
their merits depending on the audience.

-- 
Ludovic Brenta.
The sales manager standardizes the long-range workforce adjustments. 

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17 12:44                     ` Ludovic Brenta
@ 2020-04-17 13:07                       ` Jere
  2020-04-17 14:31                       ` Optikos
  1 sibling, 0 replies; 76+ messages in thread
From: Jere @ 2020-04-17 13:07 UTC (permalink / raw)


On Friday, April 17, 2020 at 8:44:30 AM UTC-4, Ludovic Brenta wrote:
> Andrew Shvets writes:
> > 1 - Well, to look at this another way, bringing in ideas from other
> > languages can have a benefit as well.  After all, just about every
> > language has its roots in a different programming language.
> 
> That's very true if your audience consists of language designers; not if
> your audience consists of end users of a language.
> 
> > 2 - In regards to the Fortran programmer that wanted to make Fortran
> > in C, that does happen, but that is not the case with most people.
> 
> I think the crux of the matter is who you decide your audience to be.
> 
> If you decide that you want to write a "Ada for Fortran/Pascal/C
> programmers" then they already know all about control structures etc;
> and you should dive into the type system upfront.
> 
I'll slightly disagree here.  As a person who came to Ada from other
languages, the first things I needed to know was how were things like
for loops and if statements handled differently in Ada.  You are 
correct that I didn't need to learn how a for loop worked, but I did
need to know how to construct a for loop in Ada.  Things like "in" vs
"of" for loops, how to exit loops, etc.  If a person is coming from 
another language, I would expect the first thing to do is help them
bridge the gap from where they came to where they are going:  show
them how to take what they already know and apply it to the new language.
Then teach new features.  Again, it's just my opinion, but it is 
based on my own experience trying to learn Ada.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17 12:44                     ` Ludovic Brenta
  2020-04-17 13:07                       ` Jere
@ 2020-04-17 14:31                       ` Optikos
  1 sibling, 0 replies; 76+ messages in thread
From: Optikos @ 2020-04-17 14:31 UTC (permalink / raw)


On Friday, April 17, 2020 at 7:44:30 AM UTC-5, Ludovic Brenta wrote:
> Andrew Shvets writes:
> > 1 - Well, to look at this another way, bringing in ideas from other
> > languages can have a benefit as well.  After all, just about every
> > language has its roots in a different programming language.
> 
> That's very true if your audience consists of language designers; not if
> your audience consists of end users of a language.
> 
> > 2 - In regards to the Fortran programmer that wanted to make Fortran
> > in C, that does happen, but that is not the case with most people.
> 
> I think the crux of the matter is who you decide your audience to be.
> 
> If you decide that you want to write a "Ada for Fortran/Pascal/C
> programmers" then they already know all about control structures etc;
> and you should dive into the type system upfront.
> 
> If, on the other hand, you are writing "Ada as a first language" (or
> even "Ada for Lisp programmers") then yes, by all means, postpone the
> discussion of user-defined types until after the basics of variables,
> subprograms and control structures.
> 
> So I don't think there should be real opposition; both approaches have
> their merits depending on the audience.
> 
> -- 
> Ludovic Brenta.
> The sales manager standardizes the long-range workforce adjustments.

This comment is not aimed at any particular book or edition or author.

The very best-written programming-language books have a preface that categorizes the reader into various scenarios (e.g., I know another imperative language, so I need where Ada differs; I am new to programming entirely, so I am not familiar with very many idioms at all; I know a different paradigm of programming than imperative [e.g., functional; System F; System FC], so I need to see whether any of my non-imperative idioms can be utilized in Ada).  Then the preface tells the reader in each scenario which chapter sequence to read in which order different than sequential 1,2,3,... (e.g., read Appendix J then chapter 4,5,6, then Appendix C, then Appendix H, then chapters 7 and onward) and/or which chapters likely may be skipped or skim read to get on to the meat of the matter.  This guided-path reading of a book requires an insightful author to actually place themselves in each scenario and to actually walk a mile in their shoes with empathy and without corner-cutting.

The extreme-detail variant of this technique of writing a book is the threaded programmed text where this path is encoded into the right-hand column throughout the text instead of appearing in the preface.

If Ada were to have only one modern textbook and no more, then this guided reading-order style of writing would be crucial to addressing the vast majority of the market.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17  4:11             ` Andrew Shvets
@ 2020-04-17 15:32               ` Luke A. Guest
  0 siblings, 0 replies; 76+ messages in thread
From: Luke A. Guest @ 2020-04-17 15:32 UTC (permalink / raw)


>> Luke.
> 
> I'm 1/3 of the way through this thread... yeah, this topic seems to be a touchy one :)
> 

I thought it died ages ago. :)

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17  4:07       ` Andrew Shvets
  2020-04-17  5:49         ` J-P. Rosen
@ 2020-04-17 17:59         ` AdaMagica
  2020-04-17 19:28           ` Optikos
  1 sibling, 1 reply; 76+ messages in thread
From: AdaMagica @ 2020-04-17 17:59 UTC (permalink / raw)


Am Freitag, 17. April 2020 06:07:15 UTC+2 schrieb Andrew Shvets:
> On Tuesday, December 3, 2019 at 8:21:25 AM UTC-5, J-P. Rosen wrote:
> > Le 03/12/2019 à 13:33, Lucretia a écrit :
> > >> Yes, he is. I had a little conversation on the very first edition
> > >> with him. I esp. objected that he started his examples with using
> > >> Integer rather than user-defined types (which IMHO is the very
> > >> heart of Ada). I do not know whether he changed this.
> > 
> > > There's nothing wrong with using integer to start off and then moving
> > > onto defined types.
> > Yes there is! (see my paper at the last Ada-Europe). The first message
> > when you teach Ada is that it is all about defining proper types. You
> > have to start by fighting bad habits from other languages.
> > 
> > -- 
> > J-P. Rosen
> > Adalog
> > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> > Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> > http://www.adalog.fr
> 
> *shrug* You have your own way of looking at this.  However, I really did not want to leave someone that is just starting with a long and academic chapter on types in Ada.  It would be boring and discourage someone from learning Ada.

Why must this be boring?

Define a temperature scale for a home thermometer. It has a measurement range from -30 to +40 °C.

Define a type for values you can read from a foldable meter rod (0 to 2 m).

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17 17:59         ` AdaMagica
@ 2020-04-17 19:28           ` Optikos
  2020-04-18 15:29             ` AdaMagica
                               ` (2 more replies)
  0 siblings, 3 replies; 76+ messages in thread
From: Optikos @ 2020-04-17 19:28 UTC (permalink / raw)


On Friday, April 17, 2020 at 12:59:11 PM UTC-5, AdaMagica wrote:
> Am Freitag, 17. April 2020 06:07:15 UTC+2 schrieb Andrew Shvets:
> > On Tuesday, December 3, 2019 at 8:21:25 AM UTC-5, J-P. Rosen wrote:
> > > Le 03/12/2019 à 13:33, Lucretia a écrit :
> > > >> Yes, he is. I had a little conversation on the very first edition
> > > >> with him. I esp. objected that he started his examples with using
> > > >> Integer rather than user-defined types (which IMHO is the very
> > > >> heart of Ada). I do not know whether he changed this.
> > > 
> > > > There's nothing wrong with using integer to start off and then moving
> > > > onto defined types.
> > > Yes there is! (see my paper at the last Ada-Europe). The first message
> > > when you teach Ada is that it is all about defining proper types. You
> > > have to start by fighting bad habits from other languages.
> > > 
> > > -- 
> > > J-P. Rosen
> > > Adalog
> > > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> > > Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> > > http://www.adalog.fr
> > 
> > *shrug* You have your own way of looking at this.  However, I really did not want to leave someone that is just starting with a long and academic chapter on types in Ada.  It would be boring and discourage someone from learning Ada.
> 
> Why must this be boring?
> 
> Define a temperature scale for a home thermometer. It has a measurement range from -30 to +40 °C.
> 
> Define a type for values you can read from a foldable meter rod (0 to 2 m).

What is especially not boring would be to show how the range restriction (on, say, an index into a buffer) precluded writing a worm's machine code off the end as the preclusion of a security vuln commonplace in C.  Now that would be an eye opener for most people coming from other languages.

What would be especially not boring for the thermometer range restriction (on, say, an automobile that is a competitor of Toyota) precluded a sensor misreading that its absence precluded the gas pedal not getting confused for the brake pedal as an off-by-one in the periodic polling responses in the drive-by-wire CAN network (or whatever minor mistake on the CAN caused those crashes).

What would be especially not boring would be to show how the range restriction on the low end being 1 or 2 or 3 angle-of-attack sensors could cause different child packages to be swapped in on a Boeing 737 MAX for each of 3 levels of MCAS system integrity with 3 or more AoA sensors begetting a majority-rules voting among the sensors, 2 begetting a usage of the most-sane sensor, and 1 begetting a turn off of the MCAS (or some such pilot-centric way of not having the software crash the airplane).

Range restrictions for the sake of range restrictions are in fact boring bordering on bicycle shedding for the reader.  The security that they facilitate would definitely enliven the topic.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17 19:28           ` Optikos
@ 2020-04-18 15:29             ` AdaMagica
  2020-04-18 16:34               ` cantanima.perry
  2020-04-23 18:43             ` Andrew Shvets
  2020-04-23 18:45             ` Andrew Shvets
  2 siblings, 1 reply; 76+ messages in thread
From: AdaMagica @ 2020-04-18 15:29 UTC (permalink / raw)


Just for the wow effect:

I come from Algol 60, later Pascal. I liked Pascal very much, but what annoyed me was for instance that for looping over arrays, I had to look up the bounds. So I defined functions serving this need.
When I met Ada, this was one of the first wow effects that there are language means for this purpose. Ada 83 had everything I missed in Pascal. Is there any other language on earth providing this?

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 15:29             ` AdaMagica
@ 2020-04-18 16:34               ` cantanima.perry
  2020-04-18 17:59                 ` Jere
  2020-05-02 19:13                 ` dave_thompson_2
  0 siblings, 2 replies; 76+ messages in thread
From: cantanima.perry @ 2020-04-18 16:34 UTC (permalink / raw)


On Saturday, April 18, 2020 at 10:29:15 AM UTC-5, AdaMagica wrote:
> Just for the wow effect:
> 
> I come from Algol 60, later Pascal. I liked Pascal very much, but what annoyed me was for instance that for looping over arrays, I had to look up the bounds. So I defined functions serving this need.
> When I met Ada, this was one of the first wow effects that there are language means for this purpose. Ada 83 had everything I missed in Pascal. Is there any other language on earth providing this?

I'm not sure I understand what you're saying, but if A is an array, then:

   - Modula-2 has HIGH(A) when A is an open array;
   - Modula-3 has FIRST(A) and LAST(A);
   - Eiffel has A.lower and A.upper.

But many languages these days are designed so that you don't have to bother with the array bounds at all:

   - C++ and Java have the for (auto a : A) { } construct;***
   - Eiffel has an across keyword;
   - Kotlin and Python have for (a in A) construct;

and so forth. So it seems that most popular languages these days allow this.

regards
john perry

***The C++ and Java versions don't work on low-level arrays. As I recall, Eiffel, Kotlin, and Python bring the machinery of high-level arrays to all arrays.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 16:34               ` cantanima.perry
@ 2020-04-18 17:59                 ` Jere
  2020-04-18 21:54                   ` cantanima.perry
  2020-05-02 19:13                 ` dave_thompson_2
  1 sibling, 1 reply; 76+ messages in thread
From: Jere @ 2020-04-18 17:59 UTC (permalink / raw)


On Saturday, April 18, 2020 at 12:34:31 PM UTC-4,cantani wrote:

>    - C++ and Java have the for (auto a : A) { } construct;***
> <snipped>
> ***The C++ and Java versions don't work on low-level arrays. 

Actually it does work on low level arrays in C++.  It doesn't work 
on pointers to array elements however, which people often confuse
with arrays (that's how people most often pass them to functions, 
but there are other methods).

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 17:59                 ` Jere
@ 2020-04-18 21:54                   ` cantanima.perry
  2020-04-18 22:18                     ` Luke A. Guest
                                       ` (2 more replies)
  0 siblings, 3 replies; 76+ messages in thread
From: cantanima.perry @ 2020-04-18 21:54 UTC (permalink / raw)


On Saturday, April 18, 2020 at 12:59:38 PM UTC-5, Jere wrote:
> Actually it does work on low level arrays in C++.  It doesn't work 
> on pointers to array elements however, which people often confuse
> with arrays (that's how people most often pass them to functions, 
> but there are other methods).

I didn't realize C++ had progressed to tracking how long a low-level array is, but in retrospect it's come along so much in terms of what you can do at compile-time that I should have tested before commenting. Thank you.

regards
john perry

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 21:54                   ` cantanima.perry
@ 2020-04-18 22:18                     ` Luke A. Guest
  2020-04-18 22:33                       ` Jere
  2020-04-19  2:23                       ` Keith Thompson
  2020-04-18 22:37                     ` Jere
  2020-04-19  0:42                     ` Paul Rubin
  2 siblings, 2 replies; 76+ messages in thread
From: Luke A. Guest @ 2020-04-18 22:18 UTC (permalink / raw)


On 18/04/2020 22:54, [email protected] wrote:
> On Saturday, April 18, 2020 at 12:59:38 PM UTC-5, Jere wrote:
>> Actually it does work on low level arrays in C++.  It doesn't work 
>> on pointers to array elements however, which people often confuse
>> with arrays (that's how people most often pass them to functions, 
>> but there are other methods).
> 
> I didn't realize C++ had progressed to tracking how long a low-level array is, but in retrospect it's come along so much in terms of what you can do at compile-time that I should have tested before commenting. Thank you.

I don't think it can, I think the new iterator for loops are for stl
containers only. I could be wrong though.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 22:18                     ` Luke A. Guest
@ 2020-04-18 22:33                       ` Jere
  2020-04-19  0:52                         ` Jere
  2020-04-19  2:23                       ` Keith Thompson
  1 sibling, 1 reply; 76+ messages in thread
From: Jere @ 2020-04-18 22:33 UTC (permalink / raw)


On Saturday, April 18, 2020 at 6:18:30 PM UTC-4, Luke A. Guest wrote:
> On 18/04/2020 22:54, cantanima wrote:
> > On Saturday, April 18, 2020 at 12:59:38 PM UTC-5, Jere wrote:
> >> Actually it does work on low level arrays in C++.  It doesn't work 
> >> on pointers to array elements however, which people often confuse
> >> with arrays (that's how people most often pass them to functions, 
> >> but there are other methods).
> > 
> > I didn't realize C++ had progressed to tracking how long a low-level array is, but in retrospect it's come along so much in terms of what you can do at compile-time that I should have tested before commenting. Thank you.
> 
> I don't think it can, I think the new iterator for loops are for stl
> containers only. I could be wrong though.

C++ has had a lot of changes over the last decade or so.  This 
example compiles and runs correctly:

#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	char message[] = "hello world\r\n";
	int data[] = {0,1,2,3,4,5,6,7,8,9};
 
	for(auto c : message){
		cout << c;
	}
	for(auto num : data){
		cout << num << ',';
	}
	cout << endl;
	return 0;
}

See it on ideone: https://ideone.com/db7cvr

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 21:54                   ` cantanima.perry
  2020-04-18 22:18                     ` Luke A. Guest
@ 2020-04-18 22:37                     ` Jere
  2020-04-19  0:42                     ` Paul Rubin
  2 siblings, 0 replies; 76+ messages in thread
From: Jere @ 2020-04-18 22:37 UTC (permalink / raw)


On Saturday, April 18, 2020 at 5:54:49 PM UTC-4, [email protected] wrote:
> On Saturday, April 18, 2020 at 12:59:38 PM UTC-5, Jere wrote:
> > Actually it does work on low level arrays in C++.  It doesn't work 
> > on pointers to array elements however, which people often confuse
> > with arrays (that's how people most often pass them to functions, 
> > but there are other methods).
> 
> I didn't realize C++ had progressed to tracking how long a low-level array is, but in retrospect it's come along so much in terms of what you can do at compile-time that I should have tested before commenting. Thank you.
> 
> regards
> john perry

C++ has always been able to track array size at compile time (the
sizeof() operator worked correctly even back int he day as long
as you used it on the array and not a pointer).  Somewhere since
c++11 (or maybe more recent) they added the auto looping and included
low level arrays with it.  The big problem remains however, is you 
cannot technically pass an array to a function as a bare parameter.
If you pass it to a function as a pointer, it loses the length, 
which then kills the auto looping mechanism.  There are ways around
this, but generally C++ prefers that you use containers rather than
raw arrays or pointers (similar to how Ada prefers containers over
access types).  So low level arrays still do have severe limitations
even with the auto looping available.  Hope that helps!

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 21:54                   ` cantanima.perry
  2020-04-18 22:18                     ` Luke A. Guest
  2020-04-18 22:37                     ` Jere
@ 2020-04-19  0:42                     ` Paul Rubin
  2 siblings, 0 replies; 76+ messages in thread
From: Paul Rubin @ 2020-04-19  0:42 UTC (permalink / raw)


[email protected] writes:
> I didn't realize C++ had progressed to tracking how long a low-level
> array is

I think that has to refer to std::array as opposed to std::vector.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 22:33                       ` Jere
@ 2020-04-19  0:52                         ` Jere
  0 siblings, 0 replies; 76+ messages in thread
From: Jere @ 2020-04-19  0:52 UTC (permalink / raw)


On Saturday, April 18, 2020 at 6:33:33 PM UTC-4, Jere wrote:
> On Saturday, April 18, 2020 at 6:18:30 PM UTC-4, Luke A. Guest wrote:
> > On 18/04/2020 22:54, cantanima wrote:
> > > On Saturday, April 18, 2020 at 12:59:38 PM UTC-5, Jere wrote:
> > >> Actually it does work on low level arrays in C++.  It doesn't work 
> > >> on pointers to array elements however, which people often confuse
> > >> with arrays (that's how people most often pass them to functions, 
> > >> but there are other methods).
> > > 
> > > I didn't realize C++ had progressed to tracking how long a low-level array is, but in retrospect it's come along so much in terms of what you can do at compile-time that I should have tested before commenting. Thank you.
> > 
> > I don't think it can, I think the new iterator for loops are for stl
> > containers only. I could be wrong though.
> 
> C++ has had a lot of changes over the last decade or so.  This 
> example compiles and runs correctly:
> 
I fail at expressing what I mean!  This didn't come out the way I meant
it.  I thought you were referring to the old iterator style and it
is common for people not to be familiar with C++11 and higher even today.
Sorry if it came across in a bad way!  Not intended.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 22:18                     ` Luke A. Guest
  2020-04-18 22:33                       ` Jere
@ 2020-04-19  2:23                       ` Keith Thompson
  1 sibling, 0 replies; 76+ messages in thread
From: Keith Thompson @ 2020-04-19  2:23 UTC (permalink / raw)


"Luke A. Guest" <[email protected]> writes:
> On 18/04/2020 22:54, [email protected] wrote:
>> On Saturday, April 18, 2020 at 12:59:38 PM UTC-5, Jere wrote:
>>> Actually it does work on low level arrays in C++.  It doesn't work 
>>> on pointers to array elements however, which people often confuse
>>> with arrays (that's how people most often pass them to functions, 
>>> but there are other methods).
>> 
>> I didn't realize C++ had progressed to tracking how long a low-level
>> array is, but in retrospect it's come along so much in terms of what
>> you can do at compile-time that I should have tested before
>> commenting. Thank you.

Both C and C++ have always tracked how long a low-level array is.
There's no built-in operator that gives you the number of element
in an array, but "sizeof arr / sizeof arr[0]" is a common idiom.
Except for VLAs (variable-length arrays, supported in C99, optional
in C11, not supported in C++), the number of elements in an array
always a compile-time constant.

What neither language can do is determine the length of an array
given a pointer to its initial element, which is how raw arrays are
usually manipulated in C and low-level C++.  (Not to be confused
with std::array, which is a C++ container class added in C++11.)

> I don't think it can, I think the new iterator for loops are for stl
> containers only. I could be wrong though.

You can iterate over a C++ array if you have visibility to the array
object itself.

Very often you don't have that visibility.  Which is why C++ has
std::vector, std::array, et al.

-- 
Keith Thompson (The_Other_Keith) [email protected]
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17 19:28           ` Optikos
  2020-04-18 15:29             ` AdaMagica
@ 2020-04-23 18:43             ` Andrew Shvets
  2020-04-23 21:07               ` Paul Rubin
  2020-04-23 18:45             ` Andrew Shvets
  2 siblings, 1 reply; 76+ messages in thread
From: Andrew Shvets @ 2020-04-23 18:43 UTC (permalink / raw)


All of that is covered in the first chapter.  If you go on Amazon and read the first chapter in the preview mode of the book, I talk about this

The only difference to me is how this topic should be taught.  I prefer to wait after introducing the basic types.  Ada has an amazing type system and it can do great things.  But it’s a complex topic and I want to introduce it in a different way than is usually found in most books.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17 19:28           ` Optikos
  2020-04-18 15:29             ` AdaMagica
  2020-04-23 18:43             ` Andrew Shvets
@ 2020-04-23 18:45             ` Andrew Shvets
  2 siblings, 0 replies; 76+ messages in thread
From: Andrew Shvets @ 2020-04-23 18:45 UTC (permalink / raw)


On Friday, April 17, 2020 at 3:28:29 PM UTC-4, Optikos wrote:
> On Friday, April 17, 2020 at 12:59:11 PM UTC-5, AdaMagica wrote:
> > Am Freitag, 17. April 2020 06:07:15 UTC+2 schrieb Andrew Shvets:
> > > On Tuesday, December 3, 2019 at 8:21:25 AM UTC-5, J-P. Rosen wrote:
> > > > Le 03/12/2019 à 13:33, Lucretia a écrit :
> > > > >> Yes, he is. I had a little conversation on the very first edition
> > > > >> with him. I esp. objected that he started his examples with using
> > > > >> Integer rather than user-defined types (which IMHO is the very
> > > > >> heart of Ada). I do not know whether he changed this.
> > > > 
> > > > > There's nothing wrong with using integer to start off and then moving
> > > > > onto defined types.
> > > > Yes there is! (see my paper at the last Ada-Europe). The first message
> > > > when you teach Ada is that it is all about defining proper types. You
> > > > have to start by fighting bad habits from other languages.
> > > > 
> > > > -- 
> > > > J-P. Rosen
> > > > Adalog
> > > > 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
> > > > Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
> > > > http://www.adalog.fr
> > > 
> > > *shrug* You have your own way of looking at this.  However, I really did not want to leave someone that is just starting with a long and academic chapter on types in Ada.  It would be boring and discourage someone from learning Ada.
> > 
> > Why must this be boring?
> > 
> > Define a temperature scale for a home thermometer. It has a measurement range from -30 to +40 °C.
> > 
> > Define a type for values you can read from a foldable meter rod (0 to 2 m).
> 
> What is especially not boring would be to show how the range restriction (on, say, an index into a buffer) precluded writing a worm's machine code off the end as the preclusion of a security vuln commonplace in C.  Now that would be an eye opener for most people coming from other languages.
> 
> What would be especially not boring for the thermometer range restriction (on, say, an automobile that is a competitor of Toyota) precluded a sensor misreading that its absence precluded the gas pedal not getting confused for the brake pedal as an off-by-one in the periodic polling responses in the drive-by-wire CAN network (or whatever minor mistake on the CAN caused those crashes).
> 
> What would be especially not boring would be to show how the range restriction on the low end being 1 or 2 or 3 angle-of-attack sensors could cause different child packages to be swapped in on a Boeing 737 MAX for each of 3 levels of MCAS system integrity with 3 or more AoA sensors begetting a majority-rules voting among the sensors, 2 begetting a usage of the most-sane sensor, and 1 begetting a turn off of the MCAS (or some such pilot-centric way of not having the software crash the airplane).
> 
> Range restrictions for the sake of range restrictions are in fact boring bordering on bicycle shedding for the reader.  The security that they facilitate would definitely enliven the topic.

All of that is covered in the first chapter.  If you go on Amazon and read the first chapter in the preview mode of the book, I talk about this 

The only difference to me is how this topic should be taught.  I prefer to wait after introducing the basic types.  Ada has an amazing type system and it can do great things.  But it’s a complex topic and I want to introduce it in a different way than is usually found in most books.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-23 18:43             ` Andrew Shvets
@ 2020-04-23 21:07               ` Paul Rubin
  2020-04-23 21:33                 ` Optikos
  0 siblings, 1 reply; 76+ messages in thread
From: Paul Rubin @ 2020-04-23 21:07 UTC (permalink / raw)


Andrew Shvets <[email protected]> writes:
> Ada has an amazing type system and it can do great things.  But it’s a
> complex topic and I want to introduce it in a different way than is
> usually found in most books.

I think these days (and maybe always), Ada is not a great choice of
first language for programmers.  Its strength is in its special
characteristics that are things that beginners would usually not use.
So imho, it doesn't seem all that worthwhile to start an Ada book with
beginner-level topics.

The popular beginner language these days is Python.  I use Python a lot
myself, though I have become somewhat disillusioned with it.  

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-23 21:07               ` Paul Rubin
@ 2020-04-23 21:33                 ` Optikos
  2020-04-23 21:42                   ` Paul Rubin
  0 siblings, 1 reply; 76+ messages in thread
From: Optikos @ 2020-04-23 21:33 UTC (permalink / raw)


On Thursday, April 23, 2020 at 4:07:34 PM UTC-5, Paul Rubin wrote:
> Andrew Shvets <[email protected]> writes:
> > Ada has an amazing type system and it can do great things.  But it’s a
> > complex topic and I want to introduce it in a different way than is
> > usually found in most books.
> 
> I think these days (and maybe always), Ada is not a great choice of
> first language for programmers.  Its strength is in its special
> characteristics that are things that beginners would usually not use.
> So imho, it doesn't seem all that worthwhile to start an Ada book with
> beginner-level topics.
> 
> The popular beginner language these days is Python.  I use Python a lot
> myself, though I have become somewhat disillusioned with it.

There are 2 different definitions of beginner:
1) Someone who is a beginner at programming in any imperative programming language.
versus
2) Someone who is versed to an adequate degree of proficiency in another imperative programming language and who is now learning Ada as a 2nd … Nth imperative programming language added to their repertoire.

There is quite a need for category #2 to compare similarities and contrast differences to the reader's prior knowledge.  Conversely, category #1's time has unfortunately passed is by in 2 phases:
a) the Green-Ada80-Ada83 fervor build-up to the mid- to late-1980s where some DoD-centric universities taught the preponderance of their undergraduate programming curriculum via the Ada83 interpreter; and
b) the Ada9X-Ada95 fervor build-up to the early- to mid-1990s where a far greater quantity of universities taught the preponderance of their undergraduate programming curriculum via GNAT, prior to the Java juggernaut displacing Ada in the universities.

Only some future popularity of Ada in industrial practice or in open-source would drive a 3rd wave of Ada being taught at the freshman or sophomore levels of very many universities again.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-23 21:33                 ` Optikos
@ 2020-04-23 21:42                   ` Paul Rubin
  2020-04-24 14:42                     ` Optikos
  0 siblings, 1 reply; 76+ messages in thread
From: Paul Rubin @ 2020-04-23 21:42 UTC (permalink / raw)


Optikos <[email protected]> writes:
> 1) Someone who is a beginner at programming in any imperative
> programming language.

This is what I meant by beginner ;)

> 2) Someone who is versed to an adequate degree of proficiency in
> another imperative programming language and who is now learning Ada as
> a 2nd … Nth imperative programming language added to their repertoire.

Yes, this is imho a more suitable audience for Ada.

> Conversely, category #1's time has unfortunately passed is by in 2
> phases

I'm not sure what you mean by this: imho, either category #1's time
never existed, or else it existed once but is now thankfully (not
unfortunately) in the past.  IMHO a beginner language should have
automatic memory management, and its basic integer datatype should be
unbounded aka bignums.  Python is like this, though it has its own
deficiencies.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-23 21:42                   ` Paul Rubin
@ 2020-04-24 14:42                     ` Optikos
  2020-04-24 15:35                       ` Dennis Lee Bieber
  2020-04-30  8:01                       ` Paul Rubin
  0 siblings, 2 replies; 76+ messages in thread
From: Optikos @ 2020-04-24 14:42 UTC (permalink / raw)


On Thursday, April 23, 2020 at 4:42:48 PM UTC-5, Paul Rubin wrote:
> Optikos  writes:
> > 1) Someone who is a beginner at programming in any imperative
> > programming language.
> 
> This is what I meant by beginner ;)
> 
> > 2) Someone who is versed to an adequate degree of proficiency in
> > another imperative programming language and who is now learning Ada as
> > a 2nd … Nth imperative programming language added to their repertoire.
> 
> Yes, this is imho a more suitable audience for Ada.
> 
> > Conversely, category #1's time has unfortunately passed is by in 2
> > phases

Autocorrect burned me.  It should have been:  pass us by.

> I'm not sure what you mean by this: imho, either category #1's time
> never existed, or else it existed once but is now thankfully (not
> unfortunately) in the past.  IMHO a beginner language should have
> automatic memory management, and its basic integer datatype should be
> unbounded aka bignums.  Python is like this, though it has its own
> deficiencies.

I think that there are 2 kinds of beginners to programming:
1) mathematicians at heart:  beginners that start from mathematics concepts and move downward to sequential execution of mathematics (as opposed to designing soft logic circuits in FPGAs)
versus
2) electrical engineers at heart:  beginners that start from hardware concepts and move upward a little to controlling that hardware then move up to abstracting that control.

There is something quite satisfying in #2 that assembly language and C typically provide to #2's adherents, hence C's popularity as “Gee whiz, mom, look at what I made the computer do” when ultimately interfacing with actual registers on an IC.  Ada-for-beginners fits best here in #2 because of its focus on need for the programmer to be aware of resource allocation (e.g., finite-sized storage pool allocation).  Soon after the gee whiz phase, some people yearn fairly early on for the greater intellectual discipline and direct rich expressiveness that Ada provides instead of doing it all by wink-wink-nudge-nudge idioms in C.

There is something quite satisfying in #1 that functional languages provide to #1's adherents, hence Haskell's popularity and to a lesser extent ML in a certain older age group.  The automatic memory management and arbitrarily-large bignum integers fit here, I think, because of the avoidance of thinking about the hardware very much at all.

And there might be a 3rd distinct category of beginner:  those that yearn to see the world as Mealy or Moore state machines and get frustrated that neither imperative nor functional programming languages put finite state machines as the true 1st-class citizens and everything else as cascading-ramification details hanging off as ornaments from an FSM Christmas tree.  This group of beginner gets frustrated and stays frustrated for an extended time (as they muddle through both imperative & functional paradigms, wondering at what year will they finally get to the good stuff among all this endless dreck); they become attracted to Erlang and Shlaer-Mellor eventually.  These people tend to reach a degree of now-this-is-what-I'm-talking-about satisfaction of sorts if they ever learn VHDL or Verilog for FPGAs, but few ever go that direction, so Erlang and Shlaer-Mellor is what they up embracing as the true maturity of their initial beginner starting point.  I have always thought that both tight Ada and loose C have been an especially uphill battle for this category of FSMphile beginner, because if FSMs are covered at all in Ada or C, it is as a passing thought in the 7th or 11th book that they read, perhaps even buried as a mere interested-reader exercise at the end of the chapter.  These people are expecting FSMs to be the Hollywood star in chapter 1 of the 1st book that they read on computer programming, as fundamental stimulus-response concept.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-24 14:42                     ` Optikos
@ 2020-04-24 15:35                       ` Dennis Lee Bieber
  2020-04-30  8:01                       ` Paul Rubin
  1 sibling, 0 replies; 76+ messages in thread
From: Dennis Lee Bieber @ 2020-04-24 15:35 UTC (permalink / raw)


On Fri, 24 Apr 2020 07:42:37 -0700 (PDT), Optikos
<[email protected]> declaimed the following:


>
>And there might be a 3rd distinct category of beginner:  those that yearn to see the world as Mealy or Moore state machines and get frustrated that neither imperative nor functional programming languages put finite state machines as the true 1st-class citizens and everything else as cascading-ramification details hanging off as ornaments from an FSM Christmas tree.  This group of beginner gets frustrated and stays frustrated for an extended time (as they muddle through 

	In my college, state machines weren't considered something for a
language class -- they were part of the (nominally) language independent
/algorithms and data structures/ course.

	Strangely, the only other place I've seen them recently is in the
Valvano ARM Cortex-M text books (using TI TIVA-C boards).



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	[email protected]    http://wlfraed.microdiversity.freeddns.org/

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Teaching Ada types
  2020-04-17  6:17                         ` Teaching Ada types J-P. Rosen
@ 2020-04-29 13:07                           ` Mehdi Saada
  2020-04-29 21:25                             ` Paul Rubin
  0 siblings, 1 reply; 76+ messages in thread
From: Mehdi Saada @ 2020-04-29 13:07 UTC (permalink / raw)


Le vendredi 17 avril 2020 08:17:45 UTC+2, J-P. Rosen a écrit :
> Well, the school taught the syntax of C, and then gave programming
> I asked: "but how did they teach you how to go from a problem
> statement to its solution?" She didn't even understand what I was
> talking about. Sigh...

I agree that it's still common (though NOT ONLY in programmation), this mindset: here's the tool, now build that damn wardrobe.
Bsically, I remember doing some basic exercices, ok, then the next one asks for a not-so intuitive leap in understanding, which leaves me angry.
Some people absolutely can not perform such leaps... for instance I'm Aspie, and if I've not been shown something, I will NEVER intuit it..
I've been told "open a logical/math book !"
Which there are a bunch of them with WILDLY different way of doing things, so the top-down "integrated" approach which would so be advised for any rigorous training, goes out the window.
I long for someone, saying: if you can't do that without even thinking, take the book X by Y (maybe chapter A to N), eat it, complete the exercises, and come back.
And that, for each point. For stuff like mathematical logic to high school algebra ? At least making sure that the reader knows it thoroughly before coming back to programmation per se.
It would need either that authors coordinate with each other a little bit, or for someone to know enough of the available materials available on the world wide web or otherwise, to sort it out.

It goes for higher stuff like functional programming, IA, etc. Instead of supposing the reader knows the prerequisites, how about making sure, by refering to other books to check it out ? I almost NEVER see that done. And the "hard to do in practice" is no excuse...

Sorry for the rant.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Teaching Ada types
  2020-04-29 13:07                           ` Mehdi Saada
@ 2020-04-29 21:25                             ` Paul Rubin
  0 siblings, 0 replies; 76+ messages in thread
From: Paul Rubin @ 2020-04-29 21:25 UTC (permalink / raw)


Mehdi Saada <[email protected]> writes:
> I agree that it's still common (though NOT ONLY in programmation),
> this mindset: here's the tool, now build that damn wardrobe.
> Bsically, I remember doing some basic exercices, ok, then the next one
> asks for a not-so intuitive leap in understanding, which leaves me
> angry.

A common enough issue that there's a meme about it.  NSFW language:

https://knowyourmeme.com/photos/572078-how-to-draw-an-owl

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-24 14:42                     ` Optikos
  2020-04-24 15:35                       ` Dennis Lee Bieber
@ 2020-04-30  8:01                       ` Paul Rubin
  1 sibling, 0 replies; 76+ messages in thread
From: Paul Rubin @ 2020-04-30  8:01 UTC (permalink / raw)


Optikos <[email protected]> writes:
> I think that there are 2 kinds of beginners to programming:
> 1) mathematicians at heart...  2) electrical engineers at heart

That's a very interesting way to look at things!  But, I think you have
to add architects, zoologists, and maybe a few other types.  RMS used to
say that working inside a big program was like building a city.  You had
to design new stuff, adapt old stuff, undertake urban renewal projects,
etc.  I guess that's not a beginner viewpoint though.

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-18 16:34               ` cantanima.perry
  2020-04-18 17:59                 ` Jere
@ 2020-05-02 19:13                 ` dave_thompson_2
  1 sibling, 0 replies; 76+ messages in thread
From: dave_thompson_2 @ 2020-05-02 19:13 UTC (permalink / raw)


On Sat, 18 Apr 2020 09:34:29 -0700 (PDT), [email protected]
wrote:

>    - C++ and Java have the for (auto a : A) { } construct;***
...
> ***The C++ and Java versions don't work on low-level arrays. ...

Others have corrected this for C++ (works for array, or templated
reference, but not C-style pointer-to-element)

Java also supports it for arrays, and Java arrays are a little higher
level: they carry their dimension even when passed as an argument.
(Like C & C++, their origin or lowerbound is always zero.) 

Java formerly required you to specify the typename, redundantly, but
since j10 (in 2018) it has 'var' (not 'auto', a trivial difference).

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-04-17  3:58 ` Andrew Shvets
@ 2020-05-09 12:39   ` Chris Collings
  2020-10-03  4:23     ` [email protected]
  0 siblings, 1 reply; 76+ messages in thread
From: Chris Collings @ 2020-05-09 12:39 UTC (permalink / raw)


On Friday, 17 April 2020 04:58:59 UTC+1, Andrew Shvets  wrote: 
> Hi,
> 
> I just stumbled across this thread (I haven't been here a while).  Hence the very late reply.
> 
> The book is pretty much the same as my "Introduction to Ada Programming".  The one key advantage in the Apress version is that the Index is much much much better now.  Also, I feel like that the formatting is vastly improved than what it was before.
> 
> Lastly, by going with Apress, it improves the status and visibility of Ada.  It's no longer the language of someone that programmed when Reagan was president.  It gives it a new feel of vitality and drives home the point that Ada is not "dead".
> 
> I'm under contract with Apress for a 2nd edition for this book.  That one will have much more information (such as a chapter on making GUIs).  I'm still working on that one.

Hi Andrew I am currently studying a degree in Computing and IT, apart from web programming, the main programming languages taught are Python and Java. I am only in the second year, so am starting Java in October.

I came across an Ada SIG on ASM and couldn't believe Ada was still going (I had once tried Ada 20+ years ago). Among other internet resources that give plenty of information, I searched the virtual library on the university. As the university partners with o'rielly your book was available to borrow online. 

I've read through the first couple of chapters and love your accessible approach. I have studied Python, however, I'm not a seasoned programmer. So because you started with the basics I found it a lot easier to digest. So much so that I've ordered a physical copy from Amazon.

So two things, well done getting a current Ada resource so accessible and thank you for making it easy to digest. I will in time read more advanced books, but for now this is exactly what I need. 

^ permalink raw reply	[flat|nested] 76+ messages in thread

* Re: Beginning Ada Programming, by Andrew T. Shvets (2020)
  2020-05-09 12:39   ` Chris Collings
@ 2020-10-03  4:23     ` [email protected]
  0 siblings, 0 replies; 76+ messages in thread
From: [email protected] @ 2020-10-03  4:23 UTC (permalink / raw)


On Saturday, May 9, 2020 at 8:39:25 AM UTC-4, [email protected] wrote:
> On Friday, 17 April 2020 04:58:59 UTC+1, Andrew Shvets wrote: 
> > Hi, 
> > 
> > I just stumbled across this thread (I haven't been here a while). Hence the very late reply. 
> > 
> > The book is pretty much the same as my "Introduction to Ada Programming". The one key advantage in the Apress version is that the Index is much much much better now. Also, I feel like that the formatting is vastly improved than what it was before. 
> > 
> > Lastly, by going with Apress, it improves the status and visibility of Ada. It's no longer the language of someone that programmed when Reagan was president. It gives it a new feel of vitality and drives home the point that Ada is not "dead". 
> > 
> > I'm under contract with Apress for a 2nd edition for this book. That one will have much more information (such as a chapter on making GUIs). I'm still working on that one. 
> 
> Hi Andrew I am currently studying a degree in Computing and IT, apart from web programming, the main programming languages taught are Python and Java. I am only in the second year, so am starting Java in October. 
> 
> I came across an Ada SIG on ASM and couldn't believe Ada was still going (I had once tried Ada 20+ years ago). Among other internet resources that give plenty of information, I searched the virtual library on the university. As the university partners with o'rielly your book was available to borrow online. 
> 
> I've read through the first couple of chapters and love your accessible approach. I have studied Python, however, I'm not a seasoned programmer. So because you started with the basics I found it a lot easier to digest. So much so that I've ordered a physical copy from Amazon. 
> 
> So two things, well done getting a current Ada resource so accessible and thank you for making it easy to digest. I will in time read more advanced books, but for now this is exactly what I need.


I'm glad that you liked it.  That was my whole point.  Please keep reading and let me know if you see any other way to improve the book :)

^ permalink raw reply	[flat|nested] 76+ messages in thread

end of thread, other threads:[~2020-10-03  4:23 UTC | newest]

Thread overview: 76+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03  4:05 Beginning Ada Programming, by Andrew T. Shvets (2020) Paul Rubin
2019-12-03 12:11 ` AdaMagica
2019-12-03 12:33   ` Lucretia
2019-12-03 13:21     ` J-P. Rosen
2019-12-03 13:57       ` Lucretia
2019-12-03 14:04         ` AdaMagica
2019-12-03 14:15           ` AdaMagica
2019-12-03 14:39             ` Simon Wright
2019-12-03 14:45               ` Shark8
2019-12-03 17:38               ` J-P. Rosen
2019-12-03 15:04           ` Lucretia
2019-12-03 15:29             ` Optikos
2019-12-03 16:06               ` Lucretia
2019-12-03 16:26                 ` Optikos
2019-12-03 16:50                   ` Lucretia
2019-12-03 17:02                     ` Shark8
2019-12-03 17:29                       ` AdaMagica
2019-12-05 16:35                       ` Dirk Heinrichs
2019-12-05 17:12                         ` AdaMagica
2019-12-09 19:08                           ` Dirk Heinrichs
2019-12-06 18:34                         ` Shark8
2019-12-06 20:29                           ` Jeffrey R. Carter
2019-12-06 21:05                             ` Shark8
2019-12-07  0:47                               ` Randy Brukardt
2019-12-14  4:21                           ` Keith Thompson
2019-12-14 11:34                             ` AdaMagica
2019-12-03 17:39                     ` Optikos
2019-12-03 19:12                       ` Paul Rubin
2019-12-14  4:34                       ` Paul Rubin
2020-04-17  5:14                       ` Andrew Shvets
2020-04-17  6:17                         ` Teaching Ada types J-P. Rosen
2020-04-29 13:07                           ` Mehdi Saada
2020-04-29 21:25                             ` Paul Rubin
2020-04-17  4:27                   ` Beginning Ada Programming, by Andrew T. Shvets (2020) Andrew Shvets
2020-04-17 12:44                     ` Ludovic Brenta
2020-04-17 13:07                       ` Jere
2020-04-17 14:31                       ` Optikos
2019-12-03 20:40               ` Björn Lundin
2020-04-17  4:16               ` Andrew Shvets
2020-04-17  4:11             ` Andrew Shvets
2020-04-17 15:32               ` Luke A. Guest
2020-04-17  4:10           ` Andrew Shvets
2020-04-17  5:02             ` Andrew Shvets
2020-04-17  4:08         ` Andrew Shvets
2019-12-03 19:14       ` Paul Rubin
2019-12-04  6:47         ` J-P. Rosen
2019-12-04  6:49         ` J-P. Rosen
2019-12-04  9:46           ` Paul Rubin
2020-04-17  4:07       ` Andrew Shvets
2020-04-17  5:49         ` J-P. Rosen
2020-04-17 17:59         ` AdaMagica
2020-04-17 19:28           ` Optikos
2020-04-18 15:29             ` AdaMagica
2020-04-18 16:34               ` cantanima.perry
2020-04-18 17:59                 ` Jere
2020-04-18 21:54                   ` cantanima.perry
2020-04-18 22:18                     ` Luke A. Guest
2020-04-18 22:33                       ` Jere
2020-04-19  0:52                         ` Jere
2020-04-19  2:23                       ` Keith Thompson
2020-04-18 22:37                     ` Jere
2020-04-19  0:42                     ` Paul Rubin
2020-05-02 19:13                 ` dave_thompson_2
2020-04-23 18:43             ` Andrew Shvets
2020-04-23 21:07               ` Paul Rubin
2020-04-23 21:33                 ` Optikos
2020-04-23 21:42                   ` Paul Rubin
2020-04-24 14:42                     ` Optikos
2020-04-24 15:35                       ` Dennis Lee Bieber
2020-04-30  8:01                       ` Paul Rubin
2020-04-23 18:45             ` Andrew Shvets
2020-04-17  4:04   ` Andrew Shvets
2019-12-10  5:17 ` Jerry
2020-04-17  3:58 ` Andrew Shvets
2020-05-09 12:39   ` Chris Collings
2020-10-03  4:23     ` [email protected]

comp.lang.ada

Archives are clonable: git clone --mirror https://archive.legitdata.co/comp.lang.ada

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git