4 ms·
Not a Haskeller, but I'd like to try to change your mind about this point: > We are just trying to build things here. Some languages are built to do engineeri
by derefr 6y ago
Not a Haskeller, but I'd like to try to change your mind about this point:
> We are just trying to build things here.
Some languages are built to do engineering first-and-foremost. Languages like Haskell are built to do mathematics in first-and-foremost. This doesn't mean that such languages aren't also well-engineered, or that they aren't also tuned to do engineering in; but the engineering concerns must be subordinated to not breaking the model that mathematicians rely upon to do math in the language. So you can't just e.g. change whether a particular kind of function can emit IO or not; or change what values exist as part of the lattice of a type; or any number of other things visible within the language's abstraction; because those very properties/constraints are also syllogisms which are relied upon in mathematics done in the language.
And before you say "why not just break the runtime model", by e.g. having special debug functions that can do IO while presenting to the runtime as pure functions—well, it's not impossible, in theory, but it's a Hard Problem, because those properties that a function presents to the runtime are also used by the compiler to optimize (or memoize, or fuse, or eliminate) code. You can't really declare something as a pure function without the runtime thinking it can do all sorts of things that result in the function being called less.
In theory, Haskell could have something like a "volatile" qualifier for functions, sort of like C's volatile qualifier for data, to tell the runtime that while the function has type X, all optimization opportunities that would normally apply to type X are off the table. Then you could have special debug functions of type X. It's just that getting this working would require a lot of re-work throughout the compiler, since the compiler mostly deduces optimization opportunities from the type (and marks something as having more optimization opportunities by proving that it has an extra applicable type), rather than just tracking some separate metadata that can be arbitrarily written to.
- pron 6y agoAnd in theory, Haskell could be exceptionally fast, or exceptionally correct, or exceptionally maintainable while in practice it is none of those things. It is, however, a relatively elegant language that explores interesting ideas and that some people enjoy, and that's great!
- dddbbb 6y agoI honestly think that Haskell's combined speed/correctness/maintainability is exceptional, none is in isolation, but I can't think of any reasonably production-ready language that has such a great combination of all three.
- deleted 6y ago[deleted]
- pron 6y agoI honestly think it's well behind some of the most popular mainstream languages in that combination, and that that's why we haven't seen a proliferation of Haskell even at companies where it is already actively used for some years alongside other languages.
- a1369209993 6y ago> In theory, Haskell could have something like a "volatile" qualifier for functions foo :: IO X Haskell already has that, it just shoves the compiler re-work off on the programmer.
- derefr 6y agoThe point of what I said is that in many cases, lifting a function into a monad means that the code that uses said function can no longer be used to prove what you set out to prove by writing it.
- a1369209993 6y agoYes, exactly: a function that requires a volatile (or IO) annotation is one for which (some of) the things you could use a non-volatile function to prove are not actually true. If you want to lie to the compiler[0], unsafePerformIO, seq, and other unsound primitives are available and documented. Contrariwise, if you want to not lie to compiler, the primitives for that are also available and documented. 0: Which is a completely resonable thing to do, and the basis of any language's standard library, the ability to recapitulate which in normal code separates good languages from Go-like special-cases-for-me-but-not-for-thee languages.
- spekcular 6y agoWhat do you mean by, "Languages like Haskell are built to do mathematics in first-and-foremost"? It's hard for me to find a reasonable interpretation of this sentence that is true. I'm not sure much serious mathematics is done is Haskell, beyond the usual arithmetic operations present in most programs, especially relative to other programming languages. It hasn't taken off in the numerical computating market, for example. Historically, it also seems like Haskell was built as a research language.
- goatinaboat 6y agoI'm not sure much serious mathematics is done is Haskell, beyond the usual arithmetic operations present in most programs, especially relative to other programming languages. It hasn't taken off in the numerical computating market, for example. All that stuff about types and categories and monads and so on is maths too. Arithmetic or numerical work is only a subset of that field. Lots of maths doesn’t even involve numbers!
- gowld 6y agoEverything in computers is math. Floating point numbers are math. Java generics with inheritance are math. It's not a point of distinction.
- spekcular 6y agoSo let me ask again: in what sense do people "do mathematics" in Haskell? They don't really "do" category theory, for example; simply noting that something forms a category is mathematics only in the most trivial sense.
- BeetleB 6y ago> All that stuff about types and categories and monads and so on is maths too. I think the question he's asking is: What papers have been published in math journals where the work was done in Haskell? Which mathematicians use Haskell to do mathematics work?
- throwaway518365 6y ago
- mrkeen 6y agoYou say you're not a Haskeller, so I'm going to take what you say about the compiler internals with a grain of salt. > And before you say "why not just break the runtime model", by e.g. having special debug functions that can do IO while presenting to the runtime as pure functions—well, it's not impossible, in theory, but it's a Hard Problem. import Debug.Trace square x = trace "I'm a Hard Problem" (x * x) main = print (square 3)