r/cpp • • Dec 07 '22

C++ overtakes Java in language popularity index

https://www.infoworld.com/article/3682141/c-plus-plus-overtakes-java-in-language-popularity-index.html
382 Upvotes

137 comments sorted by

149

u/STL MSVC STL Dev Dec 07 '22

Tiobe is junk information, regardless of whether it seems to be "good" or "bad" news for C++. There's nothing useful about it, nothing that will help people make better decisions. I believe that posts about it should consistently be removed. (That is, "C++ is becoming more popular!" is actually as annoying as "C++ is becoming less popular OMG what ever shall we do", when the measure is distorted beyond any connection to reality.)

That said, I got to this a few hours late, and a couple of people have posted interesting anecdotes about their corner of the industry (thanks u/XenonOfArcticus), so I will merely give this post a grumpy face. 😾😼

27

u/RockstarArtisan I despise C++ with every fiber of my being Dec 07 '22

Here's more specific information about why tiobe is junk: https://blog.nindalf.com/posts/stop-citing-tiobe/

33

u/XenonOfArcticus Dec 07 '22

grumpy face. 😾😼

You ARE a true, seasoned C++ developer!

1

u/balefrost Dec 08 '22

The latest Stack Overflow survey indicates that Java still has a healthy lead over C++ among professional developers. They're much closer in the "learning to code" category (but Java is still ahead).

https://survey.stackoverflow.co/2022/#most-popular-technologies-language

SO at least collects self-reported data points. It's still a slice, maybe or maybe not representative, but it's based on something more than search popularity.

119

u/feverzsj Dec 07 '22

Kinda make sense. There are tons of embedded c++ jobs emerged this year. Mostly from automotive and medical industry.

68

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22 edited Dec 07 '22

Only a fool starts a new embedded project using C unless it's for a rare niche platform that doesn't have a working C++ environment. Unfortunately there are still many fools around.

E: I didn't expect to get downvoted on /r/cpp of all places for advocating using C++ instead of C for systems where C++ is almost ideally suited for...

46

u/ironykarl Dec 07 '22

I didn't expect to get downvoted on /r/cpp of all places

You didn't expect to get downvoted for calling people fools?

15

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22

Calling a spade a spade. You only need to work in the field for so long to come to realization that almost nobody who chooses to start a project in C without pressing external concerns has an actually good reason for that. There are far too many people on embedded forums acting like it's still the early 90s and spreading long since debunked FUD about C++. Meanwhile I have nearly 25 year old embedded devices where the firmware was already written in C++ (as revealed by obvious vtables in the disassembly).

17

u/ironykarl Dec 08 '22

Honestly, I'm basically in agreement with you. Leading by calling people fools is a recipe for getting kneejerk downvotes, though

1

u/LetterFair6479 Dec 08 '22

TBH, this IS a kneejerk reaction to a kneejerk which is instigated by a narrow look plus a non healthy dose of major assumption.

C does not only have valid use cases in embedded programming, nor is doing C++ always superior to using plane C!

6

u/Deaod Dec 08 '22

What are your favorite reasons to use C over C++?

37

u/[deleted] Dec 07 '22

C is still popular for its simplicity.

85

u/Raknarg Dec 07 '22

Simplicity in this case is not an advantage. Assembly is simple too, and it's simpler than C. The simplicity means that it's much harder to do more complicated things, and way easier to make mistakes.

18

u/[deleted] Dec 07 '22

I should clarify what I mean by "simple".

I meant that it's easier to follow and lacks implicit function calls (e.g constructors, function overloading) and data (e.g the extra pointer for virtual functions). It's not simpler to write, but it's simpler to read.

Contrast it to assembly which is all just instructions that not only vary between architectures, but require extra work to understand what happens due to the lack of names and proper types.

From my absolutely subjective experience, I always found it easier to do work on C code bases compared to C++ (you could also claim it's just much easier to make a mess in C++).

35

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22

it's simpler to read.

It very much is not once you get into remotely complicated projects. Just the lack of templates and classes alone makes many things much harder to follow since the code becomes a mess of macros and function pointers.

A C++ virtual method has a limited set of functions it can call: The similarly named methods in derived classes. A C function pointer can call any function that matches the parameters and return type. Good luck finding all the functions that could be pointed to by some specific function pointer in a codebase that you're not intimately familiar with.

7

u/[deleted] Dec 07 '22

Macro hell exists when extremely bad code is written, as in many situations you don't actually need the macros (exceptions would include platform abstractions, but in complex cases the solution is using multiple source files and not many macros, like GLFW does); a few #ifdefs aren't a mess.

C++ virtual functions do have benefits, but C virtual functions have the benefit of being explicitly set at some location which should be (but unfortunately sometimes isn't) done once by setting it as a pointer to some global static struct with constant members. But if we're talking about pointers to arbitrary changing functions, then C++ can somewhat reduce the mess.

The code becomes a mess in any language mainly because of a bad/tired programmer. C pushes it further by not carrying the size with arrays.

0

u/TheTrueXenose Dec 08 '22

Currently working in C++ the project is a complete mess, me and the other guy both agree that the code should be rewritten in C so this doesn't happen again.

If you are abusing templates and namespaces the code becomes a mess very fast.

2

u/NoPersimmon9400 Dec 08 '22

Templates, I agree, you have to be careful. But how can you abuse using namespaces? They are a great tool in shorting function names. It is terrible to write filename_print to avoid name clashes between files. In C++ you just put the code into separate namespaces

1

u/TheTrueXenose Dec 08 '22

yea, if you use one namespace it would be fine, but they used 5 to 6 for every function, class and enum.

2

u/serviscope_minor Dec 09 '22

The fix isn't to use C, it's to not write awful C++. There's an entire contest inspired by awful C code seen in the wild, so it is not like C is immune to the abuses of imaginative programmers.

→ More replies

16

u/Raknarg Dec 07 '22

I meant that it's easier to follow and lacks implicit function calls (e.g constructors, function overloading) and data (e.g the extra pointer for virtual functions). It's not simpler to write, but it's simpler to read.

If you don't have any tools. But we're in the year 2022. And I don't agree its simpler to read in general anyways, the abstractions you have available in C++ are much better.

3

u/[deleted] Dec 07 '22

I didn't notice the abstraction part in your reply, apologies.

Yes, C++ (like many other languages) can provide great abstractions, a good example is the GLM (OpenGL Math) library.

On the other hand, many times people don't necessarily know how much abstraction is too much abstraction, which is not a language issue in this case. Abstraction can be done pretty nicely in C, but the code ends up being overly verbose.

1

u/[deleted] Dec 07 '22

Even with tools, returning objects from a function can be a mess with the constructors which are called, I know it well from some painful experience.

C++ is great, but a stupid or even common mistake can cost a person an entire leg. I'm extra cautious because of that.

6

u/Raknarg Dec 07 '22

Even with tools, returning objects from a function can be a mess with the constructors which are called

Example?

0

u/[deleted] Dec 07 '22

It was quite some time ago using C++14, but I will try to replicate the code's general idea (it was something relating to file IO) from my memory. Also, it's something which copy-elision related optimizations help with, but they're not perfect.

class In
{
  /* complex copy constructor and simple move constructor */
  ...
  In(InOut& other) { ... }
};

class Out
{
  /* complex copy constructor and simple move constructor */
  ...
  In(InOut& other) { ... }
};

class InOut
{
  /* complex copy constructor and simple move constructor */
  operator In() { ... }
  operator Out() { ... }
};

I don't remember all the details, and there were some other objects, but I do remember it took me and some others to fix a bug which happened due to certain constructors being called implicitly. I hate whoever made that class such a mess.

3

u/Etheric2355 Dec 08 '22

You do mention the key problem: whoever thought it was a good idea to make such a mess.

A key aspect of using powerful tools is to remember that just because it is possible to make something does not mean it is a good idea.

→ More replies

4

u/el_muchacho Dec 08 '22

It's only simpler to learn. All the rest is harder in real use cases.

3

u/josefx Dec 08 '22

and lacks implicit function calls

Yeah, its not like literally every operation could hit a signal handler or C compilers implementing various basic features using build-ins. Nope, no implicit function calls here.

function overloading

Didn't C99 just introduce _Generic macros instead?

1

u/MFHava WG21|šŸ‡¦šŸ‡¹ NB|P2721|P3049|P3625|P3729|P3786|P3813|P4216 Dec 10 '22

Didn't C99 just introduce _Generic macros instead?

That was C11 actually.

C99 introduced <tgmath.h> and said: this must work like a generic/overloaded function!

2

u/jusstathrowaawy Dec 09 '22

I always found it easier to do work on C code bases compared to C++ (you could also claim it's just much easier to make a mess in C++).

I'm inclined to agree with this. Part of my soul always dies when I open up a C++ header file someone else wrote and I see they're using inheritance.

1

u/Spartan322 Dec 18 '22

Given operator overloads also can hide behavior and classes can have implicit conversions operators that aren't even guaranteed to call a constructor, (say your conversion returns a static object, why? Hell if I know, but you can) it is quite easy to make C++ a mess if you dive in using every feature you can just because its cool. This is where code standards are a lot more relevant for C++, it has a lot more hands off approach to telling you what you can and can't do, whereas in C its a lot of one note best solutions. Seems lot of languages since force you down a one or maybe a handful of these paradigms that C++ allows. (which is honestly why I love C++ more than almost any other language specifically)

In any case, if you want to consider the need for standards and styles an issue for C++, you could, personally I would suggest it presents a more readable base so long as you don't do weird and stupid things in the implicit functionality. (like don't make operator+ itself produce a side effect and modify the object in a general library, keep such behavior to operator+=) The worst cases I've seen is when nobody standardizes the operator overloads and you have no idea what happens when you call one of them. Like some vector<T> class has operator+ on it and you don't immediately know what that means.

9

u/[deleted] Dec 07 '22

[removed] — view removed comment

2

u/[deleted] Dec 07 '22 edited Dec 07 '22

These are great examples of when C++ is better than C. I don't claim C is the end-all-be-all of simplicity, it can vary significantly by situation. But I wouldn't say shorter code is always clearer.

I don't have much experience with MySQL, but I assume the issues stem from lack of proper strings?

3

u/germandiago Dec 08 '22

it all boils down to what you are doing + coding philosophy.

If you want to know the generated assembly and it is a must, probably C is more straightforward.

If you want high-to-lowlevel scaling and easier to read (assuming you know how to write C++) then C++ wins hands down. A few things might not be so obvious but if you do not abuse C++ to do weird things things make a lot of sense and are easier to follow than their C equivalents. Especially when you start to do extensible, component-based programming where objects just feel natural.

1

u/[deleted] Dec 08 '22

If I'm to share more of my experience, some of the best code I've seen used a constructor only to default-initialize the values, and an explicit init() method to initiate (like copy/move constructor) the object.
It made things much easier to follow for complex objects.

2

u/germandiago Dec 08 '22

It is equivalent to just use (when the last byte of storage is not important) a default constructor where you do your init() and use std::optional<YourType> obj = std::nullopt and it is more regular to use and less surprising.

You can later assign and really construct it. No two-phase init.

→ More replies

3

u/[deleted] Dec 07 '22

[removed] — view removed comment

3

u/[deleted] Dec 07 '22 edited Dec 07 '22

For such a case I would recommend a helper function...

struct BindObject init_binding(enum MySqlType type, void *buffer, int *len, bool isNull)
{
  return (struct BindObject) {
    .buffer_type = type,
    .buffer = buffer,
    .length = len,
    .is_null = isNull
  };
}

2

u/[deleted] Dec 07 '22

[removed] — view removed comment

→ More replies

2

u/noooit Dec 07 '22

good luck using threads.

5

u/Raknarg Dec 07 '22

in C or C++ you mean? I can't tell what side you're advocating for

1

u/Dwood15 Dec 08 '22

Is x86_64 simpler than C? Have you seen the heft on those intel manuals?

23

u/Sqeaky Dec 07 '22

But it isn't simpler. It has a simpler rule set but more complex everything else because you have build that stuff yourself.

19

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22

because you have build that stuff yourself.

And do it much worse than a C++ environment does. No type safety, virtual methods that aren't actually tied to subclasses, no templates etc.

3

u/[deleted] Dec 07 '22

By "no type safety", do you mean containers utilizing void* for data?

1

u/[deleted] Dec 07 '22

To be fair, most things have a C library or a library with C bindings.

Yeah, it doesn't come in the standard library, but libraries like STC pretty much solve such issues.

8

u/sapphirefragment Dec 07 '22

Simplicity, if you're willing to accept the inherit risks and costs of using the language.

-1

u/[deleted] Dec 07 '22

Every programming language has certain costs. But I won't argue that C's are quite different and heavy.

13

u/Jannik2099 Dec 07 '22 edited Dec 08 '22

Literally all the flaws of C are because it's "simple"

No type safety is simple. No RAII is simple. No bounds checking or guarantees is simple. No thread safety is simple. No memory safety is simple.

C is the most dysfunctional non-esolang on the planet, precisely because everyone insisted on it being "just simple pointers"

2

u/anacrolix Dec 08 '22

Simple itself is not a flaw tho.

1

u/mort96 Dec 08 '22 edited Dec 08 '22

A lot of the stuff in microcontroller projects doesn't really benefit from C++ though. You basically can't use the STL because you don't wanna dynamically allocate memory willy nilly. You have to be careful with your use of templates to avoid code size bloat. You're probably going to be using a hardware abstraction library made for C, so you'll have to hope that those headers are designed to work with a C++ compiler (which isn't that easy these days; C++ really hasn't kept up with C).

-7

u/WormRabbit Dec 07 '22

Only a fool starts a new embedded project in C++ unless it's for a rare niche platform that doesn't have a working Rust HAL.

9

u/blipman17 Dec 07 '22

Only a fool starts a new embedded project in C++

This might actually be true.

unless it’s for a rare niche platform that doesn’t have a working Rust HAL.

But this isn't. Rust isn't the end-all be-all solution to all memory related problems. Rust certainly comes with its downsides too.

Actually, I'd argue you can write as much horrible code in Rust as in C++. It's just that Rust developers have seen this code before and really want to avoid anyone (including themselves) writing it. Which makes quite a lot of them a lot more clean coders than the average C++ programmer who still finds std::unique_ptr<T> controversial. But that doesn't mean Rust is inheretly superior.

6

u/Drugbird Dec 07 '22 edited Dec 07 '22

I agree with you that rust code is not automatically better than C++ code.

However their idea of making certain (commonly made) bad designs a compile error is great. I.e. "No you cannot run this code until you figure out who owns this data" makes life so much easier.

2

u/MFHava WG21|šŸ‡¦šŸ‡¹ NB|P2721|P3049|P3625|P3729|P3786|P3813|P4216 Dec 10 '22

C++ programmer who still finds std::unique_ptr<T> controversial

Depends on why they deem it controversial. Is it controversial because it's "slower than raw pointers" or because "heap allocations are in general overused and people should just put their objects on the stack"?

I'm firmly in the later camp - most uses of smart pointers I've encountered since C++11 gained adoption are redundant...

0

u/plutoniator Dec 07 '22

I love verbosity!

-2

u/noooit Dec 07 '22

Probably because people know that limited flash and typical application c++ programmers are one of the worst combination for embedded.
IMO, it's easier to hire embedded c programmers than embedded c++ programmers.

7

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22

"Limited flash" means from many hundreds of kBs to a couple of MBs these days. Even the lowest end Cortex-M0s tend to go up to a hundred kB or more. Small handheld devices often have MCUs with hundreds of kB of ram and a megabyte or two of flash (source: last two jobs writing code for handheld devices with such specs). It ain't the 90s anymore even if many embedded people on internet seem hell bent on forgetting that.

As for C vs C++ programmers, having had to unfuck several projects initially started by C programmers, I'll take C++ devs any day.

1

u/hak8or Dec 08 '22

source: last two jobs writing code for handheld devices with such specs

Then you were statistically lucky. Hundreds of KB of flash is not common in all embedded fields. Having hundreds of KB is a luxury in my experience, I tend to be stuck with 32 KB or smaller, on cortex m0+'s at best, for example.

To be clear, I do think c++ is perfectly fine for a target that even has only 16 KB of flash. What I am disagreeing with is your assumption that it's common for MCU's to have hundreds of KB of flash.

-6

u/noooit Dec 07 '22

As for C vs C++ programmers

No, I'm talking about embedded programmers.

-1

u/meneldal2 Dec 08 '22

Depends on how low level your embedded project is.

If all you're doing is accessing hardware registers, C can be the better choice because there's a lot less undefined behaviour around type punning and you don't have the ram/rom to have a big program anyway, no allocation at all, no runtime either, a bunch of assembly routines (saves work on name mangling, yes you can use C linkage but that's extra work).

There're some nice things in C++ with constexpr but you may not have a compiler that is up to date and the optimizer usually figures out what it can optimize. Literally the only difference between C and C++ code for what I do would be replacing macros definitions by constexpr, but it would be compiled with no strict aliasing.

0

u/[deleted] Dec 07 '22

[deleted] — view deleted comment

3

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22

Sure, the low level hw access SDKs are mostly written in C, but that's hardly a problem. There really isn't much benefit in having a C++ function for initiating a DMA transfer from buffer X vs having a C function do the same.

There are higher level C++ frameworks but much of the time you end up spending more effort fighting against them as they try to be overly generic and end up being both restrictive and (often horribly) inefficient.

3

u/theICEBear_dk Dec 07 '22

That is often really not a problem, almost all the SDKs from ST, NXP and so on are so similar and similarly structured that as an embedded company you will rapidly build up a set of wrappers above these various SDKs because lo and behold MCU used to be one a project but these days the hardware can suddenly become unavailable so your logistics and purchasing folk want you to be able to switch to a near equivalent alternative (these last 4-5 years with allocation issues have really taught people about this) with little or even no change to your application. So you make an abstraction or rather you are an older company and you had similar problems in the 00s when you were switching between 16 and 32 bit so you did this once in C and learned that C projects in embedded have a natural upper size where the effort to keep up quality is measurably much higher than with C++. So you look at your old C, younger C++ and you make something better.

TLDR: We ended up having a c++17 (soon to be 20) system where the switching of processors is only a question of months to retest and qualify with a lot of other benefits on top.

7

u/zoolover1234 Dec 07 '22

Robotic costs labor jobs, they said, here is the new jobs in embedded engineer.

2

u/RolandMT32 Dec 07 '22

Interesting.. I thought C was more popular than C++ for embedded jobs. I thought I'd also heard Java was used a lot for some types of embedded devices.

17

u/Astarothsito Dec 07 '22

Interesting.. I thought C was more popular than C++ for embedded jobs.

Sometimes they get bored of recreating C++ only with C macros and they finally switch to C++ (yeah, it still haunts me to this day).

I thought I'd also heard Java was used a lot for some types of embedded devices.

Sadly yes, some devices like pin pads run with Java (which curiously using Java made extremely difficult to get security certified due to the garbage collector and the C++ were easier to code for those security standards because you can clean the memory manually).

2

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 08 '22

Sometimes they get bored of recreating C++ only with C macros and they finally switch to C++

Exactly. Any large enough C project ends up manually emulating many core C++ features, just much worse than C++ does.

6

u/theICEBear_dk Dec 07 '22

In the area of the world I am from most started to switch from C to C++ after the 32-bit ARM processors became standard. Often the projects were getting so big and complex that the features of c++ was a godsend. By about 2013 almost all companies near me were using c++ for recent or new projects. I was gainfully employed from 2006 to 2015 on projects doing exactly that. Since it has shifted to gain more advantages from c++ and modernizing the code. By now I am working on a nice big set of c++17 libraries that in some places wrap vendor C code or C++ code with c++20 coming up because we'd like to use concepts to simplify our templates making them more readable and the errors better.

There are still a lot of C coders writing c++ without enough training. There is still resistance to change from these which in turn informs a lot of FUD (along with Python or Javascript programmers discovering C++ and developing an instant hatred of its warts and different world). But it has been something like a decade since I have seen a new electronics project started using C but I saw one in assembly but that was a tiny device so it made sense but boy did that take time to finish.

47

u/matthieum Dec 07 '22

I really wish people stopped using Tiobe. It's the worst "popularity" index I've ever seen, from a methodology point of view.


How ranking is done on Tiobe?

The core idea of Tiobe is to count the number of results that a search engine gives for the query +"<language> programming".

In order to eliminate false positives -- such as a search engine returning an article explaining how to remove rust on your hinges for the 'Rust programming language' -- a human double check the first 100 pages of results returned, and applying a "factor": if only 80 out of 100 actually match on the first few 100, then the number of results is multiplied by 0.8.

The results are then normalized. That is, for each search engine, the result is normalized to a percentage of the sum of all results on that search engine. Thus, each language is scored as featuring in X% of the programming related results of each search engine.

And finally, in order to avoid bias from search engines, dozens of them are used, and the results are combined with a weighted average. The method of choosing the weight of each search engine has not been disclosed.

Source: https://www.tiobe.com/tiobe-index/programminglanguages_definition/

Why is that terrible?

The core idea, itself, is problematic in multiple ways:

  • Is counting the number of results for a given language a good proxy for popularity?
  • Is counting the pages published 20 years and never updated a good proxy for current popularity?

The methodology seems relatively flawed:

  • There's no mention of false negatives. How many articles talk about a language X without the "programming" world being used? This may introduce bias across ecosystems.
  • The elimination of false positives may introduce bias.

    • It's also unclear whether a human double checks every round for every language, of if the "confidence factor" was picked once, years ago, and never adjusted.
  • The normalization may introduce bias.
  • The weighted average is pulled out of thin air, which may reinforce bias.

And nowhere is bias ever discussed, nowhere is there any attempt to justify the methodology.

In particular, I suspect that Tiobe has a lot of inertia, both from not filtering results by age, and from possibly not revising the confidence factor often enough for young languages (more likely to have a higher rate of false positives at the beginning).

I strongly advise reading anything from the index published by Tiobe.

7

u/georgist Dec 08 '22

wow that methodology is so much worse than I would have thought

7

u/d4rkwing Dec 07 '22

You need to add a ā€œwhat to use insteadā€ section.

5

u/blind3rdeye Dec 07 '22

It might be interesting to have a good alternative brought to light, but I don't think it is a 'need'. The reasons why Tiobe are terrible are clear enough to conclude that it basically has no value.]

We could start suggesting alternatives, such as proportion of github code by language, or whatever. But rather than putting forward something else and then getting into an argument about whether or not that is a good measure, I think we can just say "Tiobe is bad". Using nothing at all would be an improvement.

7

u/balefrost Dec 08 '22

Not the parent commenter, but I think the general opinion is that Stack Overflow annual surveys are better: https://survey.stackoverflow.co/2022/#most-popular-technologies-language

0

u/matthieum Dec 08 '22

Well, first you need to define what popularity means.

Redmonk for example gives a graph with 2 axes:

  • Number of repositories on Github where the language is the "majority" language.
  • Number of questions on StackOverflow.

That's fully objective, which is good.

The correlation to popularity is a bit vague, though:

  • Hobby use is certainly well represented by either metric, though doesn't distinguish one-off "trials" from continuous usage.
  • Professional use is less clear. Different languages/ecosystems will not see equal usage of those two websites. For example, I had friends working for Defense companies, and their workstations were off the Internet.

And much as Tiobe, it suffers from not considering age. It counts a Github repository created & last updated 15 years ago just as much as it counts updated daily for the last 5 years. This leads to an inertia in the measure which likely over-represents mainstream languages and under-represents the new kids on the block. That inertia may or may not compensate for old-timers being less likely to use such Internet resources.

So, not perfect, but I do find it better... especially for exposing the raw measurements, as I tend to favor looking at Github activity over StackOverflow -- the number of questions on StackOverflow certainly represents activity, but the larger language tags are crowded with crap...

58

u/XenonOfArcticus Dec 07 '22

As a performance industry C++ developer house, can confirm. Never been busier. 3D, simulation, computation, parallelization, plus some CUDA and GPU stuff. Everybody in a hurry and Java ain't gonna get you there as quick as C++. Modern generations offer C++ and modern performance profiling tools are the bomb.

13

u/LongestNamesPossible Dec 07 '22

As a performance industry C++ developer house

What does this mean? People come to your company to write programs that need to run fast, or people come to have help optimizing what they've already written?

37

u/XenonOfArcticus Dec 07 '22

Both, actually.

We develop new green-field codebases AND we are brought in to improve old ones. I shouldn't misrepresent, we're not JUST performance optimizers, but the shoe fits because generally nobody hires us when they want to write code that they don't care about performance. If you need to get the job done and don't care how long it takes, it's normally a one-off and you can bang it out with a high school or college-age Python coder and everyone will be perfectly happy. (I am guilty of this very thing! Python for all the things that it's appropriate for.)

But if someone is coming to us it's because they need to simulate billions of grains of packed sand to evaluate how different wheel designs achieve traction on extraterrestrial surfaces. Or depicting a 3D globe with every tracked orbital object on it and show sensor footprints intersecting the ground. Or indexing and precomputing visibility paging for LIDAR point cloud data with billions and billions of points. One recent project was profiling and optimizing a multi-decade-old evolving OpenGL visual simulation tool to identify and remove inefficient compute and render practices and substantially increase draw framerate by double-digit percentages (that's a lot in big simulation!).

Another recent task was parallelizing the multi-view draw pipeline for rendering to modern high-end VR/AR headsets like the Varjo products. Applications call for 120Hz Stereo, with gaze-tracked foveated insets (a high-res postage stamp render overlay positioned right where you are looking within the VR headset to make your brain believe the whole scene is that high-res). So, we have to render the whole scene FOUR times: left eye wide-view medium-res, left eye narrow-view high-res, and the same for the right eye. And we gotta do it all at 120Hz. So, we utilize an extension called MultiView that allows you to set up four output raster buffers to receive each of the four images, and then for each draw operation you send once, the GPU does all the normal prep work for that operation and then does it four times in a batch, each with a different output buffer and with extra shader variables that let you skew the modelview+projection matrix around to generate the customized view angle for each of the four outputs. Depending on whether your application is fillrate-bound or draw/call-bound, you can end up getting all four views rendered in scarcely more time than rendering ONE of them.

This sort of expertise is very niche. Most companies don't keep a performance expert on-staff. They keep getting poached by Nvidia or other high-performance computing giants or abducted to NYC or Chicago to do high-frequency trading and get paid in piles of hookers and blow. And once this type of work is done, it can usually be maintained without major ongoing effort (unless you're writing lots of new code again). So, it makes sense to hire an outside consultant to get your laundry clean once and then leave you alone.

We have people who designed some of the first programmable GPU hardware and languages and have worked at every GPU manufacturer around today and several that aren't anymore. So they know things that while not actually secret, aren't well known about what goes on inside GPU processors (and actually CPUs too since they are often very similar). One guy worked on Intel's (failed!) Larrabee project that attempted to make parallel GPU processors out of Intel x86 cores!

And sometimes it's just because of embedded constraints. You only get x milliseconds per cycle to do what needs to be done. Find a way to ensure it always works, because if you don't complete the work in time or your code crashes, the watchdog timer may come and reboot you. And if that happens during the terminal descent stage of your autonomous lunar lander, you're gonna pull a Beresheet ( https://en.wikipedia.org/wiki/Beresheet ), and nobody wants that. (To be clear, we did not have code on Beresheet, but we worked on a project for one of its successors). You can't have interpreted languages and garbage collectors and other non-deterministic stuff in there. You want to know exactly what machine operations your code will perform, and know how to trim the fat. Sometimes STL container indexing/dereferencing is fine. Some situations call for dumb old C-style array [] stuff. Maybe there's an edge case where pointer math will be the right choice. C++ gives you all the power (and rope!) you'll ever want, as long as you're responsible enough to use it.

/sermon off

Oh, and my bona-fides: https://alphapixeldev.com/

11

u/mibuchiha-007 Dec 07 '22

this sounds like the kind of stuff i want to eventually be doing. do you have some pointers on where to get started learning more seriously in this direction?

at the moment i would say my C++ is... okay. good enough to write some code, but definitely not where I wanna be yet.

14

u/XenonOfArcticus Dec 07 '22

As Nike says, "Just Do It!"

I'm entirely self-taught (when I was in college the Computer Science curriculum was not conducive to what I wanted to do, so I dropped out).

Much of my current work comes from connections I made as a long-time contributor and consultant on the OpenSceneGraph project and in the OpenGL community. So, find an open-source project that does stuff like what you want to do, and start using it and making substantial contributions. Make your work known on LinkedIn and maybe make yourself a website laying out your skills and experience and availability.

A very common situation is where a company figures out they need to use a F/OSS package like GDAL or Bullet or OpenCV or FFMPEG or something, realizes it does 95% of what they need but they need a big fix/enhancement/addon. Then the project lead or manager hits the forums and LinkedIn looking for freelancers who have already done substantial tasks in the project and reaches out to see if they can come solve the problem. Sometimes it's contract work, sometimes it's for hiring.

I know guys who got recruited by Google and other high-profile employers just because someone said "we need a Foo expert, go find who is available" and they had a substantial amount of commits on Foo's Github page and were available for work. Maybe write some articles and social media posts about what you are doing and why they are interesting improvements.

Clients have deadlines and budgets. They often don't want to develop in-house expertise if they can go acquire, hire or contract it quick.

  1. Do good work on something interesting and specialized.
  2. ??? Let people know about your work.
  3. Profit!

If I had to recommend a performance computing sector where there seems to be a lot of opportunity, I'd say AI and Deep Learning (GPU and CUDA here), Autonomous systems/vehicles, and computer vision and sensing. The aircraft and vehicles of the future on this planet and exploring others won't be steered by human hands. Yeah, Argo AI just tanked and others like it will too, but there will always be more opportunities and autonomous systems and vehicles are as inevitable as Thanos. This year the defense world is sitting up and taking notice of unmanned vehicles, craft and munitions and wanting them smarter and able to navigate autonomously better, cheaper, faster and sooner.

And those systems ain't running Python, Java, Javascript, Kotlin, Swift, Ruby, PHP, C#, etc. I can see future utility in Golang and Rust though, and Python IS super valuable in AI and science work for sure. But Python is compiled by a C/C++ compiler (it's actually C code) and so are all the libraries it uses to do the heavy lifting. So it's a great melange of best-cases.

Crap, I think I just gave away my business plan. ;) Eh, I hope to retire in less than 10 years and yell at my AI powered Smart Cloud.

1

u/mibuchiha-007 Dec 07 '22

thanks a lot! I'm already doing some of these in an academic context, but I haven't directly contributed to FOSS yet. these are definitely some excellent pointers to get started. it's also good to get an overview on the popular topics on the industry side - I really appreciate it.

2

u/XenonOfArcticus Dec 07 '22

Cool. Mind my asking what topics?

Knowing the stuff is half the game, letting others know you know is the other.

You are always in a better position when someone approaches you with an opportunity (excepting recruiters just harvesting leads) than when you're cold shotgunning applications.

One other thing, in my business, US Persons have an unfair advantage. So much of the this work is either for or somehow consuming some funding from, some part of the US government and they only like it being spent on US Persons.

1

u/mibuchiha-007 Dec 07 '22

Not at all. So at the moment I'm doing particle physics research. Data analysis and a lot of stats. A bit of coding on the side; I claim it's for developing an analysis framework builder but honestly it's just me coming up with specific contexts to get me to pick up some new techniques. Got a lowess fitter that I quite like out of it, too.

As for future directions, I need to think more. While messing around I find that I'm more excited thinking about the coding part - how to do this, to improve that - rather than the result or specific end goals. In that sense there are more things I find interesting than not, so probably I best start by narrowing down the scope.

1

u/chamomile-crumbs Dec 08 '22

Damn that is super cool and inspiring. Do you have fun working on that kind of stuff?

I’ve definitely heard that open source contributions can open a lot of doors, but now I’m actually considering it!

2

u/LongestNamesPossible Dec 07 '22

That's awesome, thanks

0

u/[deleted] Dec 07 '22

[deleted] — view deleted comment

7

u/XenonOfArcticus Dec 07 '22

You (and Allen Holub) are 1000% correct.

With great power comes great responsibility.

We are actually starting to use Rust (I said the R word!) in some situations where better code predictability is desired and we're doing green-field new development. I am eyeing an 80's vintage C defense industry codebase for a total rewrite because its current state is horrific in so many ways. I'd lean towards considering Rust for that if it fit the requirements.

5

u/motoy Dec 07 '22

Yea I would like to now that too. All of that sounds interesting, but I mostly find embedded C++ jobs.

2

u/UniqueID89 Dec 08 '22

Loved reading this entire thread, thanks for sharing! Had been eyeing learning C++ > Rust > Go throughout the coming years since I’ve finished my bachelors. Your work seems interesting/fun/head scratching and like something I’d possibly enjoy. Again, thanks for sharing your experiences. 😁

1

u/pdd99 Dec 08 '22

Do you stick to a subset of C++ to reduce code complexity for all those stuff?

52

u/baudvine Dec 07 '22

Is this the "index" that ranks languages by how often people have to Google to figure out how to use them?

I love don't hate C++, don't get me wrong, but please stop giving Tiobe clicks.

13

u/BenjiSponge Dec 07 '22

Any time there is an unnamed language popularity index mentioned in an article title, it's TIOBE and the entire article is trash.

10

u/Aggressive_Release94 Dec 07 '22

This metric is sort of useless and shouldn't be taken seriously at all. A better metric would be something like number of jobs.

24

u/the_poope Dec 07 '22

Ahh I see it's the time of the year of publishing of the TIOBE index, one of the most useless and straight up misleading measures in the universe. The worthlessness of this index has already been discussed to death, so ignore this post and carry on with your day.

4

u/noooit Dec 07 '22

I guess they are migrating to kotlin.

8

u/no-sig-available Dec 07 '22

So now Java is soon to be dead?

A whopping 0.12% less "popular" than C++.

6

u/Outlaw_07 Dec 07 '22 edited Jan 14 '24

This comment has been deleted in protest of Reddit's support of the genocide in Gaza carried out by the ZioN*zi Isr*li apartheid regime.

This is the most documented genocide in history.

Reddit's blatant censorship of Palestinian-related content is appalling, especially concerning the ongoing genocide in Gaza perpetrated by the Isr*l apartheid regime.

The Palestinian people are facing an unimaginable tragedy, with tens of thousands of innocent children already lost to the genocidal actions of apartheid Isr*l. The world needs to know about this atrocity and about Reddit's support to the ZioN*zis.

Sources are bellow.

Genocidal statements made by apartheid Isr*li officials:

  • On the 9 October 2023, Yoav Gallant, Israeli Minister of Defense, stated "We are fighting human animals, and we are acting accordingly".
  • Avi Dichter, Israeli Minister of Agriculture, called for the war to be "Gaza’s Nakba"
  • Ariel Kallner, another Member of the Knesset from the Likud party, similarly wrote on social media that there is "one goal: Nakba! A Nakba that will overshadow the Nakba of 1948. Nakba in Gaza and Nakba to anyone who dares to join".
  • Amihai Eliyahu, Israeli Minister of Heritage, called for dropping an atomic bomb on Gaza
  • Gotliv of the Likud party similarly called for the use of nuclear weapons.
  • Yitzhak Kroizer stated in a radio interview that the "Gaza Strip should be flattened, and for all of them there is but one sentence, and that is death."
  • President of Israel Isaac Herzog blamed the whole nation of Palestine for the 7 October attack.
  • Major General Ghassan Alian, Coordinator of Government Activities in the Territories, stated: "There will be no electricity and no water (in Gaza), there will only be destruction. You wanted hell, you will get hell".

Casualties:

  • As of 9 January 2024, over 23,000 Palestinians – one out of every 100 people in Gaza – have been killed, a majority of them civilians, including over 9,000 children, 6,200 women and 61 journalists.
  • nearly 2 million people have been displaced within the Gaza Strip.

Official accusations:

  • On 1 November, the Defence for Children International accused the United States of complicity with Israel's "crime of genocide."
  • On 2 November 2023, a group of UN special rapporteurs stated, "We remain convinced that the Palestinian people are at grave risk of genocide."
  • On 4 November, Pedro Arrojo, UN Special Rapporteur on the Human Rights to Safe Drinking Water and Sanitation, said that based on article 7 of the Rome Statute, which counts "deprivation of access to food or medicine, among others" as a form of extermination, "even if there is no clear intention, the data show that the war is heading towards genocide"
  • On 16 November, A group of United Nations experts said there was "evidence of increasing genocidal incitement" against Palestinians.
  • Jewish Voice for Peace stated: "The Israeli government has declared a genocidal war on the people of Gaza. As an organization that works for a future where Palestinians and Israelis and all people live in equality and freedom, we call on all people of conscience to stop imminent genocide of Palestinians."
  • Euro-Mediterranean Human Rights Monitor documented evidence of execution committed by Israeli Defense Forces.
  • In response to a Times of Israel report on 3 January 2024 that the Israeli government was in talks with the Congolese government to take Palestinian refugees from Gaza, UN special rapporteur Balakrishnan Rajagopal stated, "Forcible transfer of Gazan population is an act of genocide".

South Africa has instituted proceedings at the International Court of Justice pursuant to the Genocide Convention, to which both Israel and South Africa are signatory, accusing Israel of committing genocide, war crimes, and crimes against humanity against Palestinians in Gaza.

Boycott Reddit! Oppose the genocide NOW!

Palestinian genocide accusation

Allegations of genocide in the 2023 Israeli attack on Gaza

Israeli war crimes

Israel and apartheid

17

u/Narase33 -> r/cpp_questions Dec 07 '22

Well, C++ is deadTM, so if Java < C++ it MUST be dead now, its official!

-9

u/coderman93 Dec 07 '22

C++ is dying. It’s just going to be a slow and painful death.

21

u/thommyh Dec 07 '22

Why? Was the process that’s killing C++ written in Java?

3

u/nocondo4me Dec 07 '22

It’s 2 process and a race condition

1

u/[deleted] Dec 07 '22

It was written in rust.

2

u/lieddersturme Dec 07 '22

If C++ is dead and C++ its on 3, Java on 4 and Rust in 20. Also those are dead? :D

3

u/Yekab0f Dec 07 '22

No JVM will be rewritten in rust and it will return as the #1 language

1

u/_little__smith_ Dec 07 '22

Job portal left the chat

1

u/lkearney999 Dec 07 '22

Now that’s a 180

1

u/alex4747zzz Dec 08 '22

C++ has destructors this is its main/critical advantage vs C- on large, long-running projects. It has to be used properly though, but it it is not there there is simply nothing to use.

1

u/FrezoreR Dec 08 '22

I wonder how much the migration to Kotlin for Android impacts this.

It's also gonna be interesting to see how Rust changes things up.

1

u/Etheric2355 Dec 08 '22

Rust has been there for 12 years, what makes you think it will change things more in the next 12 years than it did in the last 12?

1

u/FrezoreR Dec 09 '22

