See e.g. DictShield for Python (https://github.com/j2labs/dictshield), Jackson for JVM (http://jackson.codehaus.org/), Swiz for node.js (https://github.com/racker/node-swiz)...
With dynamic languages, you have to hold a lot in your head. Having an enforced structure offloads some things off your brain so you have more mental space to think clearly and not panic or get burned.
class Stream s where
read :: s -> (a, s)
write :: a -> s -> s
and extend it to any type: instance Stream [Int] where
read s = ...
write a s = ...
instance Stream File where
...
and so on, and I can now pass any type that is a member of Stream, to a function that expects one.Contrast OCaml, an object type is represented as a set of (method, types) tuples and type-checking is a subset check (if type A has all the methods of type B, then it's a subtype of B regardless of anything else from visibility to semantics):
# let x =
object
method foo = 42
end;;
val x : < foo : int > = <obj>
# let y =
object
method foo = 63
method bar = 12
end;;
val y : < bar : int; foo : int > = <obj>
# x = y;;
Error: This expression has type < bar : int; foo : int >
but an expression was expected of type < foo : int >
The second object type has no method bar
# type simple = < foo : int >;;
type simple = < foo : int >
# (y :> simple) = x;;
- : bool = false
#http://en.wikipedia.org/wiki/Expression_problem
Anyway, there's been quite a few proposals to add extensible records to Haskell, which would allow row polymorphism, similar to what you just showed in OCaml:
http://hackage.haskell.org/trac/ghc/wiki/ExtensibleRecords
Too bad that it has gone nowhere in a long time.
No, I'm comparing structural typing, which is what Go implements, to nominative typing.
But that may very well be due to me having stayed in context of an other sub-thread where this was the subject, and using that as a filter for the current one.
Even if it was, one example of a difficult bug in one system does not invalidate a whole concept.
And duck typing is almost as old as programming itself...
If you want to know how real auto-complete works, try out IntelliJ. Auto-complete on Eclipse is like slowly being pecked to death by ducks.
A more accurate statement in my mind is "Eclipse makes Java palpable, IntelliJ makes Java fun."
I will give Eclipse a try.
[1]: https://github.com/nominolo/scion/
However, there is simply less drive to develop tooling like that for Haskell than there is for Java. Haskell is a much easier language to use given just a moderately intelligent text editor and a REPL than most others. Java, on the other hand, it verbose and annoying even with a very good IDE.
So Haskell can have good support, but since it isn't terribly necessary it isn't anything like a top priority.
http://www.infoworld.com/d/application-development/microsoft...
http://www.sublimetext.com/ https://github.com/DisposaBoy/GoSublime
Have you ever tried to auto complete the 'init' function in RubyMine? It will ask you which one of the 100 init functions do you mean. :)
Not with static typed language. There is only one init function to choose from because the IDE knows the exact type you are working with at all time.