Live data from Hacker News

Giving Ada a Chance

ajxs.me

81–90 of 261 posts

Re: Giving Ada a Chance

#81
post #69

Earlier quoted context omitted.

Ranged types are directly from Pascal. You can also use them to specify the valid indexes for an array (so a given array might be zero-based, or one-based, or 1900-based, or even -32768-based). A very positive feature, I agree.

And, even better, arrays in Ada (can't speak to Pascal) can be any discrete type so long as it is a range: type Character_Histogram is Array (range 'A'..'Z') of Integer; -- syntax may be off, not enough practice to do this cold right now

I don't think it even needs to be a range, you can index using enums

Re: Giving Ada a Chance

#82

Earlier quoted context omitted.

And, even better, arrays in Ada (can't speak to Pascal) can be any discrete type so long as it is a range: type Character_Histogram is Array (range 'A'..'Z') of Integer; -- syntax may be off, not enough practice to do this cold right now

I don't think it even needs to be a range, you can index using enums

Well, "range" was not the correct term. What I meant is that you can't treat the source as sparse. You can't skip portions of it. So you can't make an array that only covers every other element of this enumeration:

  type Colors is (Red, Green, Blue, Black, Gray, White);
It has to be a consecutive group of them, taken in order, as the specification of even this enumeration has an ordering to it as far as Ada is concerned. So I can make an array using all of Colors as the index, or some subset but it has to be, say, Red..Blue and not Red|Blue skipping over Green.

Re: Giving Ada a Chance

#83
post #69

Earlier quoted context omitted.

Ranged types are directly from Pascal. You can also use them to specify the valid indexes for an array (so a given array might be zero-based, or one-based, or 1900-based, or even -32768-based). A very positive feature, I agree.

And, even better, arrays in Ada (can't speak to Pascal) can be any discrete type so long as it is a range: type Character_Histogram is Array (range 'A'..'Z') of Integer; -- syntax may be off, not enough practice to do this cold right now

  type
    TPerson = record
      name: string;
      age: integer;
    end;
    TThrteenPersons = array[10..22] of TPerson;

  procedure Check(const aPerson: TPerson);
  var
    vPerson: TThrteenPersons;
  begin
    vPerson[11] := aPerson; // this is ok
    vPerson[1] := aPerson; // this one gives compile error
  end;
alternatively if runtime range checking is on then vPerson[i] = aPerson will raise the exception if i is out of range

Re: Giving Ada a Chance

#84
post #83

Earlier quoted context omitted.

And, even better, arrays in Ada (can't speak to Pascal) can be any discrete type so long as it is a range: type Character_Histogram is Array (range 'A'..'Z') of Integer; -- syntax may be off, not enough practice to do this cold right now

type TPerson = record name: string; age: integer; end; TThrteenPersons = array[10..22] of TPerson; procedure Check(const aPerson: TPerson); var vPerson: TThrteenPersons; begin vPerson[11] := aPerson; // this is ok vPerson[1] := aPerson; // this one gives compile error end; alternatively if runtime range checking is on then vPerson[i] = aPerson will raise the exception if i is out of range

Right. I know it works with numeric indexes in Pascal. My point was that (using my previous example) in Ada it works with any discrete type, in that case characters (which are not numbers in disguise in Ada) so I can do this:

  Histogram : Character_Histogram;
  ...
  Histogram['A'] := Histogram['A'] + 1;
(Ok, a bit more work because I didn't initialize the histogram to 0.)

Re: Giving Ada a Chance

#85

I love Ada, unfortunately it’s real world use seems to be relegated to old legacy code. I’d like to use it a little more on the side, but I also need to keep my priorities focused on realism, which sadly means ignoring Ada and learning something like C++ which seems unapproachable from any angle. Ada also seems to have a weirdly negative rep in many circles it seems. I recall looking around for an Ada compiler for a…

From my experience, it still gets a lot of use in aerospace and defence companies. Outside of those industries I can't think of people even mentioning it really, but again probably biases abound.

Skimming my local jobs list(SE England) I see new listings from both Airbus and BAE Systems looking for Ada developers in the past week.

Re: Giving Ada a Chance

#86
I took an Ada programming course when I worked at a defense contractor in the late 80s. Coming from C and Pascal it seemed familiar enough to learn quickly but was overkill for what we were doing at the time. I left soon after and I have no idea if they ever actually adopted it.

Re: Giving Ada a Chance

#87
post #67
post #39

> I can’t help but think that complicated programming paradigms would seem more intuitive to beginners if taught through Ada instead of C and its derivative languages, as is common in computer science and engineering faculties worldwide. At my university, the first courses you took in CS used Ada. I think it was a really good choice but I was in the minority I guess because after my year they switched to either using…

I am not sure if this is still the case today, but Computer Engineering in EE Department used to teach Pascal / Ada / C as the first programming language. With the expectation that making a program to compile correctly is hard. Before you move off to something like Perl / Java / Python. While in CS they tends to start to Python or Java. And you start learning all the OO, Procedure or whatever paradigm before going in…

I feel this. My CS program was in Java.

After a few years in industry, I believe that CS should start with either C or Scheme. C to teach you about real machines, Scheme to ignore the machine and do math (algorithms).

Re: Giving Ada a Chance

#88
post #39

> I can’t help but think that complicated programming paradigms would seem more intuitive to beginners if taught through Ada instead of C and its derivative languages, as is common in computer science and engineering faculties worldwide. At my university, the first courses you took in CS used Ada. I think it was a really good choice but I was in the minority I guess because after my year they switched to either using…

> after my year they switched to either using Java or Python They do this because of intense negative feedback from students who don't like having to learn languages for which there is no job market.

Which is fair, but also kind of funny. In theory, what most of us do day to day is software engineering and computer science is a niche corner of mathematics. But the broader expectation is that the math-niche teaches day to day programming.

Re: Giving Ada a Chance

#89

Earlier quoted context omitted.

When I went to school the instructor talked a bit about Ada, but as far as I know there weren't any compilers available that mere students could afford. This was in the mid-90s. I remember doing a bit of comparison of the syntax between languages, and Ada's lack of anything like a switch/case statement stood out, but the instructor did talk up the idea that if you could get it to compile it would run in Ada, assuming…

I don't know when it was added, but Ada does have a switch/case equivalent construct and I can't imagine it wasn't available early on. case X is when 1 => ...; when 2 => ...; when 3 | 4 | 100 => ... when others => ... end case;

It was always part of the language, http://archive.adaic.com/standards/83lrm/html/lrm-05-04.html...

Re: Giving Ada a Chance

#90
post #34

In answer to what appears to be a misunderstanding about Rust: > Its foreign function interface seems particularly poorly implemented. The official Rust documentation suggests the use of the external third-party libc library (called a 'crate' in Rust parlance) to provide the type definitions necessary to interface with C programs. As of the time of writing, this crate has had 95 releases. Contrast this with Ada’s Int…

[deleted]
Post reply on HN