I don't think Haskell itself will ever be the language of choice, it'll probably fall into (remain in?) a smalltalk like life.
That said, functional idioms seem to be creeping into lots of mainstream languages, so it's not like never. Rust seems pretty heavily influenced by ml, and somewhat by haskell.
Functional programming is arriving right now, but not as Haskell.
As an aside, I think of Haskell as a sensei/guru saying, "Young grasshopper, if you want access to the glory that is my wisdom you will have to wash my dishes and scrape off my calluses for the next three years" to which my personal reply is "Hell no". It¨s unfriendly and it doesn't respect my time. Is there wisdom in Haskell? Probably, but I don't have the patience to deal with the bullshit.
I'm not sure how this is different than introducing a block in C.
What would be the C equivalent of:
(let ((last-response))
(defun get-response ()
(print last-response)
(setf last-response (read))))
(print (get-response))
(print (get-response))
Notice that no other function can use last-response. It only exists for get-response, but it exists outside the scope of get-response. Does C have this?Since the variable in question is only used in one function, you could declare the variable static to that function. It takes some care to make this reentrant, but that's possibly the case in lisp as well.
To share between multiple top-level functions, you can only limit scope to the individual file.
The bigger thing C can't do that lisp can here is defining new functions in arbitrary places. In C variants where you can define local functions, you can indeed capture variables in local scope. And within a function, you can limit scope by creating a new block:
int test() {
int foo = 7;
{
int foo = 9;
}
return foo; // returns 7
}
Even in those C variants, you can't place a new function in global scope from within a function. (let ((x))
(defun func1 ())
(defun func2 ()))
This is what I mean when I say explicit scoping. And it means that the reader/debugger/maintainer knows that this variable only exists for these functions. A static variable's scope is implied by the scope of whatever it's defined in (not sure if that's limited to functions in C), in this case X exists outside of C and has it's own scope, not just it's own extent.Yes, I mentioned that static variables in a function would not extend to multiple functions.
You can share a variable between a restricted set of top level functions by grouping those functions in a single object file that does not expose the variable in question.
I think my only objection is that your phrasing implied what's different is the explicitness of the scoping, when it's actually the flexibility of how functions can be defined (unsurprising, from a lisp).
In the case of Haskell, it is taken as a badge of virtue, and it is a matter of faith that the problem is just that all other programming languages have mis-educated everyone who doesn't "get religion" about Haskell.
If Haskell's interface is hard to understand, that is a problem with Haskell.
Evidence that Haskell was deliberately made difficult to understand? And supposing this were true, why hasn't anyone made the interface more intelligible?
> If Haskell's interface is hard to understand, that is a problem with Haskell.
That's a bit like saying that if the mathematics used in the General Theory of Relativity is hard to understand, it is a problem with the General Theory of Relativity.
Well, but that's true; if there were easier-to-understand mathematics that had equal utility, it would be superior. The math being hard to understand is a problem, but (as far as anyone can tell), its a necessary cost with General Relativity.
So, for Haskell -- granting, for the sake of argument, that it is particularly hard to understand (which I'm not sure is really the case) -- the question is the complexity a necessary price for some benefit that is worth the cost?
And before you think I'm just hating on Haskell, the same is essentially true of Lisp as well.
Mainstream languages have lambdas, more immutability and stronger types? That's great (non-sarcastically!). Haskell now has GADTs, rank-n types, polymorphic kinds, type families (poor name for type-level functions), and more.
These things make Haskell still quite compelling over other more mainstream languages, if you're willing to learn.
In some sense, yes. On the other hand, there are diminishing returns. As an example, the increase in software quality from a Java-like language adopting any of algebraic data types, parametric polymorphism or first class higher order functions is probably much bigger than Haskell moving to full on dependent types.
In any case, your point stands and complements mine.
(Apropos ADTs, did Scala always have them? From what I can tell their syntax is pretty awkward, though.
Google's Protobuf, which in some sense denotes a type system, even if not a programming language, did get something like ADTs: https://developers.google.com/protocol-buffers/docs/proto3#o...
I am pretty lenient, and would go for anything that resembles a compiler-enforced tagged union. (Think C-style union.))
http://www.boost.org/doc/libs/1_60_0/doc/html/variant.html ??? (and I think it's supposed to be coming in c++17)
either :: (a -> c) -> (b -> c) -> Either a b -> c