User: Password:
|
|
Subscribe / Log in / New account

Reitter: Answering the question: "How do I develop an app for GNOME?"

Reitter: Answering the question: "How do I develop an app for GNOME?"

Posted Feb 6, 2013 22:00 UTC (Wed) by k8to (subscriber, #15413)
In reply to: Reitter: Answering the question: "How do I develop an app for GNOME?" by renox
Parent article: Reitter: Answering the question: "How do I develop an app for GNOME?"

I disagree.

It's sort of a crazy language to the programmer but the cause is not premature optimization, but rather an attempt to be a very thin layer of helpful syntax over the system's native behavior. Since systems behave differently, you don't know what will happen, so it's undefined.

You can argue this was a bad design goal, but that's a different kind of error.


(Log in to post comments)

Reitter: Answering the question: "How do I develop an app for GNOME?"

Posted Feb 7, 2013 6:00 UTC (Thu) by khim (subscriber, #9252) [Link]

Since systems behave differently, you don't know what will happen, so it's undefined.

If systems behave differently then it begs for “implementation-defined behavior”, not for “undefined behavior”. Much simpler and safer to deal with these. Indeed, the fact that C has so many “undefined behaviors” is a premature optimization - but the fact that someone made such error many years before is not an excuse to propagate this madness in newer, more modern languages.

Reitter: Answering the question: "How do I develop an app for GNOME?"

Posted Feb 7, 2013 9:24 UTC (Thu) by ncm (subscriber, #165) [Link]

Implementation-defined behavior is worse than undefined behavior. The next version of the implementation will define a different behavior, and your previously well-defined program becomes wrong.

Reitter: Answering the question: "How do I develop an app for GNOME?"

Posted Feb 7, 2013 11:46 UTC (Thu) by khim (subscriber, #9252) [Link]

You assume people write program to the spec. Well, newsflash to you: they don't. The very fact that both GCC and LLVM are trying (and failing) to catch a lot of undefined behaviors shows that people don't write to the spec. People write code, they write tests, if they pass - they are happy. That's it.

If program triggers implementation-defined behavior then tests are usually enough to catch problems (because compiler may do different thing from what the programmer expects but it consistently does different thing) while with undefined behavior compiler is absolutely free to do one thing in one case and completely different thing in another case. Which means that program may suddenly crash after compiler upgrade - and you have no idea why.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds