Live data from Hacker News

Giving Ada a Chance

ajxs.me

121–130 of 261 posts

Re: Giving Ada a Chance

#121
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

In Pascal you can use any ordinal type as the type of the array index. You can create a new type from a range of ordinal values.

So you can have arrays where the index runs from -10 to +20 or from +7 to +26 for instance. Booleans are also ordinal types so you can have an array where the index is boolean.

Re: Giving Ada a Chance

#122
post #3

This was a good read. I instantly recognized the title of the textbook that is mentioned in the blogpost? I own it! Having a background in C, I went back and forth with Ada for years, without really jumping all in. In the last couple years in particular, with the growing popularity of Rust, I started to renew my interest. I'm reminded of a popular reddit thread on r/Ada-- someone called Rust a "toy language", which p…

Is Unchecked_Deallocation still necessary? If so, then it is hard for me to take seriously any claims of Ada's safety.

There's a LOT of things that it's not necessary for; watch this video: https://archive.fosdem.org/2016/schedule/event/ada_memory/

Re: Giving Ada a Chance

#123
post #83

Earlier quoted context omitted.

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.)

Pascal (well Delphi/FreePascal incarnation) also works with chars and enums.

This modern pascal is very feature rich and has plenty of fancy bells and whistles.

Re: Giving Ada a Chance

#124
post #83

Earlier quoted context omitted.

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.)

It works with any ordinal type in Pascal, including characters, booleans and enums.

Re: Giving Ada a Chance

#125

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…

>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. Oh, my github must be ancient then! > Ada also seems to have a weirdly negative rep in many circles it seems. I recall lo…

Heh, I must say way, impressive GitHub. You the original author of the OSDev wiki’s barebones Ada tutorial?

Off topic, but have you ever heard of CHILL? It’s a language from the ITU designed for telephone switches (like Erlang) but is supposedly very similar to older Ada standards.

Re: Giving Ada a Chance

#126

I like the "clean feel" of Ada's syntax: it combines the elegance of Python with a bit more structure and does not suffer from Python's significant whitespace issues. The so-called "Ada comb" structure that is used for packages, subprograms, and even declare blocks makes it easy to find what you are looking for because it makes the source code more regular. The "Ada comb" is formed by the shape of the source code wit…

I did Ada back in university. I wrote a toy Ada compiler for my master's thesis. I was so enamored with Ada's exception handling at the time! When I discovered Python and its similar exception handling, I jumped onto Python in a heartbeat.

Awesome, you wouldn't still have a copy of your Ada compiler's source do you?

Re: Giving Ada a Chance

#127

I really like Ada's ranged types (VHDL has them also - it inherited them from Ada). You can say: type OperatingTemp is range 33 .. 90; And then declare variables of that type and they will be range checked - an exception will be thrown if the variable goes out of that range. Wish more languages had this feature.

I have little knowledge of HDL’s but I’m constantly hearing bad things about Verilog and good things about VHDL. Is it worth picking up?

Re: Giving Ada a Chance

#128

Earlier quoted context omitted.

I agree. I learned Ada in university (my professor was on the Ada committee) and used it for an embedded development course. The language was really good (many fewer foot guns than C or C++; clearly Ada was holistically designed), but I recall having issues with the tooling and the ecosystem, and the community was super defensive and hostile. If something wasn't working for your use case and the community didn't have…

GWU?

Nope. And I'm not going to say since this is my top secret anon account.

Re: Giving Ada a Chance

#129
post #53

I like the "clean feel" of Ada's syntax: it combines the elegance of Python with a bit more structure and does not suffer from Python's significant whitespace issues. The so-called "Ada comb" structure that is used for packages, subprograms, and even declare blocks makes it easy to find what you are looking for because it makes the source code more regular. The "Ada comb" is formed by the shape of the source code wit…

I use PL/SQL a fair bit, which was inspired by Ada. Unfortunately, the designers did not bring over ShortName is New ReallyLongAndAwkardName; Ah, well.

> I use PL/SQL a fair bit, which was inspired by Ada. I have a bit of a project-idea here: PL/SQL+Ada+VHDL all together in an IDE.

> Unfortunately, the designers did not bring over > ShortName is New ReallyLongAndAwkardName; Do you mean renames? Package Text renames Ada.Strings.Fixed;

IIRC, RENAME is in the keywords list for PL/SQL.

Re: Giving Ada a Chance

#130
post #123

Earlier quoted context omitted.

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.)

Pascal (well Delphi/FreePascal incarnation) also works with chars and enums. This modern pascal is very feature rich and has plenty of fancy bells and whistles.

Wirth's original, standard Pascal allowed for int/char/bool/enum, and ranges thereof, as array bounds; it wasn't a Delphi enhancement.
Post reply on HN