Live data from Hacker News

Memory Safety

memorysafety.org

151–157 of 157 posts

Re: Memory Safety

#151

I find it strange that this web site completely ignores the Java ecosystem, which offers memory-safe implementations for most of the protocols and services listed.

Can I use the Java implementations in another language without significant headache?

Depends on what is done, GraalVM supports native libraries.

https://www.graalvm.org/latest/reference-manual/native-image...

Then again, many times OS IPC is a much better option.

Re: Memory Safety

#152

Earlier quoted context omitted.

is there actually a programming language that makes race conditions impossible (I am not being facetious, I actually do not know)? if the existence of races makes a language unsafe, then aren't all languages unsafe?

Python has that property when you don't bring C extensions into the conversation. Data races exist, but can never cause memory corruption due to the GIL.

GIL is on its way out already in 3.14 onwards.

Re: Memory Safety

#153

Earlier quoted context omitted.

is go not memory safe? other than unsafe and other contrived goroutine scenarios, isn't it? I'm actually really curious - I've been writing go for just a couple years now and my understanding is the only ways for it to be unsafe are the two scenarios I described earlier.

Go is absolutely memory safe in the sense used by Prossimo and software security. It's not "safe" in an academic sense used by almost nobody except message board language warriors.

Usually it is Rust message board language warriors.

Which also overlook how Rust type system can be subverted to actually allow for data races, with some help of linker scripts and OS IPC primitives.

Re: Memory Safety

#154

I find it strange that this web site completely ignores the Java ecosystem, which offers memory-safe implementations for most of the protocols and services listed.

Java does fine on memory safety, but does not do great on null safety (and overall invariant protection / "make invalid states unrepresentative" ethos), has difficult to harden concurrency primitives, and won't be adopted in many scenarios due to runtime cost and performance pitfalls. Future Valhalla work fixes some of these issues, but leaves many things spiky.

There's nothing stopping you from writing code that is completely functional and devoid of nulls these days. It's just that java obviously still allows nulls if someone needs to use them (partly for interoperability with legacy code)

But if you're going to argue about the mere presence of null being problematic, you might as well complain about the ability to use "unsafe" code in Rust too.

Re: Memory Safety

#155
post #149

Earlier quoted context omitted.

I'm not talking about null safety in the sense of null pointers. Null pointers and out of bound pointers are still in the realm of memory safety, which of course Java has solved for the most part. Proper null safety (sometimes called void safety) is to actually systematically eliminate null values, to force in the type system a path of either handling or explicitly crashing. This is what many newer expressive multi-p…

Java introduced Optional to remove nulls. It also introduced a bunch of things to make it behave like functional languages. You can use records for immutable data, sealed interfaces for domain states, you can switch on the sealed interface for pattern matching, use the sealed interfaces + consumers or a command pattern to remove exception handling and have errors as values.

using an instance of a sealed class in a switch expression also has the nice property that the compiler will produce an error if the cases are incomplete (and as such there's also no need for a default case). So a good case for the "make invalid states unrepresentable" argument.

Re: Memory Safety

#156

Earlier quoted context omitted.

No they’re pretty important these days now that basic linear overflows and the like are harder to exploit

OK, show us all the data race code execution CVEs in Go code.

I was discussing data races in the scope of all memory unsafe languages, I don't really know enough about Go to know whether people are looking for these.

Re: Memory Safety

#157
post #113

Earlier quoted context omitted.

If you have both sides cooperating, then it's perfectly reasonable to write a safe interface on top of shared memory. If not…well, what do you suggest? Also, pointing at the overwhelming majority of code and going "this is a very specific use case" is also kind of wild, because even in IPC scenarios there will be in-memory data that needs protection.

What I suggest is getting the marketing message correctly.

What should it be?
Post reply on HN