3 ms·
By using a GC language or something like Rust, you (in theory) avoid a few of these, but the majority of them are logic errors that are hard to discover, IME.
by candiddevmike 3y ago
By using a GC language or something like Rust, you (in theory) avoid a few of these, but the majority of them are logic errors that are hard to discover, IME.
- bestouff 3y agoBy using a GC language you avoid a few of them. By using Rust with a proper framework you should avoid most of them, if not all. A proper type system can save your ass very often.
- srgpqt 3y agoEven C has a (simple) type system. The problem is that everyone (especially the standard library) take every opportunity to avoid it, instead casting everything to plain void pointers or char pointers. Thus the compiler can’t do much for safety checks. The good news is that you can build typesafe alternatives on top of the underlying std crap. Would be nice to have a standard <stdstruct.h> that provides common typesafe structs for things like os paths, sql strings, html strings, etc. just like <stdint.h> did for sized integers. I’ve rolled my own typesafe wrappers fo my current C project and it’s been great so far.
- mrighele 3y agoA type system can help with injection issues. For example you could say that user provided strings are different from literals or from those that you provide. You then allow the user to concatenate them together only by passing through functions that quote the user provided ones. This should make very difficult to make injections, or at least avoid honest mistakes
- usrusr 3y agoTypes that carry a semantic difference, not a difference on the level of technical implementation are a fascinatingly underutilized concept. I'm sure that the idea has been around forever, and implementations available as well, but it never really made the big splash that I think it should have. I even carry a "what if" language concept in my mind (as in zero plans of implementation or anything like that, merely a thought experiment) where all names would be folded into types: in a lot of scopes you only ever have one of each. If you were to run Noah's ark you'd probably not bother remembering that you called the male penguin Frederick (or was it James?), you'd simply refer to him as the male penguin. The tools tools you'd want for dealing with all the situations where you need more than one in a scope would be just what the doctor ordered for that include semantic difference in typing thing.
- grncdr 3y agoYou may be interested to know that the Ceylon language has this (or had something very similar, I’ve not actually used it myself)
- lolinder 3y agoThe top 8 are either memory errors or errors that stem from joining strings. Memory errors are largely solved by using the right language, and we've known for decades not to join strings manually. SQL prepared statements are a thing, and modern templating engines escape HTML by default, with a suitably scary name for the opt-out function. Building similar tooling for OS calls and path traversal should be pretty trivial.