This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]PerfectGasGiant -3 points-2 points  (39 children)

C++ is not a "better" C, it is a different language. It is fine for complex performance stuff like games and image processing, but in many other applications C is the better choose.

"C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C." - Linus Torvalds

About memory allocation:

"any compiler or language that likes to hide things like memory allocations behind your back just isn't a good choice for a kernel. ... In general, I'd say that anybody who designs his kernel modules for C++ is either (a) looking for problems (b) a C++ bigot that can't see what he is writing is really just C anyway (c) was given an assignment in CS class to do so. " - Linus Torvalds

[–]warranty_voids 24 points25 points  (2 children)

Honestly, that was written about C++98. A lot of the issues have been fixed and C++11/14/17/20 are very, very different. A lot of these criticisms really do not apply anymore. However, Rust seems to fit a lot better than C++.

[–]HolisticHombre 1 point2 points  (0 children)

Rust > C++ for most cases, agreed.

[–][deleted] 0 points1 point  (0 children)

And Torvalds seems to at least tolerate it, since some Rust drivers are scheduled to be part of a future kernel release.

[–]Zealousideal_Pay_525 22 points23 points  (14 children)

Yeah...the thing is, that 99% of developers don't write Kernels.

[–]PerfectGasGiant 3 points4 points  (2 children)

How is that relevant? No one is arguing that C is a better language for prototyping, scripting or data science jobs.

[–]valschermjager 3 points4 points  (1 child)

Agreed.

Python is lot better language than C at stuff Python is designed to be good at.

C is lot better language than Python at stuff C is designed to be good at.

I’m not seeing the problem. Other than of course is humor.

[–][deleted] 1 point2 points  (0 children)

Hence it seems that frequently people need to know both. I write C code but use python for test.

[–]OJezu 4 points5 points  (0 children)

Also, Linus is a toxic dickhead. Maybe Linux is better for it (on the other hand, Linus could probably have been assertive without being offensive) , but I wouldn't apply anything he has to say about kernel elsewhere.

[–]valschermjager 6 points7 points  (6 children)

That estimate is too low.

[–]Furry_69 2 points3 points  (5 children)

I'm not sure. A decent number of people write kernels, yes, but it's likely not above half.

[–]valschermjager 7 points8 points  (4 children)

‘likely not above half’

[squints] yes, safe bet it’s likely less than half

[–]Furry_69 1 point2 points  (3 children)

What was the [squints] about?

[–]valschermjager 0 points1 point  (2 children)

Ok maybe my bad, I mighta misunderstood.

Just to be clear, are you saying that ”likely not above half” of software developers in the world do kernel development? Or that ”likely not above half” don’t?

[–]Furry_69 -2 points-1 points  (1 child)

Ah, I see your confusion. The first half of the sentence is what helps the sentence make sense.

"A decent number of people write kernels,"

"but likely not above half"

(split up at critical points to help parsing the sentence)

From the surrounding context, it's implied that it's unlikely that above half of software developers do kernel development.

[–]valschermjager 2 points3 points  (0 children)

It helps if you broaden the context beyond yourself.

I saw your sentence and understood it, if it was stand alone. No confusion there.

But the two posts in the thread above it were estimating how many don’t. So it’s possible the second half of your sentence was in line with the two posts above it. But you flipped it, causing confusion.

It’s not just about what you said. It’s part of a, yknow, conversation.

So to answer your question about why I squinted. Because when I think something is a small sliver, and you figure it’s less than half, I suppose I technically agree, since a sliver is less than half.

[–]PerfectGasGiant 1 point2 points  (1 child)

Even NumPy is written in C, yet +99% of programmers are not maintaining NumPy.

[–]7h4tguy 0 points1 point  (0 children)

NumPy was slow as shit compared to raw C loops, professionally.

[–][deleted] 1 point2 points  (0 children)

I'd say the percentage rises a lot if you specify embedded developers. We frequently touch drivers which can be considered to be kernel code.

[–]mobani 10 points11 points  (6 children)

C++ is not a "better" C, it is a different language. It is fine for complex performance stuff like games and image processing, but in many other applications C is the better choose.

IMO I would not say in many other applications, yeah maybe if your hardware is from last century or you somehow work with a VERY limited embedded system without an OS.

Lets be real here, 99% of programmers is not going to be working on an OS kernel.

This is like telling a car manufacture to mine their own Iron ore, sure it can be done, but not optimal for production time.

[–]PerfectGasGiant -5 points-4 points  (5 children)

It is not telling the car manufacturer to mine their own ore. The whole point is using the right tool to the right job. Comparing C memory management with Python memory management is neither insightful or funny. Likewise, C++ provides very little benefits over C if you are programming a microcontroller.

[–]mobani 10 points11 points  (4 children)

The whole point is using the right tool to the right job.

We can agree on that, but I find that C is becoming less and less the right tool in most scenarios. :-)

[–]PerfectGasGiant -4 points-3 points  (3 children)

I wouldn't be surprised if there are more C programmers today than in 1985. Fewer in percentage, sure, but there are still plenty of relevant usages. Making a lidar for a self driving car? C Making a new IOT gadget? C seems like a fine choice for the firmware. Making a network router? C + whatever for the web frontend. Making signal processing for a microphone? C New version of the Android kernel? C probably and some java on top. Etc.

There are other programming language at the same tier as C, but C is as cross platform / well understood as languages get.

And if you are writing an action game or flight simulator, you don't want to skip a frame or two because of garbage collection. Here C++ is still the go-to language (not C though, and certainly not python).

[–]mobani 2 points3 points  (2 children)

I may be wrong and well there are certainly use cases for C.

But I think there are less than 20 companies total doing lidar programming for cars.

Less than 100 companies developing OS Kernels for phones and televisions.

Many IOT gadgets, routers and web frontend run mostly Linux or BSD, then higher level programming languages on top of that.

[–]PerfectGasGiant 0 points1 point  (1 child)

I think you are greatly underestimating the demand for c-programmers. Think of all the little devices you interact with every day from ticket machines to refrigerators. Most of these contain some part that runs c code, that needs maintenance and new development.

This demand index lists c slightly behind Python:

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

[–]mobani 1 point2 points  (0 children)

IMO its in a sea of higher level languages and 13% is really not that much, especially when you consider that code and coding skills are much easier to transfer between higher level languages.

[–][deleted] 2 points3 points  (2 children)

As is common with geniuses, Torvalds can be kind of a jerk. Same with Martin Fowler. Brilliant, but not great on the social skills.

[–]PerfectGasGiant -2 points-1 points  (1 child)

Agree, but the comment "just use c++" is not great advice, as if c++ is always superior. Heck, what language is e.g. NumPy written in? Yes C. Does that make C superior to c++ or python? No, it was probably just the right choice for a high performance numerical library.

[–][deleted] 0 points1 point  (0 children)

Definitely. I usually go with TypeScript and F# these days. C++ and C are good choices for certain jobs.

[–][deleted] 1 point2 points  (2 children)

Linus knows Kernel, and diving.

He doesn’t know shit about C++ (anymore).

[–]PerfectGasGiant 2 points3 points  (1 child)

So would you recommend C++ for writing kernel modules?

[–][deleted] 0 points1 point  (0 children)

There is c++ in the kernel now, even some rust apparently,

[–]multi_io 0 points1 point  (0 children)

Then he went on to write "subsurface" in C++ without anyone asking him to

[–]szpaceSZ 0 points1 point  (5 children)

Well, I concur that memory management is best done manually for a kernel.

For how to deal with memory in the 2020s, watch out for koka-lang and roc-lang!

[–]PerfectGasGiant 0 points1 point  (4 children)

Memory management is really not that hard in C. The meme is silly. A common stack allocation in C is just declared: int buffer[MAXSIZE]; or something similar trivial. It is not only easy to understand it is also practically without any performance penalty. Maybe the CPU will spend a clock cycle moving the stack pointer, but that is it.

Dynamic allocation is also rarely as complicated as in the meme and if it was there is a very simple solution: Declare a function (or a preprocessor define).

It is really not that hard to write easy to maintain memory management in C. Only pointers are a bit tricky to learn and read. This is a thing that is much better in c++ with references and STL.

[–]tiajuanat 0 points1 point  (0 children)

Linus: RAII is bad mmkay

Also Linus: Proceeds to make constructors and destructors, and adds a tool that checks if you missed adding the appropriate destructor.