Live data from Hacker News

C++ and the Culture of Complexity (2013)

blog.greaterthanzero.com

211–220 of 285 posts

Re: C++ and the Culture of Complexity (2013)

#211

When I was young, I thought I understood C++, because I had been taught it in school. I did not. Having interviewed several recent graduates who thought they knew C++, I believe this is fairly common, particularly among people with advanced degrees in engineering and the sciences. It's very easy, in C++, not to know the scope of one's ignorance.

This is very true. I've seen very ignorant (on c++) people say that they dont find c++ complex at all, but very simple.

Most of the time this only shows the lack of deep knowledge on the language.

Re: C++ and the Culture of Complexity (2013)

#212
post #43
post #20

Earlier quoted context omitted.

Oh boy, you must be really young. No parallel in C++?!!!?? That is where EJBs and Spring come from. The enterprise architects that created those kind of designs, were the same ones that on earlier decade were doing them with C++. Apparently micro-services are now a thing, well on the late 90's we had Sun RPC, CORBA, DCOM. All tied together with a cluster distributed transaction management. Sprinkled with code generat…

We should all be thankful that the Java and C# communities have offered a welcoming home to all the architecture astronauts :)

They are now busy building micro-services architectures in more trendy languages. :)

Re: C++ and the Culture of Complexity (2013)

#213

Earlier quoted context omitted.

> There's also the case though where the Rust compiler isn't helping you, but is just wrong. Bugs aside, compilers are not wrong, they may be too limited for what you're trying to do. Which is a different situation.

Being too limited for the intended purpose is still being wrong on some level. Not a bug, but still. Granted, sometimes you don't care: stuff like `true?1:"foo"` is of type int an has value 1, but the compiler will rejected because of a type mismatch in the conditional—but you don't care because the code smell is too big and obvious to ignore. Sometimes however you do care, if only a little: the value restriction in…

> Being too limited for the intended purpose is still being wrong on some level. Not a bug, but still.

By that criteria, every single statically typed language is "wrong on some level", you'll always find something you want to do/express which a specific language's compiler will not accept. That's not very helpful.

> Sometimes however you do care

I'm not saying people should not care, caring about lexical lifetimes being a pain in the ass is perfectly sensible (there's a reason why non-lexical lifetimes are being implemented after all). I'm saying there's a gulf between "the compiler does not allow X" and "the compiler is wrong", and lexical lifetimes are the former.

Re: C++ and the Culture of Complexity (2013)

#214
post #138

Earlier quoted context omitted.

You used Delphi, not Object Pascal. Object Pascal was created by Apple for Lisa and Mac OS, with collaboration from Niklaus Wirth. Borland then adopted it to Turbo Pascal 5.5 for MS-DOS. Turbo Pascal 6.0 and 7.0 for MS-DOS, followed by Turbo Pascal 1.0 and 1.5 for Windows 3.x took up ideas from C++. Borland then rebooted Turbo Pascal with Delphi, but to avoid creating too much confusion among Pascal developers, they…

Nitpick: Borland didn't reboot the object model, they extended it to add the 'class' types, but the 'object' types remained unchanged. The code you wrote works in both Delphi and Free Pascal :-). Object types are used often when you want to allocate objects on the stack or when you want to "embed" objects in other objects/classes (i don't know about Delphi but Free Pascal also extends object types to support newer st…

Thanks for the correction, always welcome.

Delphi 1.0 was about the time I started focusing on C++, so I am not that knowledgeable about its features. Just remembered that was one of the key changes.

Re: C++ and the Culture of Complexity (2013)

#215

Earlier quoted context omitted.

Here's one example: In C++, creating an instance of a class is fantastically complicated. The class must be initialized, and there is a zoo of different initialization forms: value, direct, aggregate, default, list, copy, etc. Which one foo {} invokes has been the subject of a spec bug. Some of these invoke a constructor, which is like a function, but isn't a function, multiplying the number of concepts involved furt…

> In Rust, there is exactly one way to create an instance of a struct: you provide a value for each of its fields. As a user of both rust and and C++, I certainly wouldn't consider the the lack of default constructors in rust to be a good thing. Especially for std types like Vec it is really annoying to have to initialize it explicitly. > The [dcl.init] section of the spec is about 16 pages long and there are about a…

> As a user of both rust and and C++, I certainly wouldn't consider the the lack of default constructors in rust to be a good thing. Especially for std types like Vec it is really annoying to have to initialize it explicitly.

That is fair but orthogonal to the issue at hand, namely:

> How is Rust less complicated than C++?

Re: C++ and the Culture of Complexity (2013)

#216
post #97
post #48

Earlier quoted context omitted.

How is Rust less complicated than C++? I don't use it, but from what I read it seems to be even more complicated, and getting even more so with the myriad of features they are adding each release.

It seems to have many fewer language-level features. No lvalue/rvalue distinction, pointers are not elevated to a language-level feature (only references), only a very limited exception mechanism (panic) that doesn't try to generalize to support general validation (rather general validation is done with Result which is a plain old datatype written in the language, though admittedly it relies on a macro for use - more…

FWIW

> Result which is a plain old datatype written in the language, though admittedly it relies on a macro for use

It does not. It relies on a special construct (!) or macro (try!) for convenience, but these are not necessary (a popular alternative is to use the various HoFs instead) and desugar to pretty trivial (if possibly repetitive) code:

    macro_rules! try {
        ($expr:expr) => (match $expr {
            $crate::result::Result::Ok(val) => val,
            $crate::result::Result::Err(err) => {
                return $crate::result::Result::Err($crate::convert::From::from(err))
            }
        })
    }

Re: C++ and the Culture of Complexity (2013)

#217

Earlier quoted context omitted.

All your complaints about C are valid, except I'd say defined but stupid behavior buried somewhere in a gargantuan language spec is effectively the same as undefined behavior. The difference is, C lets you control how much baggage you carry along and C++ doesn't. If I want a higher-level abstraction in C, I can usually implement it pretty well using inlines and macros, void and function pointers. Will it be pretty? H…

> Using a feature in C++ means carrying along all of the baggage from its dependencies and interactions with every other feature. Only if you use every other feature. Don't do that. Use the features you need (and understand well), not every feature. It actually becomes much like you say C is, except that you don't have to write the features.

> Only if you use every other feature.

Not true at all. A lot of the features have either an interface or an implementation driven by the possibility of combination with some other feature. The cognitive and/or performance costs remain even if that other feature isn't used. For example, it's easy to get mired in writing extra constructors/destructors and virtual hooha just because someone using your class might also use some feature besides the one you used yourself. I've seen that happen on many projects. The only way to avoid it seems to be to abandon most of what makes C++ different than C, at which point it would usually make more sense to start with C and add what you need.

Re: C++ and the Culture of Complexity (2013)

#218
post #59

While my pet peeves might be different than the author's I agree that C++ makes you work very hard to keep things simple and produce something that is beautiful. Just "avoid the complexity you don't absolutely need" doesn't really work: some basic things are so fundamentally convoluted that I rather just write idiomatic C because it's simple and doesn't get in my way. I want the language to originate from simple axio…

Could you give an example of "some basic things are so fundamentally convoluted"?

Also note that almost all C code is legal C++, so when you "just write idiomatic C", you're still writing C++. (Perhaps not idiomatic C++...)

Re: C++ and the Culture of Complexity (2013)

#219
post #43

Earlier quoted context omitted.

We should all be thankful that the Java and C# communities have offered a welcoming home to all the architecture astronauts :)

It seems to me there is a minority of the community of any language that want to turn it into Java.

*cough Zope

Re: C++ and the Culture of Complexity (2013)

#220
post #20
post #7

Earlier quoted context omitted.

C++ is a complex language no doubt. But software written in C++ need not be complex. Java, on the other hand, is a simple language. But the kind of unnecessary complexity I have seen in Java-land (EJBs, Spring, etc.) has no parallel in the C++-land. So going by your argument, I would choose C++ over Java to avoid the complexity jump, then profile the app, and if any part's too slow, improve that again in C++.

Oh boy, you must be really young. No parallel in C++?!!!?? That is where EJBs and Spring come from. The enterprise architects that created those kind of designs, were the same ones that on earlier decade were doing them with C++. Apparently micro-services are now a thing, well on the late 90's we had Sun RPC, CORBA, DCOM. All tied together with a cluster distributed transaction management. Sprinkled with code generat…

I suspect (but I am not certain) that any language that wants to work in that space is going to turn into Java EJB or C++ with CORBA and/or DCOM. I think it's the space, not the language, that produces such appalling monstrosities.

(And, if you needed that kind of thing, even EJB or CORBA was better than implementing that same functionality by hand...)

Post reply on HN