Jussi
if you want to square different types
Jussi
In C++ you have the template, but it will still generate 2 functions in bytecode when you compile it with both int and double type calls
Jussi
the resulting binary is same size
Anonymous
Just out of curiosity, how do templates perform type checking?
Anonymous
Using your example, square cannot be of type char *, so how does C++ check it is of a valid type?
BinaryByter
Jussi
I think it checks it compile time, not 100% sure though, never tried to multiply a char* using a template
BinaryByter
BinaryByter
BinaryByter
You can add a static_assert though
BinaryByter
Ибраги́м
Ибраги́м
That;s a simple square root, and example of what Modern C++ is.
BinaryByter
Ибраги́м
Clang is the closest u can get
Ибраги́м
Anonymous
The best thing about Clang over GCC is it doesn't have that restrictive, godawful license attached to it
BinaryByter
?
Make the function square templated and make it a constexpr
BinaryByter
I won't be happy before
Ибраги́м
Jussi
BinaryByter
BinaryByter
Jussi
want to see proof?
BinaryByter
No
Jussi
afraid?
BinaryByter
I want to see you understanding what a compiler is and what a compiler isnt
Jussi
while you're saying that C++ compiler is better at optimizing than C compiler?
BinaryByter
Manuele
Ибраги́м
Jussi
no
Manuele
The Intel compilers produce the best code
Manuele
Followed by msvc
Anonymous
For me, all of this is moot because I'm not a professional C or C++ dev so when I want it, it's as a hobby only
Manuele
Then clang and gcc
Anonymous
so going for clang over gcc to get away from GPL at the cost of a bit of optimisation doesn't matter to me
Manuele
Manuele
The problem it's that is too expensive
Jussi
BinaryByter
That way they make other's processors look slower
Jussi
well then it is optimized for their cpus
BinaryByter
Nope
Anonymous
https://insights.dice.com/2013/11/04/speed-test-comparing-intel-c-gnu-c-and-llvm-clang-compilers/
BinaryByter
Its just optimized to be slow on other's cpus
BinaryByter
Oh shit, LLVM
Ибраги́м
Anonymous
As this article shows, Intel is by no means the best
Anonymous
Also, this is running on an intel CPU
Ибраги́м
Ибраги́м
Put that on AMD chip and see how it crawls
BinaryByter
BinaryByter
Ибраги́м
And it's probably the oldest
Jussi
I believe you in that
Ибраги́м
Ибраги́м
Modern C++ for C Programmers
https://ds9a.nl/articles/posts/c++-1/
https://redd.it/8r3jh4
@r_cpp
Ибраги́м
Ибраги́м
Their time is limited on earth
Ибраги́м
Embedded space is getting choked
Anonymous
Jussi
hooah
Jussi
C forever
вадим
Anonymous
Ибраги́м
XDDDD I like dis guy
There;s a reason why ISO C++ is releasing standards updating the language every 3 years.
By 2023... C is in ICU, 'cos Embedded market share (the only last stance for C) is going to be even.
Ибраги́м
Another thing that's going to be even us AMD -> Intel MArket Share.
Intel Compiler will be irrelevant then
Manuele
Ибраги́м
To all C guyz in the house, I will give u a simple task I've done in C++17 and D.
I want an equally elegant solution in C, if u can have that u win.
Ибраги́м
Ибраги́м
Manuele
Evidence sire ?
Download visual studio, create a fucking c++ project and compile it for arm