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?
Jussi
I think it checks it compile time, not 100% sure though, never tried to multiply a char* using a template
BinaryByter
You can add a static_assert though
Jussi
you will generate no function bytecode at all
please enlighten us how it will multiply the numbers without bytecode
Ибраги́м
the resulting binary is same size
https://godbolt.org/g/gzQB3R
Ибраги́м
That;s a simple square root, and example of what Modern C++ is.
BinaryByter
Ибраги́м
Well if you're a terrible coder, C++ is better but basically both gcc and g++ are so shit at optimizing code that well your points are not valid
Saying GCC is shit at optimizations means u don't even know what u saying. GCC is the overall best compiler. Clang and MSVC might have better error messages in many cases, but optimisations, new features, availability ... GCC wins
Ибраги́м
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
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?
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
BinaryByter
The Intel compilers produce the best code
they produce horrors like this: mov eax, [SIZE] variable add eax, 1
Manuele
they produce horrors like this: mov eax, [SIZE] variable add eax, 1
If you test, the overall performances are better in the intel one
Manuele
The problem it's that is too expensive
Jussi
they produce horrors like this: mov eax, [SIZE] variable add eax, 1
that would be stupid if it was from a CPU manufacturer tbh
BinaryByter
that would be stupid if it was from a CPU manufacturer tbh
the treat increments as additions of one because intel processors treat add var , 1 as an inc operation
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
Ибраги́м
Followed by msvc
Crap! MSVC, Intel compiler for ARM, AVR, ... ?
Ибраги́м
Also, this is running on an intel CPU
^ Good u pointed that out
Ибраги́м
Put that on AMD chip and see how it crawls
Jussi
As this article shows, Intel is by no means the best
well but it compares the compile times, not the performance of the compiled program or w/e
Ибраги́м
well but it compares the compile times, not the performance of the compiled program or w/e
GCC supports more Modern C++ and experimental features at any point in time than any other compiler.
Ибраги́м
And it's probably the oldest
Jussi
I believe you in that
Ибраги́м
https://insights.dice.com/2013/11/04/speed-test-comparing-intel-c-gnu-c-and-llvm-clang-compilers/
This even shows GCC beating Intel CC at home... the TBB lib belongs to Intel
Ибраги́м
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
Ибраги́м
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
Ибраги́м
C forever
Yep, in the grave
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