Modern programming languages for HEP 4P0rC十十UsableCpp perfC+十yho 花5 C++getting usable ①Why python and C+ ②C++getting usable o Language "simplifications" o Making bad code harder to write Performant C+ Migrating from Python 2 to python 3 Conclusion simple banBadCade 12/65 S.Ponce-CERN
Modern programming languages for HEP 12 / 65 S. Ponce - CERN pyOrC++ UsableCpp perfC++ python3 Conclusion simple banBadCode C ++getting usable 1 Why python and C++ 2 C ++getting usable Language “simplifications” Making bad code harder to write 3 Performant C++ 4 Migrating from Python 2 to python 3 5 Conclusion
Modern programming languages for HEP pyOrC++UsableCpp perfC+ C++is becoming "simpler" With the C+conception of "simpler" o new and much nicer ways to write code o backward compatibility insured so the language is overall(much)more complex Most noticable features ●range based loops o auto keyword 。lambdas oranges ●<=> simple banBadCade 13/65 S.Ponce-CERN
Modern programming languages for HEP 13 / 65 S. Ponce - CERN pyOrC++ UsableCpp perfC++ python3 Conclusion simple banBadCode C ++ is becoming “simpler” With the C++ conception of “simpler” new and much nicer ways to write code backward compatibility insured so the language is overall (much) more complex Most noticable features range based loops auto keyword lambdas ranges <=>
Modern programming languages for HEP Range based loops Reason of being o simplifies loops tremendously oespecially with STL containers Syntax for type iteration_variable:container ) /body using iteration_variable Example code std:vector<int>v{1,2,3,4}; int prod =1; for (int a v)prod *=a;}/pls use std::accumulate simple banBadCade 14/65 S.Ponce-CERN
Modern programming languages for HEP 14 / 65 S. Ponce - CERN pyOrC++ UsableCpp perfC++ python3 Conclusion simple banBadCode Range based loops Reason of being simplifies loops tremendously especially with STL containers Syntax for ( type iteration_variable : container ) { // body using iteration_variable } Example code std::vector<int> v{1,2,3,4}; int prod = 1; for (int a : v) { prod *= a; } // pls use std::accumulate
Modern programming languages for HEP UsableCpp perfC十十pyho 花5 Auto keyword Reason of being o many type declarations are redundant o and lead to compiler error if you mess up std:vector<int>v; int a v[3]; int b=v.size();/bug unsigned to signed simple banBadCode 15/65 S.Ponce-CERN
Modern programming languages for HEP 15 / 65 S. Ponce - CERN pyOrC++ UsableCpp perfC++ python3 Conclusion simple banBadCode Auto keyword Reason of being many type declarations are redundant and lead to compiler error if you mess up std::vector<int> v; int a = v[3]; int b = v.size(); // bug ? unsigned to signed Practical usage std::vector<int> v; auto a = v[3]; auto b = v.size(); int sum{0}; for (auto n : v) { sum += n; }
Modern programming languages for HEP pyOrC+UsableCpp perfC+python “ Auto keyword Reason of being o many type declarations are redundant o and lead to compiler error if you mess up std::vector<int>v; int a v[3]; int b=v.size();//bug unsigned to signed Practical usage std::vector<int>v; auto a =v[3]; auto b =v.size(); int sum{o}; for (auto n v){sum +n; simple banBadCode 15/65 S.Ponce-CERN
Modern programming languages for HEP 15 / 65 S. Ponce - CERN pyOrC++ UsableCpp perfC++ python3 Conclusion simple banBadCode Auto keyword Reason of being many type declarations are redundant and lead to compiler error if you mess up std::vector<int> v; int a = v[3]; int b = v.size(); // bug ? unsigned to signed Practical usage std::vector<int> v; auto a = v[3]; auto b = v.size(); int sum{0}; for (auto n : v) { sum += n; }