Author Topic: "Code of least surprise"  (Read 11616 times)

lerno

  • Full Member
  • ***
  • Posts: 247
    • View Profile
"Code of least surprise"
« on: November 08, 2018, 03:37:54 PM »
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

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Re: "Code of least surprise"
« Reply #1 on: November 09, 2018, 08:35:43 PM »
I'll make this more explicit in the documentation!