Been a C++ application developer for 28 years, but most of the code bases I've worked with were C++98 or ported C code. The newer work probably doesn't move past C++11. I rarely use anything from C++14 or later. Most of the new stuff increases cognitive load for little or no real benefit.
I saw a C++ code snippet and thought it was super ugly, so I made it more readable in a made up programming language to just show how bloated C++ is compared to what it is actually expressing. === Bloated C++ (15 LOC, 40 words) class MyClass { std::string m_name; std::vector m_data; public: MyClass(std::string const& name, std::vector const& data) : m_name(name), m_data(data) {} std::string name() const { return m_name; } std::string data( int i ) const { return m_data.at(i); } size_t size() const { return m_data.size(); } } === What it actually is expressing (3 LOC, 25 words) let MyClosure (name : string, data : string list) = // inner state here if needed {name: () -> name; data: i -> item i data; size: () -> length data} // this is returned === What it actually is expressing (no comments or unnecessary code) (1 LOC, 17 words) let MyClosure (name : string, data : string list) = {name: () -> name; data: i -> item i data; size: () -> length data} ===== My hypothetical syntax is 40/17 = 2.35 times more concise than the regular C++ version.
There was nothing wrong with the original version, in my opinion. Just use a wider screen if you have long lines. I also put every class declaration in a separate file. Number of lines isn't a problem there. That said, I tend to use the older style C++ syntax. Some of the latest additions are destroying the elegance of the language.
@@toby9999 The original version was pure code noise. However, if you want to adopt a style that is compatible with the C++ paradigm then this would be more optimally readable: public class MyClass(string name, vector data) { string name = () => name string data = (int i) => data.at(i) size_t size = () => data.size() } C++ devs are super economical with computer resources they use, but super liberal with developer resources, it is unnecessary complexity.
@@Nellak2011 I like classes but I use then sparingly, and mainly to group conceptually related functionality together instead of having everything global. I spent many years working with C code, and globals were the root cause of very many bugs, way more than memory issues. There is a balance with classes. I really dislike what I see in most Java code though.
One of the truly great things about C++ is all the people giving excellent talks at all of these excellent conferences.
And the book authors. Scott Meyers, Josuttis, Alexandrescu-there are not many authors of such level around.
Thank you for this great walk through history! 🙏
I remember the early template implementation almost doomed templates, the old CFront compiler code bloat, slow builds, etc.
Been a C++ application developer for 28 years, but most of the code bases I've worked with were C++98 or ported C code. The newer work probably doesn't move past C++11. I rarely use anything from C++14 or later. Most of the new stuff increases cognitive load for little or no real benefit.
A lot of the new stuff reduces cognitive load and is beneficial which you'd know if you had experience using it.
I saw a C++ code snippet and thought it was super ugly, so I made it more readable in a made up programming language to just show how bloated C++ is compared to what it is actually expressing.
=== Bloated C++ (15 LOC, 40 words)
class MyClass {
std::string m_name;
std::vector m_data;
public:
MyClass(std::string const& name,
std::vector const& data)
: m_name(name),
m_data(data)
{}
std::string name() const { return m_name; }
std::string data( int i ) const { return m_data.at(i); }
size_t size() const { return m_data.size(); }
}
=== What it actually is expressing (3 LOC, 25 words)
let MyClosure (name : string, data : string list) =
// inner state here if needed
{name: () -> name; data: i -> item i data; size: () -> length data} // this is returned
=== What it actually is expressing (no comments or unnecessary code) (1 LOC, 17 words)
let MyClosure (name : string, data : string list) = {name: () -> name; data: i -> item i data; size: () -> length data}
=====
My hypothetical syntax is 40/17 = 2.35 times more concise than the regular C++ version.
There was nothing wrong with the original version, in my opinion. Just use a wider screen if you have long lines. I also put every class declaration in a separate file. Number of lines isn't a problem there.
That said, I tend to use the older style C++ syntax. Some of the latest additions are destroying the elegance of the language.
@@toby9999 The original version was pure code noise. However, if you want to adopt a style that is compatible with the C++ paradigm then this would be more optimally readable:
public class MyClass(string name, vector data) {
string name = () => name
string data = (int i) => data.at(i)
size_t size = () => data.size()
}
C++ devs are super economical with computer resources they use, but super liberal with developer resources, it is unnecessary complexity.
This is what happens if one applies useless patterns. What is the use of "MyClass"?
@@raymundhofmann7661 Facts, classes are pretty useless. Functions all day.
@@Nellak2011 I like classes but I use then sparingly, and mainly to group conceptually related functionality together instead of having everything global. I spent many years working with C code, and globals were the root cause of very many bugs, way more than memory issues. There is a balance with classes. I really dislike what I see in most Java code though.