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
-
Root826024yI prefer that there are no hard rules against stupidity. I don’t like things telling me what perfectly valid things I can and can’t do.
If the cost is being able to do stupid things, too, that’s fine by me. -
Root826024y@halfflat I edited my comment; I meant rules/errors, not warnings. Warnings are a good thing! They can also be annoying things. Especially when they’re wrong and refuse to go away. Grumble.
-
That's why every time I pass a pointer to a function, I do some NULL checking. If it's a NULL pointer, then I print an error telling me where it happened.
-
@halfflat No it isn't. Normally binary logical operators are of equal precedence. They are a class of operators, like (*, /, %) or (+, -), and left associativity is what decides the order. "and" takes precedence in many programming languages because in speech "and" usually takes precedence over "or", but this is subjective so it's worth a set of parentheses.
-
@Bybit260 Gross I hate null checks. I do Null object pattern. I hate having a codebase riddled with null checks
-
Hazarth95094yIt's this freedom that also allows you to do some pretty incredibly efficient things with the memory or the cpu.
I prefer it over the handholding of Java for example, that wont even allow me to put a return statement if Theres code after it -
@Hazarth Could you please give an example where per-spec incorrect code is more efficient than anything you can do with the STL?
-
Hazarth95094y@Lor-inc using unions or pointer casting you can shove integers into longs and add them together and then split them again into ints to achieve certain data parallelism, though to be honest that's pointless now with mmx n stuff
You can also use a similar trick with chars and string comparisons, a sufficiently long string can be sectioned into long 64bit numbers and compared with another 8chars at a time
Also now I just figured that you can probably interlace arrays in memory so they get cpu cached both at the sametime (if you need to access elements that are close to each other?) I have to test that though
Dunno, I try a lot of ugly hacks in case something fun works, and I benchmarked the first two and managed to outperform even boost, though the usage is less generic and again mmx, sse and sse2 make these hacks usually obsolete but hey! At least I know I can do these in case Im working with a cpu without simd instructions right?
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911Hats off to this lady .... I would have just flipped the machine
I like C++, but it is seriously easy to do fucked up things:
class Test{
public:
Test(){};
};
Test test;
Test* test2 = nullptr;
Test& test3 = *test2;
Test* test4 = (Test*)0x12345;
Test& test5 = *test4;
Test* test6;
Test& test7 = *test6;
No warnings at all. I wonder if there is a flag for this kind of stupidity. Here's your sign...
random
references
c++