Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Sapozhnik
Jan 2, 2005

Nap Ghost
Well, references, const references, dynamic dispatch, and templates mostly. In practice you will also want some sort of smart pointers so that means you need some level of operator overloading too.

GCC has moved from C to a conservative subset of c++, and plenty of people do kernel development in c++. Not to say I like c++ by any stretch of the imagination but it can make certain things easier.

Adbot
ADBOT LOVES YOU

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

animist posted:

I mean you *can* write a kernel in Java or whatever it's just a terrible idea

wasn't microsoft trying to do something like that with c#?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Sapozhnik posted:

I'll be interested to see what bright line makes C++ unacceptable but Rust acceptable.

C has seen a great many :pcgaming: REVOLUTIONARY NEW PARADIGM :pcgaming: languages come and go over the years. You would probably need 1TB of RAM and some very high single-threaded performance indeed to compile a hypothetical Rust-ified Linux kernel in any reasonable amount of time, which is certainly not a point in favor of its adoption.

nobody is talking about converting the whole kernel to Rust, AFAICT, just letting people use it for drivers

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)

carry on then posted:

wasn't microsoft trying to do something like that with c#?
yeah, sort of: https://en.m.wikipedia.org/wiki/Singularity_(operating_system)

the main takeaway is that is was an attempt to make as much as the os managed as possible afiak

Cybernetic Vermin
Apr 18, 2005

animist posted:

I mean you *can* write a kernel in Java or whatever it's just a terrible idea

i am not the least bit convinced that it would be a terrible idea.

the main argument against it is that we already have kernels, and the problem domain they solve has been largely fixed for some time, so why bother ever writing one again?

animist
Aug 28, 2018

Cybernetic Vermin posted:

i am not the least bit convinced that it would be a terrible idea.

the main argument against it is that we already have kernels, and the problem domain they solve has been largely fixed for some time, so why bother ever writing one again?

I mean idt it's bad to periodically reinvent the wheel, if only to learn why they're shaped like that.

in terms of actual production poo poo though yeah, new kernels are a lot of investment for pretty questionable gains.

Sapozhnik
Jan 2, 2005

Nap Ghost
The hottest execution paths in a computer system tend to involve the kernel. Latency matters and you don't want a garbage collector messing with the heap in the background while those operations are ongoing.

Linux uses rcu everywhere to manage and amortize the cost of memory management, it's not something that can be efficiently automated away for this particular application. (edit: okay, more for managing reader-writer contention, but memory management does factor into it too)

The vast majority of software doesn't care as much about latency as it thinks it does though.

Sapozhnik fucked around with this message at 19:14 on Jul 12, 2020

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull

The_Franz posted:

by the time you stripped everything not suitable for a kernel environment out of c++, you'd basically just be left with c with basic classes, and even then there would be restrictions (e.g. no allocating in constructors)

existence proof: (although i don't see any restrictions on allocation in constructors, and keep in mind that the iokit restricted c++ dialect was created circa y2k)

Apple posted:

Apple considered several programming languages for the I/O Kit and chose a restricted subset of C++.

C++ was chosen for several reasons. The C++ compiler is mature and the language provides support for system programming. In addition, there is already a large community of Macintosh (and BSD) developers with C++ experience.

The restricted subset disallows certain features of C++, including

Exceptions
Multiple inheritance
Templates
Runtime type information (RTTI)—the I/O Kit uses its own implementation of a runtime typing system

These features were dropped because they were deemed unsuitable for use within a multithreaded kernel. If you feel you need these features, you should reconsider your design. You should be able to write any driver you require using I/O Kit with these restrictions in place.

Xarn
Jun 26, 2015

quote:

Templates

wat

mod saas
May 4, 2004

Grimey Drawer

Apple posted:

If you feel you need these features, you should reconsider your design.

you’re driving it wrong

Athas
Aug 6, 2007

fuck that joker

Sapozhnik posted:

The hottest execution paths in a computer system tend to involve the kernel. Latency matters and you don't want a garbage collector messing with the heap in the background while those operations are ongoing.

Really? My experience with high performance computing is that you try to avoid the kernel as much as possible (number crunching), or try to get the kernel to set up virtual memory so that devices can just directly DMA from process memory, and at least so that the kernel is not directly involved in e.g. memory copying. I'd be pretty skeptical any system that relied on a fast kernel to get performance. Most of the ugly performance-oriented stuff in Linux is about getting the kernel out of the way.

BobHoward
Feb 13, 2012

The only thing white people deserve is a bullet to their empty skull

Athas posted:

Really? My experience with high performance computing is that you try to avoid the kernel as much as possible (number crunching), or try to get the kernel to set up virtual memory so that devices can just directly DMA from process memory, and at least so that the kernel is not directly involved in e.g. memory copying. I'd be pretty skeptical any system that relied on a fast kernel to get performance. Most of the ugly performance-oriented stuff in Linux is about getting the kernel out of the way.

you're actually reinforcing his point

hpc is a special case where you are fine with going to extraordinary effort to maximize performance at all costs

i/o through the kernel is for the vastly more common cases where application software needs the kernel to act as a security and multiplexing and abstraction layer. it's very important for kernel i/o (and memory management, and scheduling) code paths to have bounded, predictable, and low latency. you do not want gc causing the whole kernel to grind to a halt for 100ms at random times

yes, you can do better in hpc by getting rid of the middleman, but you are simultaneously getting rid of all the features the middleman provides

Cybernetic Vermin
Apr 18, 2005

you would not allocate willy-nilly in one big heap obviously, it is not very hard to manage memory a lot more carefully while still retaining a lot of the advantages.

but, again, so entirely academic as: 1) there is no reason to undertake the effort with good kernels already being around without any of the potential downsides; and; 2) this entire hypothetical being incredibly underspecified (see above where i suddenly add design details not obviously implied by the initial statement).

