Originally posted by pal666
View Post
Announcement
Collapse
No announcement yet.
AdaCore Has Been Developing A GNAT/Ada Front-End To LLVM
Collapse
X
-
Originally posted by totoz View PostYou have to work with a language that don't provide mechanisms for checking your inputs at compile time like Ada typing, and you always wonder if the caller won't put shit in your arguments (because it's just an "int" or "float" instead of an "hour" or a "longitude", etc.) and how your method will have to deal with that.
Originally posted by totoz View PostWhat were your looking for, a launch_missile() pre-built function?
Originally posted by totoz View Postin 2019 you still have to guard your includes in C/C++, and to put them in proper order to make them compile...
Originally posted by totoz View PostOk, so you live under a rock and don't know what you're talking about. The language is not strictly procedural-oriented as you can do Object-Oriented programming with it like in C++
Comment
-
Originally posted by wizard69 View PostPersonally I like languages that are readable years latter and even if I never used the language before. That is one of the reasons I adopted Python for many of my pet projects. Being easy to remember or refresh what you did years ago is a big thing. C++ can be good but it also can end up looking like APL written by a wizard (not a good wizard).
You can write bad code in pretty much any language. I guess what varies is how easy it is to write good code.
And I'll go ahead and define good code as being easy to understand, verify, and modify - ideally, with minimal impact on performance.
Originally posted by wizard69 View PostIn other words people are knocking ADA here for one of the more important features of the language. That is nice clear verbose syntax.
What I seek is the ability to express thoughts and ideas in a clear and concise manner. To that end, you need a somewhat diverse and flexible set of abstraction mechanisms. In a word: expressive.Last edited by coder; 08 October 2019, 03:32 AM.
Comment
-
Originally posted by coder View PostWell, in C++, you can define types for that purpose.
Code:type Hour is range 0 .. 23;
Code:procedure Foo (H : in Hour); I : Integer; ... Foo (30); -- Illegal (compiler warns that an exception will be raised at execution) Foo (I); -- Illegal (compiler expects an Hour data, but found an Integer data) Foo (Hour (I)); -- Valid: you do the conversion, -- you take the risk of 'I' not being in range and thus raising an exception. -- This is where you decided to handle bad input (imagine an exception handler here)
Code:Octets no. 4-6 (3 bytes) In WGS.84 in two’s complement form. Range -180 ≤ longitude < 180 deg. LSB = 180/2^23 degrees = 2.145767 * 10-05 degrees.
In Ada, such type is easily defined like:
Code:Longitude_LSB : constant := 180.0 / 2**23; type Longitude is delta Longitude_LSB range -180.0 .. 180.0 - Longitude_LSB with Size => 24, Small => Longitude_LSB;
In other languages, you'll have to define the conversions yourself, or depend on a library, but it won't be as elegant and convenient as a native language feature.
Originally posted by coder View PostAny decent library doesn't place any restrictions on the order in which you include its headers.
- there will always be someone who will have to deal with that (the library developers);
- you also have includes inside your own project, so the problem arise at this level anyway.
Modules are coming in C++, I hope this feature will be nicely designed.
- Likes 1
Comment
-
Originally posted by totoz View PostHow do you define the Hour type for example? In Ada, it will look like:
Originally posted by totoz View PostCode:procedure Foo (H : in Hour); I : Integer; ... Foo (30); -- Illegal (compiler warns that an exception will be raised at execution) Foo (I); -- Illegal (compiler expects an Hour data, but found an Integer data) Foo (Hour (I)); -- Valid: you do the conversion, -- you take the risk of 'I' not being in range and thus raising an exception. -- This is where you decided to handle bad input (imagine an exception handler here)
http://www.open-std.org/jtc1/sc22/wg...8/p1045r0.html
Without that, if you wanted assured compile-time range-checking, you'd need to use template parameters and construct instances with a function template.
Originally posted by totoz View PostCode:Longitude_LSB : constant := 180.0 / 2**23; type Longitude is delta Longitude_LSB range -180.0 .. 180.0 - Longitude_LSB with Size => 24, Small => Longitude_LSB;
Originally posted by totoz View PostThen you can directly manipulate longitude data (-180.0, 45.0, 0.0, ...), but the data binary representation is a 24-bit integer in two’s complement form (-180.0 is represented by -2^23, 45.0 by 2097152, 180.0-LSB by +2^23, etc), as defined by the protocol specification.
In other languages, you'll have to define the conversions yourself, or depend on a library, but it won't be as elegant and convenient as a native language feature.
BTW, thanks for sharing (especially actual code).
Comment
-
Originally posted by coder View PostFirst, you just seemed to be talking about constraining inputs, semantically. Now, you want to talk about range-checks? We can go there, but I never said C++ had equivalent such capabilities as Ada.
Code:type Hour is new Integer; type Minute is new Integer;
I know it's not totally impossible to do such things in C++, and my point is not to say that Ada is superior than XXX language. I think every language has its pros and their cons, and suits better for such or such case.
I wanted to react to some outdated stereotypes that make some interesting technologies forgotten, whereas some ideas could be reused in other languages. Because a reader not knowing Ada that finds posts only depicting it as an old gun, will end up with a cognitive bias based on a totally wrong picture and never get back on it. I like too when other people defend technologies I don't know myself, it makes me learn new things.
- Likes 1
Comment
-
Originally posted by totoz View PostBeing a niche language doesn't make it obsolete, and safety-critical software is not going to disappear.
ada's niche is something government-mandated
Originally posted by totoz View Postin 2019 you still have to guard your includes in C/C++, and to put them in proper order to make them compile...
Comment
-
Originally posted by pal666 View Postbut its niche is different. niche of safety-critical software is taken by c++ https://www.youtube.com/watch?v=3SdSKZFoUa8
at that point all rover FSW development was mandated to be done mainly in the C programming language.
Comment
-
Originally posted by totoz View Post
How do you define the Hour type for example? In Ada, it will look like:
Code:type Hour is range 0 .. 23;
Originally posted by totoz View PostIn other languages, you'll have to define the conversions yourself, or depend on a library, but it won't be as elegant and convenient as a native language feature.
Comment
Comment