Poll

Do you think hanging a program in an infinite loop is allowable under the C language term "undefined behaviour"?

Yes
21 (70%)
No
9 (30%)

Total Members Voted: 30

Author Topic: Should C language "undefined behaviour" cover crashing/hanging?  (Read 8949 times)

0 Members and 1 Guest are viewing this topic.

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #100 on: December 08, 2022, 10:14:21 pm »
I would love to hear Sherlock Holmes's thoughts on PASCAL. It was around at about the same time as C in the early adoption of PCs, and a far more 'designed' language. "Turbo Pascal" and "Turbo C" were approximately equal languages at tools, and I've used both.

Why did PASCAL not win, given its technical superiority?

My understanding is pretty much the same as this, I think this explanation fits the facts.

https://qr.ae/pvcWaV

First almost always beats best. Look at the crippled Intel CPU used in the IBM PC, the 68000 was head and shoulders above Intel, yet by comparison became like Pascal. Intel's crippled CPU was simply ready earlier, the rest is history.

Gosh, that very much differs from my recollection. Here's mine:

PASCAL predated C by a few years and was also commonly available. I remember using it on an Apple II and it was often seen in the press (e.g. Byte Magazine, Dr Dobbs, books at the bookstore...). It took over as the preferred language for introductory CompSci at University (until it got pushed out by Java in the late 90s). Its syntax was also used as the bases for most academic pseudocode you find in books of that era.

What killed Pascal was:

  • Early versions of Pascal didn't compile to native code. It ended up in a 'p-code' ( https://en.wikipedia.org/wiki/P-code_machine ) . This was great for portability, but poor for performance. You could not extract the full power of the machine - if you needed to you used something else. It valued portability above performance
  • it wasn't flexible enough. Pascal had a runtime model that was very hard to get rid of, making writing system level code very challenging. With C you pretty much abandon the runtime library and do your own thing. This made Pascal unsuited to writing low-level code like building OSes.
  • Code performance. When the first advanced optimizing C compilers came out PASCAL got left behind in performance. C's crudeness made for intermediate code that was easier to analyze and optimize in the resource constrained environments of the time. You ended up with smaller, faster code when you used C.
  • Pascal users would still need to use assembly for performance critical code. C would let you replace most of your assembly code with something that could be more easily developed and maintained. It was not at all uncommon for Pascal users to link to modules written in C code for performance reasons - much like how Python used now interface to C when needed. Most developers were of the view that if you are going to invest time implementing your critical code in C, you may as well use it for the rest of your codebase.

This was all at a time where business applications were largely written in something else - either in COBOL or one of the many 4GL development tools like DBase, FoxPro, DataFlex, Magix, Pick, etc. Almost nobody was writing business applications in C.

His article openly mentioned p-code. He also explained that C compiler source was freely available in universities opening the door to retargeting, Pascal compiler source wasn't as easy to come by, people had to pay for it.

The p-code was not Pascal, the compiler turned the source into pascal but could have turned it into a CPU specific object code, many Pascal compilers later did so.

So Pascal's "performance" isn't anything to do with the language itself but the compiler and code generator and optimizer.  The reasons that Pascal is less prevalent than C is nothing to do with any linguistic qualities but circumstances.

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11535
  • Country: my
  • reassessing directives...
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #101 on: December 08, 2022, 10:30:58 pm »
The reasons that Pascal is less prevalent than C is nothing to do with any linguistic qualities but circumstances.
define circumstances. if its including the fact that pascal is technically less capable than C, then you are right. nobody cares about linguistic if its capable enough.
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #102 on: December 08, 2022, 10:54:18 pm »
The reasons that Pascal is less prevalent than C is nothing to do with any linguistic qualities but circumstances.
define circumstances. if its including the fact that pascal is technically less capable than C, then you are right. nobody cares about linguistic if its capable enough.

I mean events, decisions, trends like Unix (which included C compilers) being given away free to universities, universities using that as a basis for some courses, students seeing examples of OS schedulers, utilities and network code all written in C and so on. Circumstances like Sun adopting Unix as the basis for their software strategy. As that person stated, Unix was developed by Bell Labs, which was part of a government-protected monopoly. The Unix OS and the multitude of tools it has were all written in C, therefore wherever Unix will go, C must follow.

Anything you can write in C you can write in Pascal or C# or PL/I or COBOL or APL, yes, even assembler - they are all examples of Turing machines.

So if two languages can each be used to convert some input into some output, then how can you compare the languages? How do you define "technically capable"? What is all this "linguistics" stuff? (The joke here is on you, because you can't define "technically capable" without referring to linguistic properties !  :-DD )

nobody cares about linguistics if the language is capable enough.

One of the most amusing oxymorons I've seen this year!

What if we counted the number of buffer overrrun bugs per 1,000 lines of code, for C and Pascal across some reasonable sized sample, would that be a meaningful metric perhaps? an indicator of technical capability?

There is no input text that can be converted to some output only by using C, if you know of one, please share it.



« Last Edit: December 08, 2022, 11:31:01 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Online Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11535
  • Country: my
  • reassessing directives...
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #103 on: December 09, 2022, 05:53:30 am »
nobody cares about linguistics if the language is capable enough.
One of the most amusing oxymorons I've seen this year!
you dont want to get an insult when i ask if its your place to comment C? (which clearly you are not!) but yet you are happy to give direct insult to others (in this case... me) when we give you our opinion (when you have nothing else better point or recent news to say)... how ironic! the new X generation on the street! that we worth ignoring! ;D

I mean events, decisions, trends like Unix (which included C compilers) being given away free to universities, universities using that as a basis for some courses, students seeing examples of OS schedulers, utilities and network code all written in C and so on. Circumstances like Sun adopting Unix as the basis for their software strategy. As that person stated, Unix was developed by Bell Labs, which was part of a government-protected monopoly. The Unix OS and the multitude of tools it has were all written in C, therefore wherever Unix will go, C must follow.
thats the history lesson and you got so left behind.. i ask you about today's events/circumstances... even though there are ecosystem such as borland delphi or embarcadero, why no body cares (or only minority?) to make another latest extension/development like free tools based on pascal language? or its structure/idea etc... at least not as popular as C/C++? there is no pascal++ to support operator overloading, polymosphism/template and i can find more... so bye bye pascal... your history lesson is a dissapointment/boring esp from someone who claimed a proficient programmer who built a big compiler... ;D
« Last Edit: December 09, 2022, 06:05:24 am by Mechatrommer »
Nature: Evolution and the Illusion of Randomness (Stephen L. Talbott): Its now indisputable that... organisms “expertise” contextualizes its genome, and its nonsense to say that these powers are under the control of the genome being contextualized - Barbara McClintock
 
The following users thanked this post: JPortici

Offline mfro

  • Regular Contributor
  • *
  • Posts: 207
  • Country: de
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #104 on: December 09, 2022, 06:45:37 am »
Anything you can write in C you can write in Pascal or C# or PL/I or COBOL or APL
Actually, you can't. At least not with the same level of control as you have in C. With the exception of C# (that has the same), none of the languages has any equivalent to the volatile expression to control the exact point of register loads and stores.

That either leaves you with the choice of not having certain optimisations or the inability to reliably write interrupt/exception handlers.
Beethoven wrote his first symphony in C.
 
The following users thanked this post: newbrain, DiTBho

Offline DiTBho

  • Super Contributor
  • ***
  • Posts: 3796
  • Country: gb
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #105 on: December 09, 2022, 08:14:56 am »
Anything you can write in C you can write in Pascal or C# or PL/I or COBOL or APL, yes, even assembler - they are all examples of Turing machines.

time/effort independent assumption -> human being resources are limited -> wrong.
The opposite of courage is not cowardice, it is conformity. Even a dead fish can go with the flow
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #106 on: December 09, 2022, 02:33:38 pm »
Anything you can write in C you can write in Pascal or C# or PL/I or COBOL or APL
Actually, you can't. At least not with the same level of control as you have in C. With the exception of C# (that has the same), none of the languages has any equivalent to the volatile expression to control the exact point of register loads and stores.

That either leaves you with the choice of not having certain optimisations or the inability to reliably write interrupt/exception handlers.

First, do you agree that we can't compare languages without talking about programming language syntax and semantics? We can't say C has a greater "level of control" unless we define what that means in linguistic terms? unless we can quantitatively measure that?

Second, my question was is there an input that can be consumed to produce an output that cannot be achieved with another language consuming the same input, and if there is an example.

I think the answer to that is "no", if you disagree then we can explore that if you want.

As for "volatile" it typically has different semantics in different languages, so right away its hard to compare languages on that basis. More importantly "volatile" is nothing to with the language, it is simply a way of influencing the code optimizers and optimizers are an implementation matter not a language issue.

Volatile is a way of saying to the optimizer "please don't rewrite these parts of my code, please ensure the codes does exactly what I wrote".









« Last Edit: December 09, 2022, 02:37:36 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline mfro

  • Regular Contributor
  • *
  • Posts: 207
  • Country: de
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #107 on: December 09, 2022, 03:19:26 pm »
Anything you can write in C you can write in Pascal or C# or PL/I or COBOL or APL
Actually, you can't. At least not with the same level of control as you have in C. With the exception of C# (that has the same), none of the languages has any equivalent to the volatile expression to control the exact point of register loads and stores.

That either leaves you with the choice of not having certain optimisations or the inability to reliably write interrupt/exception handlers.

First, do you agree that we can't compare languages without talking about programming language syntax and semantics? We can't say C has a greater "level of control" unless we define what that means in linguistic terms? unless we can quantitatively measure that?

Umm, no. First and foremost, I need a language that suits my needs. A programming language is a tool and tools aren't rated by beauty contest, the only measure that counts is if it they get the job done.

Second, my question was is there an input that can be consumed to produce an output that cannot be achieved with another language consuming the same input, and if there is an example.

I think the answer to that is "no", if you disagree then we can explore that if you want.
That question is nonsense, IMHO. What you request is us to prove that there are languages that are not Turing complete. By definition, programming languages have to be Turing complete or they don't deserve that designation. I won't discuss if a rose is a rose.

As for "volatile" it typically has different semantics in different languages, so right away its hard to compare languages on that basis. More importantly "volatile" is nothing to with the language, it is simply a way of influencing the code optimizers and optimizers are an implementation matter not a language issue.

Volatile is a way of saying to the optimizer "please don't rewrite these parts of my code, please ensure the codes does exactly what I wrote".

Volatile has exactly one single semantic in C and C[derived] languages. And it provides required functionality to write proper exception handlers and multithreaded interprocess communication. C is *the* system programming language, if you like it or not.

I like PASCAL (and Modula II and Oberon), I even like Ada, but (except maybe for Ada, that indeed provides volatile) I'd never come up with the idea of attempting to write any code that directly needs to interact with hardware (or deal with multiple processors) in one of these languages.

« Last Edit: December 09, 2022, 03:33:20 pm by mfro »
Beethoven wrote his first symphony in C.
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #108 on: December 09, 2022, 03:24:31 pm »
nobody cares about linguistics if the language is capable enough.
One of the most amusing oxymorons I've seen this year!
you dont want to get an insult when i ask if its your place to comment C? (which clearly you are not!) but yet you are happy to give direct insult to others (in this case... me) when we give you our opinion (when you have nothing else better point or recent news to say)... how ironic! the new X generation on the street! that we worth ignoring! ;D

I apologize if that seemed insulting.

I was trying emphasize though how being dismissive of language theory, principles and so on, is self contradictory. Saying you want to discuss the merits of C as a language while at the same time sidelining formal aspects of language design, grammars and so on, is self contradictory, that's the point I wanted to make.

I mean events, decisions, trends like Unix (which included C compilers) being given away free to universities, universities using that as a basis for some courses, students seeing examples of OS schedulers, utilities and network code all written in C and so on. Circumstances like Sun adopting Unix as the basis for their software strategy. As that person stated, Unix was developed by Bell Labs, which was part of a government-protected monopoly. The Unix OS and the multitude of tools it has were all written in C, therefore wherever Unix will go, C must follow.

Thats the history lesson and you got so left behind.. i ask you about today's events/circumstances... even though there are ecosystem such as borland delphi or embarcadero, why no body cares (or only minority?) to make another latest extension/development like free tools based on pascal language? or its structure/idea etc... at least not as popular as C/C++? there is no pascal++ to support operator overloading, polymosphism/template and i can find more... so bye bye pascal... your history lesson is a dissapointment/boring esp from someone who claimed a proficient programmer who built a big compiler... ;D

You actually asked me to "define circumstances", you wanted to know what I meant by the term and so I told you. It wasn't a "history lesson" it was a clarification of what I meant by "circumstances". The rest of that paragraph makes no sense to me, it sound like you disagree with something I might have said but I do know what that is.







« Last Edit: December 09, 2022, 04:28:08 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #109 on: December 09, 2022, 03:46:15 pm »
Anything you can write in C you can write in Pascal or C# or PL/I or COBOL or APL
Actually, you can't. At least not with the same level of control as you have in C. With the exception of C# (that has the same), none of the languages has any equivalent to the volatile expression to control the exact point of register loads and stores.

That either leaves you with the choice of not having certain optimisations or the inability to reliably write interrupt/exception handlers.

First, do you agree that we can't compare languages without talking about programming language syntax and semantics? We can't say C has a greater "level of control" unless we define what that means in linguistic terms? unless we can quantitatively measure that?

Umm, no. First and foremost, I need a language that suits my needs. A programming language is a tool and tools aren't rated by beauty contest, the only measure that counts if it they get the job done.

I see, so you disagree, OK show me the data processing test that cannot be solved by another language. Yes a language should meets one's need, no argument with that. Yes a programming language is a tool, no argument with that. If you can't define how languages are compared then how do you know that C is the best choice?

What is it about a programming language specifically, that helps you "get the job done"? You mentioned "volatile" and that's fine, I pointed out though that that's not a matter of language, its more about how a language is implemented.


Second, my question was is there an input that can be consumed to produce an output that cannot be achieved with another language consuming the same input, and if there is an example.

I think the answer to that is "no", if you disagree then we can explore that if you want.
That question is nonsense, IMHO. What you request is us to prove that there are languages that are not Turing complete. By definition, programming languages have to be Turing complete or they don't deserve that designation. I won't discuss if a rose is a rose.

Well if a program written in C cannot do any more than a program written in other languages then how can you compare languages? I already suggested one possible metric, the frequency of buffer overrun bugs as a function of language, you never commented on that idea.


As for "volatile" it typically has different semantics in different languages, so right away its hard to compare languages on that basis. More importantly "volatile" is nothing to with the language, it is simply a way of influencing the code optimizers and optimizers are an implementation matter not a language issue.

Volatile is a way of saying to the optimizer "please don't rewrite these parts of my code, please ensure the codes does exactly what I wrote".

Volatile has exactly one single semantic in C and C[derived] languages. And it provides required functionality to write proper exception handlers and multithreaded interprocess communication. C is *the* system programming language, if you like it or not.

I like PASCAL (and Modula II and Oberon), I even like Ada, but (except maybe for Ada, that indeed provides volatile) I'd never come up with the idea of attempting to write any code that directly needs to interact with hardware (or deal with multiple processors) in one of these languages.

That's all well and good but once again "volatile" pertains to the implementation of a language not the language itself. Furthermore, saying "Volatile has exactly one single semantic in C" is quite simply untrue, I quote: (emphasis mine)

Quote
In C, and consequently C++, the volatile keyword was intended to

o - allow access to memory-mapped I/O devices
o - allow uses of variables between setjmp and longjmp
o - allow uses of sig_atomic_t variables in signal handlers.

While intended by both C and C++, the C standards fail to express that the volatile semantics refer to the lvalue, not the referenced object. The respective defect report DR 476 (to C11) is still under review with C17.[2]

Here is that defect report. Here is a quote too, from it:

Quote
The following sections discuss the C semantics of the volatile keyword and show that they neither support existing practice nor, we believe, reflect the intent of the committee when they were crafted.

It's meaning varies, it has a different meaning in C# a different meaning in Java and so on.




« Last Edit: December 09, 2022, 03:57:22 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline artag

  • Super Contributor
  • ***
  • Posts: 1061
  • Country: gb
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #110 on: December 09, 2022, 03:57:26 pm »
"printf" was/is a good example here, in this forum  ;D
(we tried to get rid of it, but ...)

Who did ?

I never saw anything remotely as useful and usable as printf.
Meanwhile, it's been made somewhat safer by having the compiler understand it instead as well as the runtime, though that strikes me as poor layering. Perhaps the feature itself is poorly layered too. Arguably the semantics of text formatting itself doesn't split neatly (we don't construct sentences in english hierarchicly).

There was, of course, the laughable iostream crap. A clumsy, unfunctional, hard to read, even more poorly layered and poorly laid out demonstration of operator overloading. Very much a candidate for 'we could, rather than we should, so we did'.

Any other examples ?
« Last Edit: December 09, 2022, 04:10:58 pm by artag »
 

Online Marco

  • Super Contributor
  • ***
  • Posts: 6694
  • Country: nl
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #111 on: December 09, 2022, 04:49:03 pm »
People don't realize how much of a technological achievement Rust is.

Rust reminds me a lot of Haskell, the code hurts my head but a lot of people I can readily recognize as smarter than me are adopting it. Has more industry adoption than Haskell ever had though, even if it's mostly just taking Google's CrosVM and repurposing it.

I'm not sure the industry has enough high IQ coders to make good use of it.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19280
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #112 on: December 09, 2022, 05:07:31 pm »
People don't realize how much of a technological achievement Rust is.

Rust reminds me a lot of Haskell, the code hurts my head but a lot of people I can readily recognize as smarter than me are adopting it. Has more industry adoption than Haskell ever had though, even if it's mostly just taking Google's CrosVM and repurposing it.

I'm not sure the industry has enough high IQ coders to make good use of it.

That latter question is extremely pertinent w.r.t. C.

If language X is safer (whatever that might mean), then arguably you can get away with X programmers having a lower "IQ".
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 Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #113 on: December 09, 2022, 05:18:09 pm »
People don't realize how much of a technological achievement Rust is.

Rust reminds me a lot of Haskell, the code hurts my head but a lot of people I can readily recognize as smarter than me are adopting it. Has more industry adoption than Haskell ever had though, even if it's mostly just taking Google's CrosVM and repurposing it.

I'm not sure the industry has enough high IQ coders to make good use of it.

I've read about Rust, it was refreshing, but a few days ago I read this too, the guy is clearly a seasoned MCU engineer too.

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #114 on: December 09, 2022, 05:36:37 pm »
This in particular has now caught my attention:

Quote
Zig manages to provide many of the same features with a single mechanism - compile-time execution of regular zig code. This comes will all kinds of pros and cons, but one large and important pro is that I already know how to write regular code so it's easy for me to just write down the thing that I want to happen.

From here.

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #115 on: December 09, 2022, 07:58:14 pm »
Simple set theory says C is more than some other languages.

C gives you the ability to write a whole class of programs that are outside of what can be written in 'safe' language, or a highly managed runtime environment - those with memory leakage, smashed stacks and other "bad stuff". The set of possible programs achievable in C has to be larger than a 'safe' programming language. Most would argue that these programs sit outside of the C standards, but it is what it is.

Most of the time the overreach is not a good thing - but sometimes the ability to shoot yourself in the foot in a very controlled manner is important. Especially when directly controlling hardware, or OS HAL type work.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #116 on: December 09, 2022, 08:09:14 pm »
Simple set theory says C is more than some other languages.

C gives you the ability to write a whole class of programs that are outside of what can be written in 'safe' language, or a highly managed runtime environment - those with memory leakage, smashed stacks and other "bad stuff". The set of possible programs achievable in C has to be larger than a 'safe' programming language. Most would argue that these programs sit outside of the C standards, but it is what it is.

Most of the time the overreach is not a good thing - but sometimes the ability to shoot yourself in the foot in a very controlled manner is important. Especially when directly controlling hardware, or OS HAL type work.

Several people in this and related threads keep saying the language has great support for "directly controlling hardware" and "systems programming" yet I've still not seen any concrete examples of such features, features that other languages presumably don't have.

The language certainly can be used for manipulating hardware, and indeed is used for that a great deal, but that doesn't mean it is good at doing that, or has some special features designed for doing that.

« Last Edit: December 09, 2022, 08:14:09 pm by Sherlock Holmes »
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #117 on: December 09, 2022, 08:38:48 pm »
This in particular has now caught my attention:

Quote
Zig manages to provide many of the same features with a single mechanism - compile-time execution of regular zig code. This comes will all kinds of pros and cons, but one large and important pro is that I already know how to write regular code so it's easy for me to just write down the thing that I want to happen.

From here.

That feature is nice.

 

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14297
  • Country: fr
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #118 on: December 09, 2022, 08:43:53 pm »
A language that is both "safe", good at high-level stuff, and also very nice for low-level stuff: Ada. Anyone serious about designing programming languages should at least have a look at it IMHO.

 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #119 on: December 09, 2022, 09:43:34 pm »
A language that is both "safe", good at high-level stuff, and also very nice for low-level stuff: Ada. Anyone serious about designing programming languages should at least have a look at it IMHO.

That's a good point, I've neglected Ada, just speed-read a few articles, time for an in-depth look.

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #120 on: December 09, 2022, 09:49:24 pm »
Regarding Ada:

Quote
One important distinction between Ada and a language like C is that statements and expressions are very clearly distinguished. In Ada, if you try to use an expression where a statement is required then your program will fail to compile. This rule supports a useful stylistic principle: expressions are intended to deliver values, not to have side effects.

Music to my ears...
“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #121 on: December 09, 2022, 09:50:41 pm »
A language that is both "safe", good at high-level stuff, and also very nice for low-level stuff: Ada. Anyone serious about designing programming languages should at least have a look at it IMHO.

So why aren't we all using Ada for programming these microcontrollers? What's been the issue here?

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 

Offline nfmax

  • Super Contributor
  • ***
  • Posts: 1556
  • Country: gb
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #122 on: December 09, 2022, 10:11:07 pm »
A language that is both "safe", good at high-level stuff, and also very nice for low-level stuff: Ada. Anyone serious about designing programming languages should at least have a look at it IMHO.

So why aren't we all using Ada for programming these microcontrollers? What's been the issue here?

Historically, at least, the cost of compilers. But then that used to apply to C as well
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 19280
  • Country: gb
  • Numbers, not adjectives
    • Having fun doing more, with less
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #123 on: December 09, 2022, 10:22:57 pm »
A language that is both "safe", good at high-level stuff, and also very nice for low-level stuff: Ada. Anyone serious about designing programming languages should at least have a look at it IMHO.

So why aren't we all using Ada for programming these microcontrollers? What's been the issue here?

In the late 70s and early 80s you bought an expensive proprietary minicomputer and expensive proprietary operating system. Some expense could be saved in an university by using Unix.

Students familiar with Unix escaped into companies, where they "bought what they knew" from companies like Microsoft (yes, their first operating system was Xenix, a Unix variant).

If you had Unix, you automatically had a free C compiler.

Ada was becoming available at the same time, but it was developed to sell to the military and priced accordingly.
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 Sherlock Holmes

  • Frequent Contributor
  • **
  • !
  • Posts: 570
  • Country: us
Re: Should C language "undefined behaviour" cover crashing/hanging?
« Reply #124 on: December 09, 2022, 10:34:50 pm »
Right but its free now, GNAT...

“When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.” ~ Arthur Conan Doyle, The Case-Book of Sherlock Holmes
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf