6 ms·
Memory Safety in a Modern System Programming Language Pt. 1
- verdagon 4y agoIt's amazing what strides languages are making in the realms of memory safety. I think D's got the right idea, to have pockets of zero-cost memory safety, on top of an overall architecture that embraces shared mutability's benefits. A lot of languages are going this direction too: * Cone is putting a full borrow checker on top of GC, RC, and single ownership: https://cone.jondgoodwin.com/ https://cone.jondgoodwin.com/ * Vale is putting opt-in "region borrow checking" on top of single ownership with generational references: https://verdagon.dev/blog/zero-cost-refs-regions https://verdagon.dev/blog/zero-cost-refs-regions * Lobster is employing an automatic-borrow-checker-esque algorithm on top of RC for some brilliant speedups: https://www.strlen.com/lobster/ https://www.strlen.com/lobster/ * Ante has some designs for lifetime inference, which I think will work really well: https://antelang.org/ https://antelang.org/ * HVM is a runtime for Haskell that uses borrow checker semantics and falls back to clone. It's not shared mutability, but Haskell without GC is pretty cool! https://github.com/Kindelia/HVM https://github.com/Kindelia/HVM I particularly like D's approach because it's opt-in; we can use it in the areas of the program where we need performance the most, and prioritize flexibility and development velocity everywhere else, which I think is the right balance for most programs developed today. It also means one can gradually ease into learning how to use static analysis and their more complex constructs (like return scope, mentioned in the article). One can be proficient in the basic language quickly, and then improve their craft gradually. In modern software engineering, this is a big win, in my opinion. Props to D for going this direction!
- 3a2d29 4y agoAs much as I don’t want to complain about all the new low level languages (it’s really cool to see so much innovation!) But I can’t help but feel a bit overwhelmed with options, and I know very few will ever catch on. At least D seems to have some momentum, but I have fallen into the trap before of learning new languages that die. I want to learn one of these, but I want it to last!
- dukc 4y agoD is pretty safe choice in that regard. It has been around 20 years already and still marches on. Also it has many companies using it that depend on it. So while there is no guarantee it will ever be among top-10 languages, it's unlikely to die off anytime soon either.
- verdagon 4y agoFor sure. Most of those are pretty young and experimental, so I'm glad D is adding something solid!
- acehreli 4y agoD is not popular but has a strong long-time following.
- skyde 4y agowhat about Rust ? Is rust not trying to be memory safe ?
- verdagon 4y agoRust has a great approach to memory safety for plenty of use cases, but I personally believe that the future lies with languages that have a more seamless blend between shared mutability and static analysis. Going all-in on borrow-checked single ownership causes a bit too much complexity, in my opinion. I would be very interested in any advances in the Rust realms that could address the added complexity! I haven't heard much coming from that direction. Polonius sounded like it would remove some edge cases from borrow checking, but it didn't seem like it would really help with the fundamental complexities from borrow checking.
- rayiner 4y agoGlad to see experimentation in this space, because I'm not quite sure Rust hits the optimal point in the design space. I think some of Rust's complexity is due to lacking what Cyclone calls regions and having to always deal with lifetimes, which can get complex: https://www.cs.umd.edu/~mwh/papers/cyclone-cuj.pdf https://www.cs.umd.edu/~mwh/papers/cyclone-cuj.pdf.
- bitwize 4y agoI would say "Bring the Burroughs system architecture back"... but we might actually be doing that with CHERI!
- languageserver 4y ago> This compiles and is fully memory safe, despite dereferencing those pointers in the same completely unchecked way they are dereferenced in C. This is memory safe because @safe D does not allow creating an int* that points to unallocated memory areas, or to a float*, for instance Who on Earth wrote this? This is not at all true.
- dukc 4y agoAuthor here. Fire questions away!
- avrionov 4y agoWhat do you think prevents D to become more popular? It seems Rust and Go captured some of the mind share of D.
- metadat 4y agoWhy isn't D more popular? (2014) https://news.ycombinator.com/item?id=7692230 https://news.ycombinator.com/item?id=7692230 (25 points, 16 comments)
- dukc 4y agoThe short answer is, I really don't know. There are lots of speculation about that around. The only confident opinion I have is that good does not mean popular and vice-versa. But since you asked, I think I should make my guess. I think people tend to use what life brings them to. Most will not voluntarily go hunting for the best language the Internet has to offer for them. So the languages become popular by forcing people to learn them, by having them to use them at their jobs or implementing important APIs in them. This means that what the project managers of big organisations have enthusiasm or business reasons to push tends to end up popular, not what is preferred by the common programmer. D is largely a free-time volunteer effort AFAIK so it does not get as much corporate influence than it would get if it were an academic or commercial effort. But again, that is just a gut guess, no research to back this up.
- mattarm 4y agoI think your second paragraph rings true. I also think there is a cost to using a non-mainstream technology that is often overlooked or under-estimated. I also think the benefits of non-mainstream languages are often over-stated. In other words, when you really look at the details the cool/niche languages do often have notable drawbacks. I suspect that for most organizations the pro/con or cost/benefit comparisons of C++ vs. D don't often come out in D's favor and never did. In the early days D chose to use GC which today, and for the past 30 years I have done C++ work professionally, has always been a dis-qualifier (mainly because of the extra memory overhead involved as well as the GC pauses). I have always looked at D with some interest, but never come close to formulating an argument that I could take to my company and suggest we start using D where we currently use C++. C++ almost uncompromisingly holds true to its backwards compatibility goals with C and the early versions of itself. C++ also almost always holds true to its "zero overhead abstraction" goals. D chose GC and replaced its standard library at one point. It is an interesting language for sure, but I think there are some things C++ has done better, from a practical use point of view, at least for the use cases where its use is still justified today, by being a more conservatively designed language.