News for hackers. Stuff that matters.
Re:Porting 4.5K lines of C to Go by hinkley on Saturday August 05, 2017 @02:58PM (#14937278)
I managed to go about 15 years without using the ternary operator. Pretty much the only time it's really good at what it does is for assignments, and I've started using it a bit myself.

However, the old discomforts come up pretty frequently. I find people slipping functions into both the right hand and left hand side. And once you do that, you really should push it into a new function. Especially if you have any plans for testing.

Most compilers are pretty good at inlining things like that, and at any rate there are almost always bigger performance problems than function call overhead. In fact, one of my big tricks is that a function that consists of a weird but fast algorithm is generally tolerated by your coworkers better than just dropping it into the middle of a block of code. And knowing they could easily revert the change (because it's only one commit and one function body!) if it starts to annoy them also helps.

tl;dr: Just like comments in the middle of a function reveal a missing function, a ternary operator probably means the same.

There are no comments on this comment yet.