General Category > General Discussion

"Code of least surprise"

(1/1)

lerno:
I think the one of the best features of C (which it shares with languages like Pascal, and in some sense Java) is that it's very clear from the code what is happening. The only thing that breaks the rule is macros.

Contrast to that to a language that is the complete opposite: Swift. In Swift, you can express opaque DSLs trivially. Overloading on return type is pretty crazy, as is the implicit conversions of C++.

I would call C a language with "code of least surprise" – what you see is what you get. If you analyse a few lines of code you can actually directly know how the execution will flow, what types variables are etc, instead of things happening implicitly "behind the scenes".

My understanding is that C2 is pretty much the same: as far as it possible no unseen, implicit code that works behind the scenes creating surprising effects (Swift, C++). If so, maybe state explicitly it in "philosophy"?

bas:
I'll make this more explicit in the documentation!

Navigation

[0] Message Index

Go to full version