Author Topic: 2017 Make with Ada competition  (Read 26058 times)

0 Members and 1 Guest are viewing this topic.

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10278
  • Country: gb
    • Having fun doing more, with less
Re: 2017 Make with Ada competition
« Reply #50 on: May 20, 2017, 06:21:49 am »
Common sense is irrelevant in that context.

Common sense is always relevant. Cogito ergo sum.

It is necessary, but not sufficient. Besides, common sense isn't common.

Quote
People are crazy about safety. They invented safe programming languages and used them to create the most overbloated and dysfunctional software that ever existed. You think looking at the results would give them a clue that something is wrong with the approach. Not in a slightest. They want yet better, that is yet safer languages.

I hope you can express your intent better in a programming language than you can in English.

Quote
What I value in the language is freedom - ability to do what I want with it. If, instead, it stands in my way, I will try to avoid it a all costs. Language safety is of no concern to me. If I do something stupid such as going over array boundaries, so be it. I know I'm going to make mistakes, and there's nothing wrong with this. I can test, and I can fix. Does such approach makes development slower? I don't think so.

Professionals know that "you can't test quality into a product". Developers are notoriously bad at finding bugs in their own code.

W.r.t. development speed, you really ought to think it makes the process slower overall. Start with reading any of the standard books such as Brooks' "The Mythical Man Month", or McConnell's "Rapid Development"

Quote
More freedom means simpler and less bloated programs. Simpler programs take less development time. Also, they are likely to have less bug.

The last two sentences are correct, if somewhat ungrammatical. The first sentence is gibberish.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9209
  • Country: my
  • reassessing directives...
Re: 2017 Make with Ada competition
« Reply #51 on: May 20, 2017, 07:12:24 am »
maybe someone should persuade Dave to program this forum in Ada, to avoid stupid mistakes like misquotes and ungrammatical semantics. this is life threatening forum, brain doesnt count  :-DD
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18013
  • Country: nl
    • NCT Developments
Re: 2017 Make with Ada competition
« Reply #52 on: May 20, 2017, 10:12:12 am »
People are crazy about safety. They invented safe programming languages and used them to create the most overbloated and dysfunctional software that ever existed. You think looking at the results would give them a clue that something is wrong with the approach. Not in a slightest. They want yet better, that is yet safer languages.
IMHO you have to distinguish between two use cases for a safe programming language:
1) Use by programmers who can't program so the program doesn't work but at least it doesn't crash all the time.
2) Use by programmers who can program and like to concentrate on the task at hand instead of babysitting a programming language.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10278
  • Country: gb
    • Having fun doing more, with less
Re: 2017 Make with Ada competition
« Reply #53 on: May 20, 2017, 10:21:54 am »
People are crazy about safety. They invented safe programming languages and used them to create the most overbloated and dysfunctional software that ever existed. You think looking at the results would give them a clue that something is wrong with the approach. Not in a slightest. They want yet better, that is yet safer languages.
IMHO you have to distinguish between two use cases for a safe programming language:
1) Use by programmers who can't program so the program doesn't work but at least it doesn't crash all the time.
2) Use by programmers who can program and like to concentrate on the task at hand instead of babysitting a programming language.

Nicely put. :)

Alternatively, "if C++ is the answer, just what was the question?".
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9209
  • Country: my
  • reassessing directives...
Re: 2017 Make with Ada competition
« Reply #54 on: May 20, 2017, 10:45:15 am »
IMHO you have to distinguish between two use cases for a safe programming language:
1) Use by programmers who can't program so the program doesn't work but at least it doesn't crash all the time.
2) Use by programmers who can program and like to concentrate on the task at hand instead of babysitting a programming language.
you have to distinguish between a "language" and "features that come with the compiler". language is one thing, compiler is another thing. since this thread is more toward a "language" (Ada), we should be concentrating on that, not what feature a compiler can provide. features a compiler from Borland will be different from what a Microsoft's compiler can provide. external tools is another whole different story. i will agree with you and the clan if this thread is talking about..... "Competition using Robust Ada Compiler from AdaCore". i'm not sure how many Ada compiler out there, GNAT is one of it? but if Ada is like C/C++ with many compiler manufaturers/vendors, i bet there will a whole bunch of inconsistencies and level of securities among them.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 2560
  • Country: it
Re: 2017 Make with Ada competition
« Reply #55 on: May 20, 2017, 11:14:56 am »
You are missing several things.

I am aware i am, that's why i asked

Quote
Demonstrably skilled programmers do continually make many mistakes with C/C++.
after all, humans make mistakes

Those with significant experience of both C and Ada usually claim Ada gives better results where it is used.

Quote
You have to compare the cost of the tools with the employment costs of the engineers (typically 2*salary).

but i would expect that since that's a more niche language tool that costs a lot for a small business, the salary for somebody that know it well would be that higher as well. bottom line, can smaller businesses in less critical areas afford the price of both tools and man power?
I assume that the goal of this competition is to increase adoption or at least make developers curious about it. Okay, where is the free compiler and debugger for my platform of choice? I am fine with some limitations so i can at least check it out
 
Quote
You have to compare the cost of the tools with the cost of making a mistake that would have been avoided if the tools had been used.
The cost to you is irrelevant
You have ignored the difficulty of proving (e.g. to a judge/jury) that you have taken all necessary steps. Common sense is irrelevant in that context.

Very true, one buy insurance before the accident. about common sense, i think that the jury's/judge common sense is very relevant, more than actual proofs, sadly

This is only my opinion, of course

I hope your placement of brackets in your programs is less error-prone than your placement of "quote" tags above! (One of the lines that you appear to write was in fact written by me).

Knowing that humans make mistakes is a reason for preferring languages that help detect and avoid some important classes of mistake.

Having free compilers/tools is very helpful, but is not sufficient. Industry inertia should never be underestimated.

General principle about insurance: on average you pay more for insurance than you get back from insurance. With that in mind...
I've never heard of any insurance for being late to market or developing poor quality products.
I suspect that buying insurance for a useful amount of product liability would be very expensive.
Yeeeeeah, i get your point. i guess i would have spotted that mistake in a forum with a WYSIWYG post editor, but i'd rather just make an error and then correct it. Nobody was harmed for this error, do you get mine?

I am not saying you all are wrong, not at all. What i'm trying to say is that i can't see how the benefits are more that the cost in my line of work. I like to learn from my mistakes and my mistakes shouldn't put people's life in danger, hopefully.
I am sure i will change my mind in the future, when i will be more eperienced... or when needed. But if i can use C, i'll use C.

Lack of experience? Probably. I won't deny it. After all, i have been earning money from programming microcontrollers for just a few years (i'm 25)
But the i-know-better attitude is not helping getting your message across

Lazyness? That plays a big role: if i can use C i will use C. I will be extra careful, no problem for me. I don't have tight development cycles nor have to work on safety critical applicatons, thank god.

But at the end of the day is lack of free and ready made tools that is stopping me or someone like me (i think) from adopting new languages.
Is there an ada compiler for dspic? AFAIK, no. And i use them extensively.
It is true that one shouldn't understimate industry inertia, but smaller players can also be more dynamic (less numbers on products and quantities, less people, less inertia from within the workplace itself) but for those places a multi thousand euro investment can't be taken lightly. That is my current situation. I can/am proposing new platforms in both software and hardware at where i work but the investment has to be justified. Having free tools for the platforms i have to use, at least for training, would have me learning these platforms.

I see your point. Do you see mine?

Again, it is all my opinion.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4348
  • Country: ch
Re: 2017 Make with Ada competition
« Reply #56 on: May 20, 2017, 02:09:24 pm »
Professionals know that "you can't test quality into a product". Developers are notoriously bad at finding bugs in their own code.

Exactly!
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 2560
  • Country: it
Re: 2017 Make with Ada competition
« Reply #57 on: May 20, 2017, 02:20:12 pm »
pay a good C programmer that can achieve the same result

No, that is the point: there job-area (like avionics) where C-programmers don't achieve the same result if you have to consider the task in the life-cycle window.


again: i thought that the point of all of this (2017 make with ada competition) was to increase adoption of ada from OUTSIDE those job-areas

i am NOT arguing about it's purposes and merits in those job areas, of which i know nothing about
« Last Edit: May 20, 2017, 02:21:55 pm by JPortici »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 1841
  • Country: ca
Re: 2017 Make with Ada competition
« Reply #58 on: May 20, 2017, 02:35:29 pm »
I hope you can express your intent better in a programming language than you can in English.

If you don't understand something, just ask. I'll explain. If you want to discuss grammatical errors, point specifically to them. I'll learn and hopefully my English will be better and more understandable next time.

Professionals know that "you can't test quality into a product". Developers are notoriously bad at finding bugs in their own code.

I didn't suggest testing quality into a product. I suggested that there's no reason to be afraid of mistakes. If you make a mistake, this is not the end of the world. You can fix it and move along. Happens all the time.

But what can you do if the language stands between you and your goal and doesn't let you do what you want to do?
 

Online Kalvin

  • Super Contributor
  • ***
  • Posts: 1793
  • Country: fi
  • Embedded SW/HW.
Re: 2017 Make with Ada competition
« Reply #59 on: May 20, 2017, 02:40:31 pm »
But what can you do if the language stands between you and your goal and doesn't let you do what you want to do?

Do you have any particular case where the language has prevented you from doing something you would need to do? And what useful language constructions Ada does not have compared to the C/C++ languages, for example?
 

Online Kalvin

  • Super Contributor
  • ***
  • Posts: 1793
  • Country: fi
  • Embedded SW/HW.
Re: 2017 Make with Ada competition
« Reply #60 on: May 20, 2017, 03:33:51 pm »
The magnitude of numbers that need to be represented depends on the problem and hence can and should be part of the problem specification and/or top-level architectural design. That is true for whichever language is used to implement a solution - Ada, C, Forth, Java, xC, Pascal (OK probably not Smalltalk, since it silently flips to BigIntegers whenever overflow occurs :) )

Right, and this is the reason I use int32_t etc. in C, except for simple things like small loop index variables. But the fact that it is possible at all that a program behaviour can change if you use a different compiler, is not a good language design decision in my opinion. I know they did this for efficiency reasons, because if you have 32 bit registers, then it is faster to have 32 bit integers as well, but this doesn't matter anymore nowadays. Would be better the other way around: if the programmer writes a program for an architecture with a CPU with 16 bit registers, the programmer could use 16 bit types, but integer should still be 32 bit. I guess it is no problem with the new generics feature of Ada to use the type you want in libraries as well, depending on your target.

Well, if you think about it, using integers or longs doesn't convey any information whether the variable contains a valid value or whether the value you are trying to assign to a variable is within the valid range. Thus, using integer and longs should not be allowed in first place. And the int32_t, uint32_t, uint8_t are just stating that you want to allocate N bytes for the variable, that's all.

Let's take an example here: You are printing the values of variables on the screen while your program is running. How can you be sure that the values of the variables are withing acceptable range? You do not, unless you check your source code or the documentation. So, you take a look at the source code and find out the the variable is of type integer:

Code: [Select]
int row;
int column;

Are you any wiser now in determining whether the variable holds a valid value?

The C programmers have a partial solution for this: they can use a typedef to define a new type:

Code: [Select]
typedef int RowIndex_t;
typedef int ColumnIndex_t;

RowIndex_t row;
ColumnIndex_t column;

Unfortunately this definition doesn't give any more information other than the variable row is now of type RowIndex_t but doesn't reveal what is the allowed range of values. Also, it doesn't allow the compiler check whether you are accessing the array with valid indexes: You can access the table as Table[row][column] or Table[column][row] and the compiler is happy with that, although the result may not be what you expect.

In Ada it is possible to define an integer type to contain the lower and upper limits of the type, so the programmer can find that information right from the type definition:

Code: [Select]
type Row_Index_Type is range ROW_INDEX_MIN .. ROW_INDEX_MAX;
type Column_Index_Type is range COLUMN_INDEX_MIN .. COLUMN_INDEX_MAX;

m : Row_Index_Type;
n : Column_Index_Type;

Now, also the compiler can check that the variable will always be assigned with the valid values, otherwise an exception will occur. With this more detailed and expressive type system, a compiler is able to perform compile-time analysis and find common errors, like trying to access the array with wrong indexes or assigning a variable with a value outside its allowed range etc.
« Last Edit: May 20, 2017, 03:40:15 pm by Kalvin »
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 1841
  • Country: ca
Re: 2017 Make with Ada competition
« Reply #61 on: May 20, 2017, 05:53:52 pm »
Do you have any particular case where the language has prevented you from doing something you would need to do? And what useful language constructions Ada does not have compared to the C/C++ languages, for example?

Last time I used "safe" languages was some 15 years age when I was forced to use VB and C#. So, I don't remember specific cases. Perhaps we start from C, and then you explain how Ada can help.

I propose the following small example. If you think it is bad, offer a different one and we'll go from there.

Imagine, you have a binary file (similar to ELF, ZIP etc.). Let's suppose the file contains a tree presented as a list of 32-bit aligned records:

Code: [Select]
typedef struct {
  uint32_t sibling; // offset of the sibling's record from the beginning of the file
  uint32_t child; // offset of the first child's record from the beginning of the file
  load_t payload; // variable length payload
} obj_t, *pobj_t;

You need to transverse the tree. You read your file into memory as a single piece, verify that the length is a multilple of 4, then you start going through the tree:

Code: [Select]
int process_object(char* file_base, uint32_t file_size, pobj_t object) {
   int offs;
 
  //TODO: here goes the code to process the payload

  // now deal with the tree

  // process the rest of the siblings (if any)
  if ((offs = object->sibling & 0xfffffffc) > file_size - 8) return 0;  // safety
  if (offs && !process_object(file_base, file_size, (pobj_t)(file_base + offs))) return 0;

  // process the children (if any)
  if ((offs = object->child & 0xfffffffc) > file_size - 8) return 0;  // safety;
  if (offs && !process_object(file_base, file_size, (pobj_t)(file_base + offs))) return 0;

  return 1;
}

In this case, C gave me everything - ability to access the data quickly, ability to process loads regardless of the payload. It is quick to write and works (I didn't test it though). Why would I need anything else? Extra tools cannot help, but they have an ability to impede what is already working.

How that would be done with Ada?
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10278
  • Country: gb
    • Having fun doing more, with less
Re: 2017 Make with Ada competition
« Reply #62 on: May 20, 2017, 06:16:37 pm »
You are missing several things.

I am aware i am, that's why i asked

Quote
Demonstrably skilled programmers do continually make many mistakes with C/C++.
after all, humans make mistakes

Those with significant experience of both C and Ada usually claim Ada gives better results where it is used.

Quote
You have to compare the cost of the tools with the employment costs of the engineers (typically 2*salary).

but i would expect that since that's a more niche language tool that costs a lot for a small business, the salary for somebody that know it well would be that higher as well. bottom line, can smaller businesses in less critical areas afford the price of both tools and man power?
I assume that the goal of this competition is to increase adoption or at least make developers curious about it. Okay, where is the free compiler and debugger for my platform of choice? I am fine with some limitations so i can at least check it out
 
Quote
You have to compare the cost of the tools with the cost of making a mistake that would have been avoided if the tools had been used.
The cost to you is irrelevant
You have ignored the difficulty of proving (e.g. to a judge/jury) that you have taken all necessary steps. Common sense is irrelevant in that context.

Very true, one buy insurance before the accident. about common sense, i think that the jury's/judge common sense is very relevant, more than actual proofs, sadly

This is only my opinion, of course

I hope your placement of brackets in your programs is less error-prone than your placement of "quote" tags above! (One of the lines that you appear to write was in fact written by me).

Knowing that humans make mistakes is a reason for preferring languages that help detect and avoid some important classes of mistake.

Having free compilers/tools is very helpful, but is not sufficient. Industry inertia should never be underestimated.

General principle about insurance: on average you pay more for insurance than you get back from insurance. With that in mind...
I've never heard of any insurance for being late to market or developing poor quality products.
I suspect that buying insurance for a useful amount of product liability would be very expensive.
Yeeeeeah, i get your point. i guess i would have spotted that mistake in a forum with a WYSIWYG post editor, but i'd rather just make an error and then correct it. Nobody was harmed for this error, do you get mine?

Agreed. My point about the brackets was trivial, except that it is an illustration of how easy it is to miss a mistake. We all make mistakes; I know that only too well :(

Quote
I am not saying you all are wrong, not at all. What i'm trying to say is that i can't see how the benefits are more that the cost in my line of work. I like to learn from my mistakes and my mistakes shouldn't put people's life in danger, hopefully.
I am sure i will change my mind in the future, when i will be more eperienced... or when needed. But if i can use C, i'll use C.

Lack of experience? Probably. I won't deny it. After all, i have been earning money from programming microcontrollers for just a few years (i'm 25)
But the i-know-better attitude is not helping getting your message across

There is always a risk-reward tradeoff. In many cases the cost of mistakes is small.
You should use the best tool for the job; in some cases that will be C, in others it shouldn't be C.
What I object to is (other) people claiming that, one way or another, they catch all their mistakes.

Trying to work out what you will try to do better next time is a valuable attribute in an engineer. I've always asked job candidates that in interviews; if they don't have an answer they certainly won't get the job!

I was your age when I first used C in microcontrollers (in 1982). It worked, the customer was satisfied, but I was aware of C's limitations, I realised where I was "skating on thin ice" and started looking for tools without those limitations.

Quote
Lazyness? That plays a big role: if i can use C i will use C. I will be extra careful, no problem for me. I don't have tight development cycles nor have to work on safety critical applicatons, thank god.

But at the end of the day is lack of free and ready made tools that is stopping me or someone like me (i think) from adopting new languages.
Is there an ada compiler for dspic? AFAIK, no. And i use them extensively.
It is true that one shouldn't understimate industry inertia, but smaller players can also be more dynamic (less numbers on products and quantities, less people, less inertia from within the workplace itself) but for those places a multi thousand euro investment can't be taken lightly. That is my current situation. I can/am proposing new platforms in both software and hardware at where i work but the investment has to be justified. Having free tools for the platforms i have to use, at least for training, would have me learning these platforms.

Laziness is a poor reason :)
Mistakes can be very expensive even in non-safety critical applications.
Learning new languages is valuable, even if you never learn them in anger. Just knowing "different ways of thinking" is valuable, e.g. OOP, declarative, FSMs and event-driven architectures.

Quote
I see your point. Do you see mine?

Yes I do, with the caveats mentioned above.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10278
  • Country: gb
    • Having fun doing more, with less
Re: 2017 Make with Ada competition
« Reply #63 on: May 20, 2017, 06:20:16 pm »
IMHO you have to distinguish between two use cases for a safe programming language:
1) Use by programmers who can't program so the program doesn't work but at least it doesn't crash all the time.
2) Use by programmers who can program and like to concentrate on the task at hand instead of babysitting a programming language.
you have to distinguish between a "language" and "features that come with the compiler". language is one thing, compiler is another thing. since this thread is more toward a "language" (Ada), we should be concentrating on that, not what feature a compiler can provide. features a compiler from Borland will be different from what a Microsoft's compiler can provide. external tools is another whole different story.

