CppCon 2018: Jon Kalb “This is Why We Can’t Have Nice Things”

preview_player
Показать описание


Lightning Talk


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

"If you must remain consistent with the past, you can never improve" <- and that's how C++ turned into the monster it is today

chopsueysensei
Автор

I was west const beliver, but without knowing what is the reasons behind this (and I did not want to know maybe honestly). This has opened my mind, million thanks for that

nwhous
Автор

I've always considered myself West const, but his comment about reading it backwards actually made a lot of sense.

nivenfres
Автор

I didn't get how to read east-const until I learned to read it right to left. once I did that, it became very clear why the auto-complete for function signatures always writes T const& and not const T&. Because the object being passed in is a REFERENCE to Const T. literally what "T const &" says, if you read it Right to Left :-)

MatkatMusic
Автор

This is only an issue if you find the full rules for const placement too complicated. Personally I don't and so I prefer writing code which reads like English language whenever possible, which means west const. The inconsistency is not an issue because I don't find the rules too complicated at all. Note, I'm not even a native English speaker.

Maybe it's a cultural thing though. In slavic languages (my native Polish language is one of them) the order of most words in a sentence doesn't matter because the endings of the words express relations between them, so I'm naturally more used to using some actual rules rather than trying to glance the meaning of the whole thing from the order of words. For example, I found your example with const WidgetPtr utterly ridiculous. If your native language is a one where order matters I propose that you try to get used to thinking in terms of actual rules before you bury west const. Just assume for a few minutes that you don't have any prior knowledge and interpret a few declarations using the rules as the source of truth. I think it should become very easy in a few minutes. The rules are unambiguous after all.

piotrarturklos
Автор

When is "-Wconst-west" comming? With that we could use something like "-Werror=const-west" to transition.

xavierthomas
Автор

This is also why I'm annoyed when I see people write "int* x" instead of "int *x". Like west-const, it expresses how people _wish_ types were parsed rather than how they are _actually_ parsed, and as a result breaks down in more complicated cases.

MatthijsvanDuin
Автор

I still feel east const weird, however, I reckon that it's provably more useful, whenever you want to make several replaces in W.I.P. (working in progress) f()s: the east const is near the reference/pointer, so it's more information togheter, and thus it's safer for replacements in files.

MrAbrazildo
Автор

I agree.. partially, it's not beyond me to realise that if there is nothing to the left of const it must refer to the right. My issue is that this is small syntactic preference which I really haven't time to worry about given the other problems in c++ e.g. trying to understand convoluted template declarations :S

fredhair
Автор

Just change it whenever you see it in the code base. Doesn't hurt to do so when you update/rewrite some parts of the code

codewing
Автор

I'm pretty well convinced by the east-const arguments, but all that ingrained behaviour makes it feel wrong.
Going to be a while before I can write east-const without it feeling all kinds of wrong.

MSheepdog
Автор

Hey ; other people _do_ think C++ syntax is a kludge in places. Glad it isn't just me after all.
Now personally I _don't_ like east const, but having const self-consistent would be nice.

Hold it - if C++ source is read right-to-left, how does [] signal a lambda?

williamchamberlain
Автор

I completely agree! East const is much more logic and consistent.

BenjaminBuch
Автор

Interesting that the speaker mentions Dan Saks. Back in the day he also advocated the Whitesmiths bracketing style, arguing that the brackets are part of the block they wrap, so they should have the same indentation as the block. And here the speaker again advocates a coding style because it's more consistent. Well, it was definitely wrong for brackets and it could be wrong here - the human mind has the capacity to contain such inconsistency, and coding style is about presenting code to fellow programmers in a way familiar to them, so that they can focus on the substance (avoid making their eyes bleed"). As long as a certain style is not more prone to bugs (such as the style of avoiding brackets if you don't have to), it's just a style. Logic doesn't apply.

urisimchoni
Автор

east-const ftw; seriously though, where can I get east-cont bands without going to such a conference?

parnmatt
Автор

Somehow I knew it was about east vs west const after see the title of this talk.

echosystemd
Автор

Recently I changed my const style to Kenny Kerr's const style. He is from Microsoft. So I use east const now.

evgenytarasov
Автор

except " unsigned char const c('\0'); " reads stupidly in both English and declarative order.

schulmastery
Автор

East Const!!! I wish compilers had warning for West Const.

myusernameislongerth
Автор

East const and convoluted rules is more elite. And that is what matters in cpp. If you're not leet, you're not cpp programmer.

hr