comp.lang.ada
 help / color / mirror / Atom feed
* Re: Here is why C and C++ are bad...
       [not found] ` <28691853-48fd-4d68-b28b-3ecbaf7a1bc0@googlegroups.com>
@ 2015-12-26 19:21   ` Anh Vo
  2015-12-27 11:25     ` Serge Robyns
  0 siblings, 1 reply; 2+ messages in thread
From: Anh Vo @ 2015-12-26 19:21 UTC (permalink / raw)


On Saturday, December 26, 2015 at 4:47:23 AM UTC-8, Serge Robyns wrote:
> On Friday, 25 December 2015 22:54:10 UTC+1, Ramine  wrote:
> 
> with Ada.Text_IO; use Ada.Text_IO;
> 
> procedure test is
>    u : Natural := 1234;
>    i : Integer := -1233;
>    result1 : Natural;
> 
> begin
>    result1 := u + i;
>    Put_Line ("result: " & Natural'Image (result1));
> end test;

and your point is? This compiles since Natural is a subtype of Integer. Otherwise, it will be rejected by the compiler if u : New_Natural := 1234; where type New_Natural is new Integer range 0 .. Integer'Last; Thus, this example did not demonstrate the mixing of two separate types.


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

* Re: Here is why C and C++ are bad...
  2015-12-26 19:21   ` Here is why C and C++ are bad Anh Vo
@ 2015-12-27 11:25     ` Serge Robyns
  0 siblings, 0 replies; 2+ messages in thread
From: Serge Robyns @ 2015-12-27 11:25 UTC (permalink / raw)


On Saturday, 26 December 2015 20:21:46 UTC+1, Anh Vo  wrote:

> and your point is? This compiles since Natural is a subtype of Integer. Otherwise, it will be rejected by the compiler if u : New_Natural := 1234; where type New_Natural is new Integer range 0 .. Integer'Last; Thus, this example did not demonstrate the mixing of two separate types.

This is exactly my point. Using bogus examples to prove a point is a bogus proof.  If you read carefully you will notice I said "I purposely" used sub types instead of plain types as this is what was done in the C example too.  Likewise in C++ you would have to use different classes with their operators to achieve "strong" typing.  I'll not be the one to dismiss all the qualities of Ada but I can't accept bogus arguments to paint infamy neither.  We all know it takes more than a language to build good software, it has to start with good software engineering and "best practices".  Likewise a safety belt will not make reckless drivers safe.

I've given a quick look at Ramine's code as he advertised it and was surprised to find plenty of type-less pointers (equivalent of void* in C), actually I failed to find the traditional Pascal typed pointer notation "^type", generic scalar types and even C like constructs like int32 and int64.  There is a fair amount of design to be done in order to port the code to Ada.  Well true Ada will force him to do so, at least partially, as my example has proven it.  But the same will hold true if he wanted to port his code to proper C++.  And this is why I found the statement so bogus.  Nothing to do with Ada nor C++, both languages have options to do unsafe/unchecked conversions and actions but all good software engineers will doubt the code.

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

end of thread, other threads:[~2015-12-27 11:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <n5kdp5$cji$5@dont-email.me>
     [not found] ` <28691853-48fd-4d68-b28b-3ecbaf7a1bc0@googlegroups.com>
2015-12-26 19:21   ` Here is why C and C++ are bad Anh Vo
2015-12-27 11:25     ` Serge Robyns

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