I strongly suspect nctnico is more than aware of that.

However, language features can both enable and prevent compilers and toolchains from finding mistakes and reasoning about the code. And that is completely independent of specific compilers and other tools.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 1841
  • Country: ca
Re: 2017 Make with Ada competition
« Reply #64 on: May 20, 2017, 07:01:05 pm »
What I object to is (other) people claiming that, one way or another, they catch all their mistakes.

I think you're tilting at windmills. I haven't seen anyone claiming that.
 

Online Kalvin

  • Super Contributor
  • ***
  • Posts: 1793
  • Country: fi
  • Embedded SW/HW.
Re: 2017 Make with Ada competition
« Reply #65 on: May 20, 2017, 09:11:10 pm »
How that would be done with Ada?

Pretty much similar to your C implementation unless the binary file is abstracted by a simple container which will provide some information about the file itself, like the file size, so you do not have to pass that around explicitly.

Ada doesn't have restrictions which prevents from accessing the binary arrays like you are doing. But, if your file has been corrupted, the variable offs may get negative values, and you will access the data somewhere else in the stack:

Code: [Select]
if ((offs = object->sibling & 0xfffffffc) > file_size - 8) return 0;  // safety
if (offs && !process_object(file_base, file_size, (pobj_t)(file_base + offs))) return 0;

You are also assuming that int is 32-bits. Will this work correctly with 64 bit ints?

In Ada one could write pre-conditions and post-conditions which would check the that the contract is not violated. For example one pre-condition could be so that the object is within file_base and file_base + file_size and trying to access the file outsize its bound would produce an exception.

In Ada one would probably operate with unsigned integers to access the elements of the byte array, so the index cannot be negative and will be caught at runtime. Then one would assign an Access variable (similar to C pointer) to point to the struct, and access the data using that Access variable. Also, one would add a pre-condition that the index has to be divisible by 4. One can also specify that the Access is aligned to 4.

Using isolated example is a bit problematic because the benefits of the language seem to be very limited if none. But even in this small example one could write something more robust - even in C, but Ada has some built-in advantages, though.
« Last Edit: May 20, 2017, 10:32:07 pm by Kalvin »
 

Offline analogo

  • Regular Contributor
  • *
  • Posts: 80
  • Country: at
Re: 2017 Make with Ada competition
« Reply #66 on: May 20, 2017, 10:04:00 pm »
Does GNAT still require GPL for anything linked with its libraries?

GNAT does not require other sources/programs to be compiled with GPL. As the rest of GCC, it is licensed under the GPLv3 + runtime library exception: https://www.gnu.org/licenses/gcc-exception.html: "When you use GCC to compile a program, GCC may combine portions of certain GCC header files and runtime libraries with the compiled program. The purpose of this Exception is to allow compilation of non-GPL (including proprietary) programs to use, in this way, the header files and runtime libraries covered by this Exception."

In other words, GNAT/GCC itself is GPL but you can use it without problems (and without paying) to produce any program, even proprietary programs.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4348
  • Country: ch
Re: 2017 Make with Ada competition
« Reply #67 on: May 20, 2017, 10:27:09 pm »
GNAT does not require other sources/programs to be compiled with GPL. As the rest of GCC

GNAT requires a bootstrapper, which is architecture specific!

