4 ms·
Agreed. But note that "faults at run-time", even with recovery procedures, can be very costly in some critical systems.
by the_af 12y ago
Agreed. But note that "faults at run-time", even with recovery procedures, can be very costly in some critical systems.
- seanmcdirmid 12y agoRun-time faults would happen even in a static language however, as those aren't just about tag match errors or NPEs. A really heavy-duty (dependant) type system is needed to get rid of resource (out of memory) and arithmetic faults (divide by zero), so those safety critical systems are more likely to be formally verified instead. Haskell is also completely unsafe when it comes to resource usage, which is why it is not used often in say avionics.
- dllthomas 12y agoYou can get rid of divide by zero without anything sophisticated. The key is that you cannot expose normal division. There are two reasonable solutions: Perform test in the operation: (/) :: i -> i -> Maybe i Require test before the operation: nonzero :: i -> Maybe (NonZero i) (/) :: i -> NonZero i -> i Both of these come at a cost, of course, of making some arithmetic expressions look less natural - which dependent types could probably help with.
- the_af 12y agoYes, runtime faults can happen in a static language as well. However, I don't buy the usual argument that follows up (not saying you are saying this now, but I'm sure you've heard it): "therefore, you're not better off using a statically typed language, therefore just use a dynamically typed language". Just because a statically typed language cannot rule out every kind of runtime flaw is not a good reason to stop using them. Statically typed languages rule out some errors that dynamically typed languages don't. In both cases you also need to perform additional checks, and in both cases, safety critical systems should be formally verified. Not "instead", but "in addition to". A statically typed language is an additional, automatic safety net on top of everything else. Every bit of safety counts. You don't need to formally verify your generic list algorithm isn't going to try adding two elements (and throw an exception when the elements cannot be meaningfully added) because it can't by definition. That's one less formal verification you need to do.
- seanmcdirmid 12y agoI never claimed dynamic languages were better, just that Haskell is a dynamic language with more static features than say Python. There are no truly static languages, except maybe perhaps static macro languages like C++'s STL. > In both cases you also need to perform additional checks, and in both cases, safety critical systems should be formally verified. Not "instead", but "in addition to". In practice, there are a lot of other things going on in Haskell that work against formal verification in safety critical real time systems. When you need to know for sure, non-determinism (say in the form of lazy evaluation) is your enemy, and the type system itself becomes less useful because those paths have to be rigorously explored anyhow. Heck, at that point, you might even want to use assembly since even the compiler is suspect. Thankfully, most of us don't write that kind of code. Pedantic: runtime is a thing that runs your program while run-time is a phase.
- the_af 12y ago> I never claimed dynamic languages were better, just that Haskell is a dynamic language with more static features than say Python. There are no truly static languages, except maybe perhaps static macro languages like C++'s STL. That's a pretty non-standard view. It's as unhelpful as static typing proponents claiming dynamically typed languages such as Python are "unityped". As unhelpful as Simon Peyton Jones jokingly claiming that Haskell is the world's best imperative language :) Any of those claims may be technically true, but it doesn't help us understand, choose or use those languages. Other similarly unhelpful claims include the old "these languages are all Turing-complete anyway, so it doesn't which one you use." So I disagree with you, philosophically, but since I acknowledge you're a very knowledgeable guy, let me ask you about your opinion: - Would you say there is no advantage to using a statically typed language like Haskell/ML over a dynamically typed language? - Or if you think there is an advantage, do you think the costs outweigh the benefits? - If you were asked to develop a safety critical system, and given the choice of using Haskell (or ML if you dislike lazy evaluation by default, or OCaml if you prefer a more hybrid language) and Python (or a similar dynamic language of your choice), and every other analysis tool you can think of, static or run-time, which language would you pick? Assume you cannot pick anything else, you're given time to become proficient on the language you pick, and you cannot refuse the assignment. I know, this is a fantasy scenario, but indulge me.
- codygman 12y agoWhy do you use the phrasing "heavy-duty (dependant) type system"? Are you of the opinion that dependant typing is overkill for general programming? What is your opinion of Idris?
- tel 12y agoDT is definitely heavy-duty. There are massive unsolved problems about how to make, say, proof management... basically even possible. This is part of what makes HoTT exciting, I believe, as it provides a formalized way of passing proofs and operations around over different types so long as there's a suitable homotopy. So while Idris is a very exciting research direction, it's completely fair to state that they have a hefty set of barriers to overcome before they truly demonstrate the value of DT in some larger variety of usecases besides just theorem proving.