Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> a = b[i++]

You can't be serious. How is this ambiguous in the slightest? Assuming that you actually know some rudimentary C.



Because a = b[++i] means something different. It's a dense and unecessary shortcut.


At the risk of being downvoted again (for which I don't much care, but it does say much about the mindset...), is it so very much unreasonable to ask of programmers using a language, and more importantly a language they will be using very frequently, to just learn the language!?!?

The amount of dumbing-down that I've seen happen to programming is already beyond ridiculous. You should definitely look at APL, Lisp, or some of the other more expressive languages out there if you think anything beyond the equivalent of glorified Asm (one statement per line, one operation per statement, one use per variable...) is "dense and unecessary[sic] shortcut".

I think this a relevant article to start understanding the opposite point of view: https://news.ycombinator.com/item?id=13565743


You're absolutely right that developers should know this stuff. But that's to some degree the wrong point to make. When considering the maintainability and correctness of the codebase, "clever" hacks are often not desirable. Nowadays, there's no performance gain to be had by indulging in such tricks; the optimiser will do the right thing for both cases.

The problem for me here is not that it's "too complex", but that it's ambiguous even for experts with a casual glance. It makes perfect sense right now after you've written it, but months or years later, the person reading this while doing some maintenance or debugging might glance over and not see the subtlety of pre- vs post-increment while they are busy with other tasks and deadlines. It does make sense to avoid such pitfalls, where possible.


This has nothing to do with what I'm saying. You obviously write code without thinking about people reading it later. It doesn't matter if the reader knows a[i++] and a[++i]. What matters is that you can easily make a mistake here, and the reader can easily not see the mistake or misunderstand what you meant to write. Compactness is the enemy of clairity.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: