r/ProgrammingLanguages • u/ThomasMertes • Oct 14 '26
Improved article about memory safety
Thank you to everyone who gave feedback on my article about memory safety.
I used the input to vastly improve the article (see "Achieving memory safety").
Please take a look and share your thoughts again and consider starring the Seed7 project on GitHub.
13
Upvotes
View all comments
Show parent comment
4
u/Athas Futhark Oct 14 '26
In Haskell, whether or not the function can do IO is part of the type system. If you have a function of type
Int -> Int, then it cannot possibly do any kind of IO operation (assuming you're not using escape hatches likeunsafePerformIO, but those can be disabled). Haskell is however coarse-grained, so if you have a function of typeInt -> IO Int, then it can do any kind of IO, including going into/devand/procto subvert process memory (or more directly just use library IO functions to mess with the process). Despite its coarseness, this is still a pretty useful distinction in practice, although it is not something you can retrofit onto a classical language. A major current research topic in programming languages is to make this distinction more fine-grained, so we can talk more precisely about which effects a function may have. Look up languages like Koka or Flix as examples of languages with "effect systems". Personally I am skeptical of splitting up true IO effects, as once you can read/write files, you can do basically anything.Indeed, but proofs of implementation correctness are so rare that we usually cannot expect them. Also, implementation bugs are reasonably easy to fix, whilst fundamental unsafety in the language design is much harder.
I should note that my guesstimate is certainly that Seed7 is memory safe, because it omits the features that usually lead to memory unsafety. It doesn't even have threads, as far as I can see, which is otherwise sometimes a way in which unsafety can sneak in undetected.