4 ms·
> We have no theory of language error-proneness Language error-proneness is directly proportional to the rate of usage of mutability and side effects. Immutabl
by qwerty456127 9y ago
> We have no theory of language error-proneness
Language error-proneness is directly proportional to the rate of usage of mutability and side effects. Immutable references to immutable objects don't quirk and pure functions always do exactly the same thing (usually exactly what you expect them to do).
The first time I have tried Scala (having no prior functional programming experience) I was mesmerised with how well it worked: every successful build would result in a program doing exactly what it was supposed to do (run-time quirks or errors were extremely rare) and whenever a build failed it was usually rather easy to find and fix the failure reason.
- DonaldFisk 9y agoOther important causes of errors are weak typing, not checking array indices, numeric overflow, and manual memory management.
- kbwt 9y agoNone of which are exclusive to low level languages. They're just easier to recognize and point at.
- kbwt 9y agoIf you consider performance as a correctness issue, then functional and/or garbage collected languages have a very high incidence of bugs.
- DonaldFisk 9y agoIt's usually better to do the right things slowly than the wrong things quickly. In practice most speed improvements are made by improving the algorithm. With high level languages, you can do this faster. C still uses malloc and free, functional programs which don't dynamically allocate memory won't call the garbage collector, and there are fast garbage collection algorithms for the ones which do. Functional languages aren't intrisincally slow either. Strong static typing/type inference allows them to be compiled to very fast code.
- kbwt 9y agoThere is software which is already so optimized at the algorithm level, you have to use a low level language to fully exploit the hardware. For example with video games; if you can cram more/better content or achieve higher simulation fidelity/tickrate you improve the game experience and developers compete on that. These are programs where selecting a different instruction to split a loop-carried dependency makes a significant difference. Data is carefully packed and reorganized between passes to optimally match the cache hierarchy. Good luck selling these developers uncontrollable per-access indirections and thunks. Furthermore, this kind of code barely uses malloc/free, preferring instead to use custom allocation patterns tailored for each use case. If you replicate that in a higher level language, you effectively do your own memory management within a large block allocated by the runtime. So you are liable to write all of the same lifetime/indexing bugs in while using your shiny "safe" language.
- qwerty456127 9y agoTheoretically this can be true. I.e. you can write anything (good or bad, correct of quirky, fast or slow) adequate to your skills in C so being proficient enough you can potentially end up with a C program that would solve the same task faster than a functional/mixed program in Scala. In practice, however, real-world Scala programs usually run approximately as fast (or faster) than real programs real humans write in C as far as I know (and can be developed/modified much faster). And they are less prone to crash, expose a vulnerabilities, produce wrong results or have portability problems. But they indeed tend to require a way more memory than you would probably fit in if you'd go the old-school way using manual memory management, sharing and re-using memory regions as much as possible.
- klibertp 9y ago> pure functions always do exactly the same thing Unless there's a hardware error, OS error, language bug or any of the number of other circumstances which can messes up your assumptions. As Joe Armstrong said, you can't type-check being hit by a lightning, not to mention your pure function may never terminate simply because the thread it ran on was killed. > Language error-proneness is directly proportional Citation needed (and it doesn't matter to what exactly you think it's proportional at this point). A large-scale, confirmed independently a couple of times, academic study would do. In other words: it's not that simple, even if you choose to ignore performance. Immutable data and pure functions are great and should be used wherever it makes sense, but they are not a silver bullet.
- AnimalMuppet 9y agoAgree. qwerty456127 speaks as if mutation is the only source of errors. It's not. (And timing is not the only other source of errors. And hardware failure is not the only remaining source of errors. There's lots of ways that things go wrong.)
- qwerty456127 9y agoMutation is not the only source of errors but I believe it is the source of at least 80% (probably more) of errors.