24 ms·
> "The other thing that you shouldn't do, even though C/C++ allows it, is pointer arithmetic. Again, it's one of those epiphany things C programmers remember fr
by xtrapolate 8y ago
> "The other thing that you shouldn't do, even though C/C++ allows it, is pointer arithmetic. Again, it's one of those epiphany things C programmers remember from their early days. It's something they just couldn't grasp until one day they did, and then they fell in love with it. Except it's bad. The reason you struggled to grok it is because it's stupid and you shouldn't be using it. No other language has it, because it's bad."
Honestly, this is a pointless rant. "Do this, but don't do that (because that's stupid)".
> "No other language has it, because it's bad"
The reason you "don't have pointer arithmetic in other languages" is - it's been abstracted away from you, for your convenience, so that you can just concentrate on your business logic and not have to worry about the rest. You may not deal with pointer arithmetic, but the people developing your JVM/CPython/V8/Chakra sure do. Author is simply ranting about the possibility of abusing/misusing the mechanisms offered by C/C++.
- zwkrt 8y agoProgramming as a profession is strange because we each do such different things but all tools are available to us all the time. Imagine if this were true in the physical world; you would read arcticles written by accountants like "Dynamite Considered Harmful" with rebuttals titled "Why Dynamite Matters" by construction engineers...
- sam0x17 8y agoThis is fantastically imaginative. I love it.
- zzzeek 8y agothis is the most genius thing I've ever read on hacker news.
- xtrapolate 8y agoIt's almost as if things aren't really black or white, there's usually plenty of grey in-between. Things like use-cases, scenarios, trade-offs, intricacies. I find it awkward that a security shop would publish an article using that language - I would personally be embarrassed.
- jolmg 8y ago> I would personally be embarrassed The rest of the comment is good, it adds to the argument, and I even agree with it, but there is no reason for this to be here. It doesn't add anything; it's just like calling names. From the HN guidelines: > Don't be snarky. > When disagreeing, please reply to the argument instead of calling names. "That is idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3." EDIT: To be downvoted like so for reminding people of the guidelines, HN sure is changing. I guess no good thing lasts forever.
- deleted 8y ago[deleted]
- taneq 8y agoYou see this all the time here on HN. "Interpreted languages are useless" coming from the systems and embedded people. "You can't call yourself a developer if you're not an expert in [FOTM web framework]" from the web devs. "Mutability is evil and reassigning variables is a sign of incompetence" from the functional programming sect.
- thwd 8y agoPointer arithmetic is abstracted away for _safety_, not convenience. You can read about in e.g. Go's FAQ. https://stackoverflow.com/questions/32700999/pointer-arithmetic-in-go https://stackoverflow.com/questions/32700999/pointer-arithme...
- mixmastamyk 8y agoOr perhaps safety and convenience.
- mikeash 8y agoPointer arithmetic can be perfectly safe. C doesn’t implement it safely but that doesn’t mean other languages couldn’t.
- vmchale 8y agoFunnily enough, ATS has pointer arithmetic and it can be safe if you declare the appropriate types. It seems kind of nuts to say array indexing isn't just a fancier version of pointer arithmetic.
- xtrapolate 8y ago> It seems kind of nuts to say array indexing isn't just a fancier version of pointer arithmetic. I agree.
- zzzcpan 8y agoArray indexing is __bounds checked__ pointer arithmetic. But not in C.
- deleted 8y ago[deleted]
- thwd 8y agoArray-indexing in C and C++ _is_ pointer arithmetic! It's syntactic sugar. Array-indexing in safe languages is bound checked iff the compiler can't prove the index value to always be in-bounds.
- mikeash 8y agoIn case anyone doesn’t already know, this isn’t a figure of speech. array[5] literally translates to *(array + 5) in C. Since + is a symmetric operator, that means 5[array] is a valid, equivalent expression.
- ben0x539 8y agoDo you just take issue with the specific claim that no language should have pointer arithmetic, or do you disagree with the more general thrust of the post? Sure, it's ranty and, like, maybe closer to op-ed than computer science publication, but I think even among the rarefied breed of people developing your JVM/CPython/V8/Chakra, you could easily find approval for the notion that pointer arithmetic is bad(*) and should be avoided as much as possible.
- gaius 8y agoAdditionally, I don’t think it’s reasonable to extrapolate from the mess that is systemd to all C/C++ code. Some fantastically reliable systems have been developed with them.