Most active commenters
  • vlovich123(3)

←back to thread

In Defense of C++

(dayvster.com)
185 points todsacerdoti | 11 comments | | HN request time: 0.017s | source | bottom
Show context
fouronnes3 ◴[] No.45268145[source]
This is a good article but it only scratches the surface, as is always the case when it comes to C++.

When I made a meme about C++ [1] I was purposeful in choosing the iceberg format. To me it's not quite satisfying to say that C++ is merely complex or vast. A more fitting word would be "arcane", "monumental" or "titanic" (get it?). There's a specific feeling you get when you're trying to understand what the hell is an xvalue, why std::move doesn't move or why std::remove doesn't remove.

The Forest Gump C++ is another meme that captures this feeling very well (not by me) [2].

What it comes down to is developer experience (DX), and C++ has a terrible one. Down to syntax and all the way up to package management a C++ developper feels stuck to a time before they were born. At least we have a lot of time to think about all that while our code compiles. But that might just be the price for all the power it gives you.

[1] https://victorpoughon.github.io/cppiceberg/

[2] https://mikelui.io/img/c++_init_forest.gif

replies(4): >>45268251 #>>45271645 #>>45273605 #>>45277835 #
jandrese ◴[] No.45268251[source]
In Linuxland you at least have pkg-config to help with package management. It's not perfect but neither is any other package management solution.

If I'm writing a small utility or something the Makefile typically looks something like this:

    CC=clang
    PACKAGES=libcurl libturbojpeg
    CFLAGS=-Wall -pedantic --std=gnu17 -g $(shell pkg-config --cflags $(PACKAGES))
    LDLIBS=$(shell pkg-config --libs $(PACKAGES))

    ALL: imagerunner

    imagerunner: imagerunner.o image_decoder.o downloader.o
replies(1): >>45268768 #
duped ◴[] No.45268768[source]
Consider that to do this you must:

- Use a build system like make, you can't just `c++ build`

- Understand that C++ compilers by default have no idea where most things are, you have to tell them exactly where to search

- Use an external tool that's not your build system or compiler to actually inform the compiler what those search paths are

- Oh also understand the compiler doesn't actually output what you want, you also need a linker

- That linker also doesn't know where to find things, so you need the external tool to use it

- Oh and you still have to use a package manager to install those dependencies to work with pkg-config, and it will install them globally. If you want to use it in different projects you better hope you're ok with them all sharing the same version.

Now you can see why things like IDEs became default tools for teaching students how to write C and C++, because there's no "open a text editor and then `c++ build file.cpp` to get output" for anything except hello world examples.

replies(7): >>45269381 #>>45270904 #>>45270987 #>>45271280 #>>45273544 #>>45277859 #>>45343902 #
worik ◴[] No.45270987[source]
None of that is a problem

There are a lot of problems, but having to carefully construct the build environment is a minor one time hassle.

Then repeated foot guns going off, no toes left, company bankrupt and banking system crashed, again

replies(2): >>45271224 #>>45273765 #
1. vlovich123 ◴[] No.45271224[source]
> There are a lot of problems, but having to carefully construct the build environment is a minor one time hassle.

I've observed the existence in larger projects of "build engineers" whose sole job is to keep the project building on a regular cadence. These jobs predominantly seem to exist in C++ land.

replies(5): >>45271408 #>>45271555 #>>45272069 #>>45272581 #>>45273222 #
2. wojciii ◴[] No.45271408[source]
How is that even possible?

Wasn't CI invented to solve just this problem?

replies(1): >>45271451 #
3. vlovich123 ◴[] No.45271451[source]
You have a team of 20 engineers on a project you want to maintain velocity on. With that many coooks, you have patches on top of patches of your build system where everyone does the bare minimum to meet the near term task only and it devolves into a mess no one wants to touch over enough time.

Your choice: do you have the most senior engineers spend time sporadically maintaining the build system, perhaps declaring fires to try to pay off tech debt, or hire someone full time, perhaps cheaper and with better expertise, dedicated to the task instead?

CI is an orthogonal problem but that too requires maintenance - do you maintain it ad-hoc or make it the official responsibility for someone to keep maintained and flexible for the team’s needs?

I think you think I’m saying the task is keeping the build green whereas I’m saying someone has to keep the system that’s keeping the build green going and functional.

replies(2): >>45271627 #>>45302380 #
4. jandrewrogers ◴[] No.45271555[source]
I’ve only ever seen this on extraordinarily complex codebases that mixed several languages. Pure C++ scales really well these days.
5. AdieuToLogic ◴[] No.45271627{3}[source]
> You have a team of 20 engineers on a project you want to maintain velocity on. With that many coooks, you have patches on top of patches of your build system ...

The scenario you are describing does not make sense for the commonly accepted industry definition of "build system." It would make sense if, instead, the description was "application", "product", or "system."

Many software engineers use and interpret the phrase "build system" to be something akin to make[0] or similar solution used to produce executable artifacts from source code assets.

0 - https://man.freebsd.org/cgi/man.cgi?query=make&apropos=0&sek...

replies(1): >>45271763 #
6. vlovich123 ◴[] No.45271763{4}[source]
I can only relate to you what I’ve observed. Engineers were hired to rewrite the Make-based system into Bazel and maintain it for single executable distributed to the edge. I’ve also observed this for embedded applications and other stuff.

I’m not sure why you’re dismissing it as something else without knowing any of the details or presuming I don’t know what I’m talking about.

replies(1): >>45296620 #
7. josefx ◴[] No.45272069[source]
Most of what I have seen came from technical debt aquired over decades. With some of the build engineers hired to "manage" that themselves not being treated as programmers and just adding on top of the mess with "fixes" that are never reviewed or even checked in. Had a fun time once after we reinstalled the build server and found out that the last build engineer created a local folder to store various dependencies instead of of using vcpkg to fetch everything as we had mandated for several years by then.
8. TuxSH ◴[] No.45272581[source]
> These jobs predominantly seem to exist in C++ land.

You wish.

These jobs exist for companies with large monorepos in other languages too and/or when you have many projects.

Plenty of stuff to handle in big companies (directory ownership, Jenkins setup, in-company dependency management and release versioning, developer experience in genernal, etc.)

9. pjmlp ◴[] No.45273222[source]
I have been "build engineer" across many projects, regardless of the set of programming languages being used, this is not specific to C++.
10. AdieuToLogic ◴[] No.45296620{5}[source]
>>> You have a team of 20 engineers on a project you want to maintain velocity on. With that many coooks, you have patches on top of patches of your build system ...

>> The scenario you are describing does not make sense for the commonly accepted industry definition of "build system."

> I’m not sure why you’re dismissing it as something else without knowing any of the details or presuming I don’t know what I’m talking about.

My apologies for what I wrote giving the impression of being dismissive or implying an assessment of your knowledge. This was not my intent and instead was my expression of incredulity for a build definition requiring 20 engineers to maintain. Perhaps I misinterpreted the "cooks" responsible for build definition maintenance as being all of those 20 engineers. If so, I hope you can see how someone not involved in your project could reach this conclusion based on the quote above.

Still and all, if this[0] is the Bazel build tool you reference and its use is such that:

  With that many coooks[sic], you have patches on top of patches 
  of your build system where everyone does the bare minimum 
  to meet the near term task only and it devolves into a mess 
  no one wants to touch over enough time.
Then the questions I would ask of the project members/stakeholders are:

  1 - Does using Bazel reduce build definition
  maintenance verses other build tools such as
  Make/CMake/etc.?

  2 - Does the engineering team value reproducible build
  definitions as much as production and test source
  artifacts?

  3 - If not, why not?
EDIT:

To clarify the rationale behind questions #2 and #3:

Build definitions are production code, because if the system cannot be built, then it cannot be released.

Test suites are production code, because if tests fail, then the build should fail and the system cannot be released.

0 - https://bazel.build/start/cpp

11. wojciii ◴[] No.45302380{3}[source]
I worked in companies that did this .. 20 years ago. I didn't imagine that this was still possible.

For me it's just about rules/discipline: Commit working code with passing unottests. Everyone is responsible for fixing stuff. You break something you'll fix it.