Earlier quoted context omitted.
you can't sprinkle debug prints in Haskell? really? (honest question)
Short answer: No, you can't. Long answer: You can, but Haskell is very serious about keeping pure code separate from impure code. Any function which performs I/O is impure, so its output must be an IO Thing instead of just a Thing. This means anything that uses its output must accept an IO Thing instead of an ordinary Thing, and so on. Of course, the way I/O works means that a 'Type1 -> Type2' function into can be tr…
John Carmack: Thoughts on Haskell [video]
141–150 of 153 posts
Re: John Carmack: Thoughts on Haskell [video]
#142Earlier quoted context omitted.
Pure FP doesn't have variables. It has bindings.
This seems like splitting hairs.
Re: John Carmack: Thoughts on Haskell [video]
#143Earlier quoted context omitted.
You're simply wrong. That's not how the term "variable" works. From http://en.wikipedia.org/wiki/Variable_(mathematics) : "Varying, in the context of mathematical variables, does not mean change in the course of time, but rather dependence on the context in which the variable is used."
Math doesn't have vars, only vals
Re: John Carmack: Thoughts on Haskell [video]
#144Earlier quoted context omitted.
assert()s prove that something isn't happening. Types prove that something cannot happen.
Types prove that something cannot happen in the formal system the program represents. In the real world, though, radiation can flip memory bits into impossible positions, drive blocks can fail and spit random garbage, IPC messages can get dropped on their way to the receiver, etc. Sadly, even when your system is pure and elegant and you've proven it all out, you still need runtime asserts (and more advanced things li…
Re: John Carmack: Thoughts on Haskell [video]
#145Earlier quoted context omitted.
This seems like splitting hairs.
When combined with lexically scoped closures, if you try to shadow your value bindings in a functional language and expect it to work the same way as mutating a variable does in an imperative language, you're in for a surprise.
Re: John Carmack: Thoughts on Haskell [video]
#146Earlier quoted context omitted.
While i can see his point, I'm not entirely sure this is the case. A text-book example of a multi-paradigm language is Scala. And yet with Scala, the more I've learned about the functional side of things, the more tempting it is just to avoid any imperative or object-oriented idioms or patterns and just go functional all the way. it's almost as if the designers of scala knew if they could convert java programmers ove…
My experience with Scala was the opposite: it has great support for OO and imperative programming. The functional way of doing things often wasn't better, while on the other hand, traits are crazy flexible. I've seen people go crazy with functional code in Scala that is barely readable and impossible to debug; the JVM debugger is still optimize for imperative programs, while no one has really figured out a good debug…
Re: John Carmack: Thoughts on Haskell [video]
#147Earlier quoted context omitted.
Short answer: No, you can't. Long answer: You can, but Haskell is very serious about keeping pure code separate from impure code. Any function which performs I/O is impure, so its output must be an IO Thing instead of just a Thing. This means anything that uses its output must accept an IO Thing instead of an ordinary Thing, and so on. Of course, the way I/O works means that a 'Type1 -> Type2' function into can be tr…
Whoa, really? You have to use a monad just to print text to stdout in Haskell?
I.e., if your program needs top 3 results in a race, then you can safely use a function that returns all the results, but since you afterwards use only first three then the remainder aren't calculated, that code most likely isn't run and the order of any "embedded" print statements would be undefined.
That being said, standard Debug.Trace module allows simple adding of debug prints anywhere.
Re: John Carmack: Thoughts on Haskell [video]
#148Earlier quoted context omitted.
That's a good point. People don't understand that functional purity in Haskell, while a nice goal, isn't a law, you can break it if you have a good reason to. IO is sort of the canonical example, it isn't there to prevent you from doing IO, it's there to act as a giant warning sign that either this function, or one of the functions it uses isn't pure. Likewise mutable data structures while not the default, can be imp…
The problem is that "all things being equal" never happens because immutable data structures have worse performance if not used in a way that benefits from persistence. IMO, that makes them a poor default.
:) You could say that "all things being equal" never happens because mutable data structures have worse persistence if they're not used in a way that their performance matters. But also, different defaults make sense for different problem domains.
Re: John Carmack: Thoughts on Haskell [video]
#149Earlier quoted context omitted.
If you'll go read his opinions, you'll see that he has been a strong advocate for static analysis. His position is very understandable since he spent a lot of time working on complex pieces of C/C++ code, encountering a lot of subtle accidental errors that could have been avoided with better tools for static analysis or with a better language. He also worked mostly on client side software, where the fail fast / fail…
Tim Sweeney (Unreal Engine) has also written about haskell and specifically STM ( http://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-... ) and more recently on dependently typed languages ( http://arxiv.org/pdf/1307.5277v1.pdf ).
Re: John Carmack: Thoughts on Haskell [video]
#150Earlier quoted context omitted.
Math doesn't have vars, only vals
That's a rather strange assertion, if you mean "variables" and "values." Math distinguishes between variables and values. Variables have different values. Values can be bound to variables. Sometimes we do math with mostly variables and few values -- that's called algebra.
val y = Console.readInt
var x = y + 1
x = y + 2 //valid
y = 5 //error, vals can't be changed in the same block