> Where C++ gives you many slightly different takes on the same concept (e.g. unique_ptr, shared_ptr and raw pointers), C gives you one way to go and that one has a conveniently compact notation (such as float ). You use unique_ptr and shared_ptr because float is unsafe. If you don't care about the safety that smart pointers provide, you can use float* in C++ too. > ticking with the example of matrix math, it is baff…
"safety" is really overrated. The paranoia-fueled security industry has turned programming into some sort of weird authoritarian dystopia.
Goodbye C++, Hello C
31–40 of 222 posts
Re: Goodbye C++, Hello C
#32Earlier quoted context omitted.
The compiler cannot catch logic or design errors. If you made a mistake when designing the algorithm and implemented it as it is, you'd need to debug anyway. Sometimes it's something as simple as missing a minus symbol somewhere in your equations. Working with Eigen was especially painful. All the template magic it uses means what would have taken 1 second to compile if used BLAS/LAPACK, now takes 10-20 seconds.
> The compiler cannot catch logic or design errors. If you made a mistake when designing the algorithm and implemented it as it is, you'd need to debug anyway But that's the thing, it can. - you can specify compile-time preconditions and use the type system to ensure value are in range (which catches a ton of errors) - you can use constexpr to enforce no UB (UB in constexpr evaluation is a compile error) For instance…
double negate(double x){ return x; }
?
Re: Goodbye C++, Hello C
#33Earlier quoted context omitted.
You're right. I did some graphics work in my last job. OpenGL2 is supported by just about every device made in the last 15 years, on every major operating system, including software OpenGL in VMs. Vulkan is not officially supported on OSX (although there is an unofficial port that is quite good, from what I understand) and only runs on modern hardware.
> Vulkan is not officially supported on OSX And neither is OpenGL
And, like, Apple ported OpenGL to Apple Silicon macs. I suspect it's going to stick around, it's just never, ever going to get updated.
Re: Goodbye C++, Hello C
#34Earlier quoted context omitted.
> The compiler cannot catch logic or design errors. If you made a mistake when designing the algorithm and implemented it as it is, you'd need to debug anyway But that's the thing, it can. - you can specify compile-time preconditions and use the type system to ensure value are in range (which catches a ton of errors) - you can use constexpr to enforce no UB (UB in constexpr evaluation is a compile error) For instance…
How does the type system catch this bug double negate(double x){ return x; } ?
Just because a system does not catches all bugs does not make it useless - for me, even if C++'s type system had caught only one bug it'd be worth it (and in most of my code, which is mainly about fairly specific domain objects, the compiler saves me from myself pretty much daily).
In any case, I'd likely have this somewhere
constexpr double negate(double x) {
return -x;
}
// example implementation for the sake of the comment, there are much more exhaustive libs out there
constexpr bool sample(auto func) {
bool ok = true;
double x = -1000.;
while(x
this way I'd get a compile error if my cat walks on my keyboard and inadvertently removes the - (also a relatively common occurence)Re: Goodbye C++, Hello C
#35Earlier quoted context omitted.
"safety" is really overrated. The paranoia-fueled security industry has turned programming into some sort of weird authoritarian dystopia.
Is this a joke? Do you really think managed pointers are an example of authoritarian dystopianism?
Re: Goodbye C++, Hello C
#36> Where C++ gives you many slightly different takes on the same concept (e.g. unique_ptr, shared_ptr and raw pointers), C gives you one way to go and that one has a conveniently compact notation (such as float ). You use unique_ptr and shared_ptr because float is unsafe. If you don't care about the safety that smart pointers provide, you can use float* in C++ too. > ticking with the example of matrix math, it is baff…
"safety" is really overrated. The paranoia-fueled security industry has turned programming into some sort of weird authoritarian dystopia.
Re: Goodbye C++, Hello C
#37> Where C++ gives you many slightly different takes on the same concept (e.g. unique_ptr, shared_ptr and raw pointers), C gives you one way to go and that one has a conveniently compact notation (such as float ). You use unique_ptr and shared_ptr because float is unsafe. If you don't care about the safety that smart pointers provide, you can use float* in C++ too. > ticking with the example of matrix math, it is baff…
"safety" is really overrated. The paranoia-fueled security industry has turned programming into some sort of weird authoritarian dystopia.
Re: Goodbye C++, Hello C
#38Earlier quoted context omitted.
"safety" is really overrated. The paranoia-fueled security industry has turned programming into some sort of weird authoritarian dystopia.
Is this a joke? Do you really think managed pointers are an example of authoritarian dystopianism?
Re: Goodbye C++, Hello C
#39Earlier quoted context omitted.
"safety" is really overrated. The paranoia-fueled security industry has turned programming into some sort of weird authoritarian dystopia.
Is this a joke? Do you really think managed pointers are an example of authoritarian dystopianism?
The tinkerer/hacker ethos is disappearing slowly from PCs. It never caught on in the mobile world. It may perhaps only survive as a remnant in specialised chips and boards designed for learning.
Re: Goodbye C++, Hello C
#40Here on my laptop (Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz), on linux, compiling an eigen example takes 0.7 seconds
clang++ -fuse-ld=lld eigen.cpp -I/usr/include/eigen3/ 0,66s user 0,07s system 100% cpu 0,728 total
if I put the eigen header in a PCH this drops to 0.1 seconds clang++ -fuse-ld=lld eigen.cpp -I/usr/include/eigen3/ -include-pch 0,08s user 0,02s system 104% cpu 0,099 total
I have a hard time seeing how 300 lines of code (vs the 10 lines of the example) would multiply compile times by 300 - here's the example I used #include
#include
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout
I develop a GUI software with boost, Qt, and a fair amount of TMP and my average turn-around time from a change in the average file to the program running is between in and 2 seconds. Maybe it could get down to 0.1~ seconds if using C, but there would be so many less checks and guards !