HNHacker News
TopNewBestAskShowJobs

dukc

27 karma · joined June 21, 2022

submissionscomments
dukc··on D Blog: Memory Safety in a Systems Programming Language Part 3
Author here, ask me anything about it!
dukc··on D memory Safety with DIP1000
Author here, ask away!
dukc··on Memory Safety in a Modern System Programming Language Pt. 1
An optimiser may not treat null-dereferencing D code as undefined behaviour. It must either error at compile time (if it can prove the dereference would be null no matter what), crash at runtime, or derefer the null address, which also results in a crash.
dukc··on Memory Safety in a Modern System Programming Language Pt. 1
Used the wrong word. Meant "archaic", not "anarchic".

Side note, D has source code tools, this being probably the most famous one: https://github.com/dlang-community/D-Scanner . It's just that I don't use them myself.

dukc··on Memory Safety in a Modern System Programming Language Pt. 1
Nope. Memory safety means no undefined behaviour. Crashing is defined behaviour. Indeed, at least in the D philosophy it is better to crash than to just do something and continue when a bug is detected. If that were not the case, assertions in released code would be total humbug.

Now, detecting such errors statically at compile time is still valuable where it is practical. But it's common knowledge that no language guarantees no bugs. It follows that a complete "no crashing" guarantee is not even desirable, let alone part of a memory safety guarantee.

dukc··on Memory Safety in a Modern System Programming Language Pt. 1
Yes, that is correct. There are all kinds of gc-less containers implemented for D, including the standard library std.container.array that is much like C++ std::vector. The downside of those is that they are not entirely memory safe.

EDIT: Even slices do not mandate using the GC. The GC will only collect arrays registered to it in the first place. If the slice was malloced, it is not registered and thus won't be collected. The built-in ~ operator allocates the new array with the GC though, so you have do something custom to concatenate slices in GC-free code.

dukc··on Memory Safety in a Modern System Programming Language Pt. 1
I wrote it. Where's the problem precisely? I don't see it.
dukc··on Memory Safety in a Modern System Programming Language Pt. 1
D 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.
dukc··on Memory Safety in a Modern System Programming Language Pt. 1
I'm personally kind of anarchic, because I use hardly any tools. Text editor and terminal, that's how I program. The compiler is my linter. So I don't know.
dukc··on Memory Safety in a Modern System Programming Language Pt. 1
The 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.

dukc··on Memory Safety in a Modern System Programming Language Pt. 1
Author here. Fire questions away!