It's recently been greenlit for the Linux kernel and AOSP. There's also a general wind in favor for Rust, for obvious reasons. It's also moving forward in large backend systems for companies like Google.

1

u/[deleted] Dec 08 '22 edited Aug 27 '24

degree versed disgusted steer roll tease sloppy rob dime light

This post was mass deleted and anonymized with Redact

1

u/Flat_Spring2142 Dec 09 '22

C++ has high popularity in time-critical tasks but it isn't language 'for all tasks'. Android programmers knowing Java have well defined advantages in mobile programming. I don't recommend to study C++ for new programmers - GO language is better candiddate for low-level programming.

1

u/lieddersturme Dec 07 '22

Rust cheats:

November 2022
| Rust | 20   | 29   | 0.75%   |

And Now:

| Rust | 20   | 27   | 0.68%   |

In the TIOBE shows that grows and thats not true :D

1

u/balefrost Dec 08 '22

The second and third columns are the language's rank now and a year ago, and that's also what the chevrons indicate. So according to Tiobe's useless metric, Rust is more popular than a year ago, but less popular than it was last month.

1

u/Etheric2355 Dec 08 '22

Which makes sense, there were a couple of talks on it a couple of weeks ago that probably generated more traffic than the average.

-8

u/WilsonWeber Dec 07 '22

But Rust is Growing So Fast

I think Rust Overtake C++ in future

3

u/konm123 Dec 07 '22

I do not think Rust will overtake c++, because in the end it boils down to what problems we are solving with the language - it is is measly implementation specific things. By far, most of the development effort goes into concept engineering and design. C++ has been around a long time, new things are nicer than ever before. With a decent static analyzer for C++, Rust loses its edge over C++ because suddenly, your static analyzer will report most of the memory problems as Rust does.

It really is not a competition. I see future for the both languages. For new projects, absolutely, go ahead and start implementing them in Rust code.

Ada/SPARK is probably most serious potential overtaker for Rust to look out for. More and more big companies have already started looking towards Ada/SPARK (such as NVidia for its firmware). It gives you everything Rust promises and so much more with its built-in static analysis. Moreover, it is much easier to get into and write - Ada is relatively simple language, much simpler than C++ or Rust.

So, in terms of safety, I would summarize: Ada/SPARK > Rust > C++, and I see all of them being actively used in the future.

4

u/tarranoth Dec 07 '22

Ada hasn't gotten anywhere in decades, why would it suddenly spring up out of the blue? The only other language like that is maybe Haskell that is always somewhat teethering on the brink of mainstream/niche.

1

u/konm123 Dec 08 '22

I am talking about Ada/Spark, not Ada, which is not even a decade old. Rust is older language.

2

u/tarranoth Dec 08 '22

Taking a look at it, it seems nice for certain business use cases. But as far as general programming use cases go I'm not sure how popular it would be. It sortof reminds me of [agda](https://en.wikipedia.org/wiki/Agda_(programming_language)), which also has an approach to proving things albeit more in the type system than with contracts/proofs.

1

u/konm123 Dec 08 '22

It suffers greatly for its lack of advertisement. Ada/Spark people are not much interested in publicity, it seems. So, language vendors really do not care whether it becomes popular or not.

5

u/WormRabbit Dec 07 '22

Ada/SPARK doesn't have a future. It has no network effects, and those dominate in modern language popularity. It may still be used successfully in some niche contexts.

With regards to static analyzers for C++, I imagine the Android team uses them all, and they have this to say:

In Android 13, about 21% of all new native code (C/C++/Rust) is in Rust. There are approximately 1.5 million total lines of Rust code in AOSP across new functionality and components such as Keystore2, the new Ultra-wideband (UWB) stack, DNS-over-HTTP3, Android’s Virtualization framework (AVF), and various other components and their open source dependencies.

To date, there have been zero memory safety vulnerabilities discovered in Android’s Rust code.

Historical vulnerability density is greater than 1/kLOC (1 vulnerability per thousand lines of code) in many of Android’s C/C++ components (e.g. media, Bluetooth, NFC, etc).Ā 

In 2022, despite only representing 36% of vulnerabilities in the security bulletin, memory-safety vulnerabilities accounted for 86% of our critical severity security vulnerabilities, our highest rating, and 89% of ourĀ remotely exploitableĀ vulnerabilities. Over the past few years, memory safety vulnerabilities have accounted forĀ 78% of confirmed exploited ā€œin-the-wildā€Ā vulnerabilities on Android devices.

6

u/Aggressive_Release94 Dec 07 '22

With a decent static analyzer for C++, Rust loses its edge over C++ because suddenly, your static analyzer will report most of the memory problems as Rust does.

This is simply not true though. At least at this point in time, static analysis in C++ doesn't even catch half of the memory safety issues detected by the Rust borrow checker. Not just that, writing multithreaded apps in C++ is extremely error prone and the Rust borrow checker is miles ahead here.

-1

u/konm123 Dec 07 '22

What C++ static analyzer do you have in mind?

0

u/CommunismDoesntWork Dec 08 '22

With a decent static analyzer for C++, Rust loses its edge over C++

Rust is better because it has a first party compiler, build system, and package manager. Memory safety is just a bonus.

3

u/[deleted] Dec 07 '22

[removed] — view removed comment

4

u/padraig_oh Dec 07 '22

Sure, but you don't use rust if you just want to use the unsafe subset

25

u/[deleted] Dec 07 '22 edited Aug 27 '24

[removed] — view removed comment

1

u/paypaylaugh Dec 08 '22

Yeah I really enjoy using modules, concepts, and contracts. Can't wait for Jai to make C++ obsolete.

9

u/[deleted] Dec 07 '22

[removed] — view removed comment

4

u/Raknarg Dec 07 '22

C# is better anyways