Code: [Select]
SRC_URI="ftp://gcc.gnu.org/pub/gcc/releases/gcc-${PV}/gcc-core-${PV}.tar.bz2
        ftp://gcc.gnu.org/pub/gcc/releases/gcc-${PV}/gcc-ada-${PV}.tar.bz2
        amd64? ( https://dev.gentoo.org/~george/src/gnatboot-${SLOT}-amd64.tar.bz2 )
        sparc? ( https://dev.gentoo.org/~george/src/gnatboot-${SLOT}-sparc.tar.bz2 )
        x86?   ( https://dev.gentoo.org/~george/src/gnatboot-${SLOT}-i686.tar.bz2 )"
#       ppc?   ( mirror://gentoo/gnatboot-${BOOT_SLOT}-ppc.tar.bz2 )

As you can see, forget { PPC32, PPC64, MIPS, HPPA1, HPPA2, SPARC }

Code: [Select]
2016-12-10--16-12-50---2016-12-10--19-32-20 - emerge  =dev-lang/gnat-gcc-4.9.3 - success - root
2016-12-10--20-15-36---2016-12-10--23-06-03 - emerge  =dev-lang/gnat-gcc-4.3.6 - failure - root
2016-12-13--01-42-28---2016-12-13--06-58-53 - emerge  =dev-lang/gnat-gcc-4.3.6-r1 - failure - root
2016-12-13--12-04-03---2016-12-13--12-05-42 - emerge  -K =dev-lang/gnat-gcc-4.3.5 - success - root

Also, there are some bugs, which still don't make the process to complete on some versions.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4348
  • Country: ch
Re: 2017 Make with Ada competition
« Reply #68 on: May 20, 2017, 10:31:56 pm »
but Ada has some built-in advantages, though.

And not being obliged to use the C preprocessor ( #ifdev, #else ... #define ... ) is a bonus :D
 

Offline NorthGuy

  • Super Contributor
  • ***
  • Posts: 1841
  • Country: ca
Re: 2017 Make with Ada competition
« Reply #69 on: May 20, 2017, 11:25:54 pm »
In Ada one would probably operate with unsigned integers to access the elements of the byte array, so the index cannot be negative and will be caught at runtime. Then one would assign an Access variable (similar to C pointer) to point to the struct, and access the data using that Access variable. Also, one would add a pre-condition that the index has to be divisible by 4. One can also specify that the Access is aligned to 4.

I should've declared Offs as uint32_t. It's a bug in my code. However, when you combine signed with unsigned, C uses unsigned operation, so the code still works correctly. I might've get a compiler warning on this, depending on the compiler.

So, in Ada you would declare the constraints when declaring the variables, and then the compiler would check every assignment. But if you had specified a wrong constraint in the declaration (same as I declared Offs int instead of uint32_t) then you would get all the wrong checks (same as I could get wrong comparisons if the C standard would be slightly different). Doesn't look very different so far.

What is different, is that Ada would check the conditions on all assignments, not only when it's needed. It you know the value in the variable is good, so you can skip the checks. The compiler cannot. I understand the compiler can optimise and skip some of the checks. But humans can do this better. Thus human code will produce less checks, often much less checks. Not a big deal for a small program, but this is one of mechanisms which add bloat to the code.

But even in this small example one could write something more robust - even in C, but Ada has some built-in advantages, though.

Exactly. The success depends on the one writing the code. If he uses int instead of uint32_t in C, or if he specifies a wrong constraint in Ada, the code will be buggy. Looks like switching languages won't make much difference, will it?

 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3076
  • Country: us
Re: 2017 Make with Ada competition
« Reply #70 on: May 20, 2017, 11:27:38 pm »
I would love to see someone use this contest as an excuse to re-write the Arduino environment for Due (Atmel SAM3X CM3.)  Just enough for all of the standard examples to run.   You can cheat if you want - I assume the Ada compilers in question have the ability to call functions in a lower-level language?  Then we can see exactly how much bigger/slower/etc the sketches are, how much of the code has to be "unsafe", how much ha to be written in some other language, look for advantages of the Ada version, and so on, for a whole set of pretty standard-ish embedded applications...
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9209
  • Country: my
  • reassessing directives...
Re: 2017 Make with Ada competition
« Reply #71 on: May 21, 2017, 01:44:22 am »
In Ada one would probably operate with unsigned integers to access the elements of the byte array, so the index cannot be negative and will be caught at runtime.
oh i would love to see this when it get caught in life threatening situation such as in Avionics... i would love.... but actually not, for the sake of the souls involved.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Online Kalvin

  • Super Contributor
  • ***
  • Posts: 1793
  • Country: fi
  • Embedded SW/HW.
Re: 2017 Make with Ada competition
« Reply #72 on: May 21, 2017, 05:25:34 am »
In Ada one would probably operate with unsigned integers to access the elements of the byte array, so the index cannot be negative and will be caught at runtime. Then one would assign an Access variable (similar to C pointer) to point to the struct, and access the data using that Access variable. Also, one would add a pre-condition that the index has to be divisible by 4. One can also specify that the Access is aligned to 4.

I should've declared Offs as uint32_t. It's a bug in my code. However, when you combine signed with unsigned, C uses unsigned operation, so the code still works correctly. I might've get a compiler warning on this, depending on the compiler.

So, in Ada you would declare the constraints when declaring the variables, and then the compiler would check every assignment. But if you had specified a wrong constraint in the declaration (same as I declared Offs int instead of uint32_t) then you would get all the wrong checks (same as I could get wrong comparisons if the C standard would be slightly different). Doesn't look very different so far.

What is different, is that Ada would check the conditions on all assignments, not only when it's needed. It you know the value in the variable is good, so you can skip the checks. The compiler cannot. I understand the compiler can optimise and skip some of the checks. But humans can do this better. Thus human code will produce less checks, often much less checks. Not a big deal for a small program, but this is one of mechanisms which add bloat to the code.

But even in this small example one could write something more robust - even in C, but Ada has some built-in advantages, though.

Exactly. The success depends on the one writing the code. If he uses int instead of uint32_t in C, or if he specifies a wrong constraint in Ada, the code will be buggy. Looks like switching languages won't make much difference, will it?

Yes, you are correct that changing a programming language wouldn't make a poorly designed and poorly written code any better. But in the hands of a good programmer it does make difference.

Btw, you are making an assignment in if statement, which is considered as illegal in many organizations. Yes, you are comparing signed to unsigned. Probably you will turn off also some other compiler warnings so they will not annoy you too much. You are also assuming that the endianess doesn't matter. It would be also a good thing to make the struct as packed just in case. Ada has a built-in capability to specify the endianess, so one doesn't have to decorate the code with the endianess conversion macros.
 

Online Kalvin

  • Super Contributor
  • ***
  • Posts: 1793
  • Country: fi
  • Embedded SW/HW.
Re: 2017 Make with Ada competition
« Reply #73 on: May 21, 2017, 05:29:56 am »
In Ada one would probably operate with unsigned integers to access the elements of the byte array, so the index cannot be negative and will be caught at runtime.
oh i would love to see this when it get caught in life threatening situation such as in Avionics... i would love.... but actually not, for the sake of the souls involved.

Yes, I know what you mean: It would be much better to keep on computing using invalid data, like the air speed, instead of letting the programmer to decide what to do if the exception should happen. Right?
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9209
  • Country: my
  • reassessing directives...
Re: 2017 Make with Ada competition
« Reply #74 on: May 21, 2017, 05:46:42 am »
In Ada one would probably operate with unsigned integers to access the elements of the byte array, so the index cannot be negative and will be caught at runtime.
oh i would love to see this when it get caught in life threatening situation such as in Avionics... i would love.... but actually not, for the sake of the souls involved.
Yes, I know what you mean: It would be much better to keep on computing using invalid data, like the air speed, instead of letting the programmer to decide what to do if the exception should happen. Right?
exception is certainly supported in C/C++. but we are not comfortable enough with any compiler's high level built in functions/features, so we make our own check in every loops, tuned specifically so there is no unecessary degradation in performance (aka bloatware). modular programming style is a must, so we can break down applications into smaller unit test, and we make sure every single one of it is bulletproof of any possible inputs, we test them to fail. please distinguish... we test our code/application, we are not testing the "language" or the "tool", we test the real deal. that is if... and only if... we are paid good money for it. you call that tedious? not much difference than exception handling in any languages, generic or specific.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf