Hacker News new | comments | show | ask | jobs | submit login

> Undefined behavior is the result of a design decision: the refusal to systematically trap program errors at one particular level of a system. The responsibility for avoiding these errors is delegated to a higher level of abstraction.

Sounds a bit like an argument for Checked Exceptions: If you're going to write code for one layer of abstraction, your code should only emit errors that match its own tier. (And not raw naked primeval stuff occurring many layers down.) ( http://imgur.com/iYE5nLA )




It's also not entirely true.....undefined behavior also exists because it's a serious pain to define every detail of a language. The only language I know of that is completely defined (other than toy languages) is ML......and the authors felt the work to completely define it wasn't entirely worth the effort.


Java is also completely defined and pretty completely specified. But don't confuse unspecified behavior with undefined behavior. Unspecified behavior means that one of several things can happen, but it's unspecified which. Undefined behavior means that absolutely anything can happen, including things that are not part of normal application behavior.


> Unspecified behavior

I feel like "unspecified" still sounds too lax. How about "implementation-defined"?

I'm thinking of scenarios like: "When this occurs, The Java Virtual Machine implementation may choose to either X or Y. If it does Y, then it shall throw a Z exception."


> and the authors felt the work to completely define it wasn't entirely worth the effort.

Can you add a source link? I would be interested in looking it up.



Eiffel is also completely defined.

It is one of the few languages that has denotational semantics as part of the language definition.

It was also one of the first languages to fix the null reference problem (called Void-safety in Eiffel speak).

Had the compilers been a bit cheaper instead of targeted to the enterprise customers, maybe many more would be enjoying writing safe native compiled software on Eiffel.


And HTML. Every sequence of bytes is an HTML document with some defined meaning. It may not be valid HTML (the spec does define parse errors), but it will parse to the same representation in all conforming parsers.




Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: