|
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.
|
# ? Jul 12, 2020 16:06 |
|
|
# ? Apr 26, 2024 18:35 |
|
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#?
|
# ? Jul 12, 2020 17:54 |
|
Sapozhnik posted:I'll be interested to see what bright line makes C++ unacceptable but Rust acceptable. nobody is talking about converting the whole kernel to Rust, AFAICT, just letting people use it for drivers
|
# ? Jul 12, 2020 18:09 |
|
carry on then posted:wasn't microsoft trying to do something like that with c#? the main takeaway is that is was an attempt to make as much as the os managed as possible afiak
|
# ? Jul 12, 2020 18:12 |
|
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?
|
# ? Jul 12, 2020 18:20 |
|
Cybernetic Vermin posted:i am not the least bit convinced that it would be a terrible idea. 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.
|
# ? Jul 12, 2020 18:24 |
|
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 |
# ? Jul 12, 2020 19:11 |
|
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++.
|
# ? Jul 12, 2020 19:54 |
|
quote:Templates wat
|
# ? Jul 12, 2020 19:56 |
|
Apple posted:If you feel you need these features, you should reconsider your design. you’re driving it wrong
|
# ? Jul 12, 2020 20:12 |
|
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.
|
# ? Jul 12, 2020 20:40 |
|
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
|
# ? Jul 12, 2020 21:49 |
|
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).
|
# ? Jul 12, 2020 21:57 |
|
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
|
# ? Jul 12, 2020 22:18 |
|
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
|
# ? Jul 13, 2020 09:55 |
|
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/).
|
# ? Jul 13, 2020 12:32 |
|
ebpf scares me, not gonna lie.
|
# ? Jul 13, 2020 13:09 |
|
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
|
# ? Jul 13, 2020 13:29 |
|
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?
|
# ? Jul 13, 2020 19:40 |
|
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
|
# ? Jul 13, 2020 19:54 |
|
please don't reference cplusplus.com by name as someone might accidentally see it and look it up
|
# ? Jul 13, 2020 20:07 |
|
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.
|
# ? Jul 13, 2020 20:09 |
|
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 |
# ? Jul 13, 2020 20:32 |
|
java is a fantastic language wielded by the most extremely regarded programmers
|
# ? Jul 13, 2020 20:34 |
|
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 |
# ? Jul 13, 2020 20:50 |
|
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.
|
# ? Jul 13, 2020 20:54 |
|
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
|
# ? Jul 13, 2020 21:12 |
|
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)
|
# ? Jul 13, 2020 21:14 |
|
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?
|
# ? Jul 13, 2020 21:40 |
|
Xarn posted:Do you mean for floating point types, or? yes, for floating point numbers
|
# ? Jul 13, 2020 21:51 |
|
Sapozhnik posted:linux wasn't really designed it just sort of happened "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
|
# ? Jul 13, 2020 21:56 |
|
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)
|
# ? Jul 13, 2020 21:59 |
|
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'
|
# ? Jul 13, 2020 22:04 |
|
I think trait hadn't been considered yet at that point
|
# ? Jul 13, 2020 22:07 |
|
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
|
# ? Jul 13, 2020 22:37 |
|
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
|
# ? Jul 13, 2020 23:58 |
|
"trait" is not longer than 5 characters
|
# ? Jul 14, 2020 00:13 |
|
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
|
# ? Jul 14, 2020 00:16 |
|
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
|
# ? Jul 14, 2020 00:21 |
|
|
# ? Apr 26, 2024 18:35 |
|
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"
|
# ? Jul 14, 2020 00:48 |