Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Welcome to devRant. Post legit rants and you'll quickly get the ++ you need.
Also,
You're an idiot if you're using a plain old array in C++ and complaining about the lack of bounds checking. Because the Java array is a mammoth object with a fuckton of methods and metadata while the C++ array is literally just a block of memory that you have to manage on your own.
Most C++ STL containers have functions that return elements after bounds checking, like std::vector's at(). Unlike Java, the C++ language philosophy is to give you choices and trust you to pick the right ones. -
Edit: I seem to spend a lot of time defending C++, lol. Not just on dR, but irl too. Don't mind me.
-
devios157016yIn C++ you make sure you can do something before you do it. If you dereference a null or invalid pointer, that’s your fault. Java on the other hand teaches lazy coding with training wheels that try and catch you when you fall.
I can’t abide any meme that tries to make Java look in any way superior to C++. -
Awlex177456y@7Raiden Kotlin ~ C#, in case you want still want to reap the benefits of java.
I know this must sound to you like a joke -
@devios1 undefined behavior is way worse than a bit of a penalty for exception handling.
-
devios157016y@beegC0de An uncaught exception is arguably not much better.
An exception might help you catch* a problem that happens in production more easily, but if you’re expecting/relying on exceptions, you’re doing it wrong.
*It’s impossible to talk about exceptions without accidental puns. -
@devios1 I know it is bad to rely on them, but I would rather have an exception thrown that literally makes it impossible to index out of bounds or follow a null pointer.
-
devios157016y…but don’t forget it comes with a cost. C++ is really just a thin layer on top of the hardware: you can do stupid and dangerous things with it, but it’s also blazingly fast.
-
@devios1 c++ has its own version of exceptions as well. See http://cplusplus.com/reference/... it is a bounds-checked vector accessor that throws an exception for a bad index.
-
devios157016y@beegC0de Interesting. It’s been a while since I’ve used C++ admittedly. I’m not personally a fan of exceptions whenever they can be avoided. I’d rather document the inputs and outputs of the function and return null if given invalid input.
I do think exceptions are useful on a low level when it truly is an unexpected condition: unwinding the stack back to a place where it can be handled gracefully is better than crashing hard, as I said.
An example of a good exception is if the disk is full. Imo that’s a proper use of an exception. However, as a counter example, catching an exception if you try to write to a file that doesn’t exist is sloppy. That’s relying on the exception to tell you whether the file is there or not. Instead, if you follow my personal approach, you would have to first attempt to instantiate an object that represents the file you want to write to. If it’s null, there’s no file object to even try. If it disappears unexpectedly though, exception. -
@vlatkozelka yeah, heh, that's why I posted the second comment. Didn't want @clonancodes to leave because of me 😅
I've been kinda annoyed at the pointless hate that C++ gets, lel.
Related Rants
Been feeling like a caveman after moving from Java to Ruby. Reminded me of this.
joke/meme
reddit
spongebob
stolen memes
need upvotes for avatar