redleader
Aug 18, 2005

Engage according to operational parameters

carry on then posted:

wasn't microsoft trying to do something like that with c#?

yeah. one of the tech leads wrote up a good blog series about one of their efforts

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

The_Franz posted:

by the time you stripped everything not suitable for a kernel environment out of c++, you'd basically just be left with c with basic classes, and even then there would be restrictions (e.g. no allocating in constructors)

turns out this is actually pretty nice though for building out reasonable abstractions while also getting reasonable performance, see IOKit

Cybernetic Vermin
Apr 18, 2005

btw, on the subject of higher-level contructs and virtual machines in kernel work: i'll just remind people about the weird and exciting world of the ebpf virtual machine hooks worming itself into more and more of the linux kernel. since the bytecode has to be automatically verified (loaded untrusted from userspace a kernel verifier needs to prove it correct/safe) they used to originally be tiny (4k instructions max) and loop-free, but those restrictions have been loosened to a full 1 million instructions and all loops needing to be verifiably bounded (https://lwn.net/Articles/794934/).

Antigravitas
Dec 8, 2019

Die Rettung fuer die Landwirte:
ebpf scares me, not gonna lie.

my homie dhall
Dec 9, 2010

honey, oh please, it's just a machine
ebpf is fully sick. one cool thing it lets you do is you can pretty much drop a debug statement anywhere in kernel code on a live system without too much of a performance hit. using it is a little clunky at first in terms of interface, but it’s a breeze to install and run on stock Ubuntu

Vanadium
Jan 8, 2005

there's a lot of individual c++ features that seem like a good idea, has there been research into which features or combination of features actually turn the whole thing into a huge mess?

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Vanadium posted:

there's a lot of individual c++ features that seem like a good idea, has there been research into which features or combination of features actually turn the whole thing into a huge mess?

things that are good:
templates
references
raii
constexpr is “good”
cppreference.com

I think we’ve about covered it

bad things:
templates
infinite ways to initialize
many obtuse parts of the stdlib, e.g. std::numeric_limits::min vs. max, idc if C did it this way it’s confusing (see note below about being dumb)
cplusplus.com

you’ll never get anyone to agree on what parts you should use, because it all ”works” and if you can’t use it then you must be dumb since the almighty committee sent it forth into the wild or the other guy is too dumb to understand it so you should do your own thing

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man
please don't reference cplusplus.com by name as someone might accidentally see it and look it up

Falcorum
Oct 21, 2010

animist posted:

I mean you *can* Java it's just a terrible idea

after dealing with java's xml landscape bullshit all day I'm inclined to agree.

Athas
Aug 6, 2007

fuck that joker
I never program in C++ anymore. What's wrong with cplusplus.com? Is it at least bad in an entertaining way?

Also, the syntax is a very bad part of C++.

Athas fucked around with this message at 21:50 on Jul 13, 2020

Jerry Bindle
May 16, 2003
java is a fantastic language wielded by the most extremely regarded programmers

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Athas posted:

Also, the syntax is a very bad part of C++.

eh the syntax is fine, especially in c++11 onwards

the bad parts for me

- it's easy to write terrible code from a multithreading/maintainability/memory management perspective, and it will happily work until it doesn't
> somewhat mitigated by RAII and modern practices but that's not really an option if you're working with a large ancient codebase
- standard library is, uh, okay; it has enough stuff in it but is a bit obtuse and hodge-podgey compared to most any modern standard library
- can be a bit verbose, I'm writing a C++ server/ Java client right now and I actually find Java less verbose outside of libraries - no headers, anonymous namespaces (c++98 so no lambdas), constness, more things already done
- exceptions are kinda garbage
- lots of gotchas and things to keep track of, from simple things like constness and virtuality to janitoring multithreading and smart pointers
- portability on linux is a nightmare if you need to support 10+ year old systems with a variety of distros and rely on multiple libraries, but I guess not everyone does

Private Speech fucked around with this message at 21:07 on Jul 13, 2020

Cybernetic Vermin
Apr 18, 2005

writing some more modern java atm and man it has nicely lightened up on verbosity by way of some simple sugar and a lot of more tidy (third-party) library design. very pleasant experience. zgc keeping gc interruptions consistently in the low single-digit milliseconds range in the system i'm working on too.

Kazinsal
Dec 13, 2011



Cybernetic Vermin posted:

btw, on the subject of higher-level contructs and virtual machines in kernel work: i'll just remind people about the weird and exciting world of the ebpf virtual machine hooks worming itself into more and more of the linux kernel. since the bytecode has to be automatically verified (loaded untrusted from userspace a kernel verifier needs to prove it correct/safe) they used to originally be tiny (4k instructions max) and loop-free, but those restrictions have been loosened to a full 1 million instructions and all loops needing to be verifiably bounded (https://lwn.net/Articles/794934/).

did the ebpf devs see that thing where a group of people ported lua as an NT kernel driver and looked at it as a challenge or something

Sapozhnik
Jan 2, 2005

Nap Ghost
linux wasn't really designed it just sort of happened

probably why it's so successful (other than being in the right place at the right time)

Xarn
Jun 26, 2015

Sweeper posted:

std::numeric_limits::min vs. max, idc if C did it this way it’s confusing (see note below about being dumb)

Do you mean for floating point types, or?

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Xarn posted:

Do you mean for floating point types, or?

yes, for floating point numbers

Lutha Mahtin
Oct 10, 2010

Your brokebrain sin is absolved...go and shitpost no more!

Sapozhnik posted:

linux wasn't really designed it just sort of happened

probably why it's so successful (other than being in the right place at the right time)

"what do we need to add to the next couple of releases in order to keep our big development sponsors happy" is technically a design

JawnV6
Jul 4, 2004

So hot ...

tinaun posted:

rust used to have a rule where no keyword or std type should have a name longer than 5 letters, so you had ret for return and loop instead of continue (and even sillier stuff like iface instead of trait)
normally im unqualified to have an opinion but ive checked it a few times and 'trait' is 5 letters?

Cybernetic Vermin
Apr 18, 2005

JawnV6 posted:

normally im unqualified to have an opinion but ive checked it a few times and 'trait' is 5 letters?

it's short for 'portraiture'

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

I think trait hadn't been considered yet at that point

Zlodo
Nov 25, 2006

Vanadium posted:

there's a lot of individual c++ features that seem like a good idea, has there been research into which features or combination of features actually turn the whole thing into a huge mess?

c++ have a lot of features like templates that have outgrown their original purpose and are very clumsy to use for what a lot of people now use them for

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Athas posted:

I never program in C++ anymore. What's wrong with cplusplus.com? Is it at least bad in an entertaining way?

no, it's just a boringly mediocre reference site with good seo

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



"trait" is not longer than 5 characters

Soricidus
Oct 21, 2010
freedom-hating statist shill

Vanadium posted:

there's a lot of individual c++ features that seem like a good idea, has there been research into which features or combination of features actually turn the whole thing into a huge mess?

that would be the programmers

Soricidus
Oct 21, 2010
freedom-hating statist shill

Cybernetic Vermin posted:

writing some more modern java atm and man it has nicely lightened up on verbosity by way of some simple sugar and a lot of more tidy (third-party) library design. very pleasant experience. zgc keeping gc interruptions consistently in the low single-digit milliseconds range in the system i'm working on too.

it’s good yeah

I’ve been reluctantly doing golang and drat it is ridiculous for a language whose design goals included “be less verbose than java” to require this much boilerplate

Adbot
ADBOT LOVES YOU

abigserve
Sep 13, 2009

this is a better avatar than what I had before
anyone got some good resources for learning general software engineering concepts?

A friend is interviewing somewhere and gave me some example questions that totally stumped me, but when looking up the terms used it was all things I'd done in practice before, I just never knew the name for them as I don't have that background ex. "SDLC"

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply