Re:Programming Is Hard
by unnouinceput on Wednesday September 20, 2023 @02:14AM
(#37580937)
Something like that would fail the code review at any large organization. Why? Because ternary operator is hard for maintenance purposes so the reviewer would simply ask to use if..else syntax instead. I gather you never worked in such organization.
Re:Programming Is Hard
by thewakalix on Wednesday September 20, 2023 @02:37AM
(#37581097)
That is not the ternary operator.
But following the setting of the gp comment, that operator would fail code review as well. Because the book of sacred rituals says so.
Not the OP and not a fan of ternary operations, but if programming were left to large organizations we would still be writing .asp pages.
Which is to say that inovation happens only when you try to do stuff just a little different each time, so I’d say that code reviews as currently implemented at those big organizations is against long-term programming-related innovation.
This is an interesting idea- I'm not sure I understand it fully though. Do you have much luck with static type analysis? I find in Python, nothings ever certain, but mypy with good type hints solves a lot of these kind of None based shenanigans.
I have heard about mypy but haven't seriously used it. Type hinting has helped a lot (basically you'll end up writing Python like it's Rust), but something like the Maybe monad (my example above) would reduce a lot of boilerplate.
define "bug free". In Python, I've been reimplementing monads recently. It's such a shame that Python still doesn't have Null/None propagation. After each obtained result and before using it in the next chain, I have to run a series of sanity checks (is it Null or not, etc.) which should be resolved automatically by the language. Alas, most people don't care.