Live data from Hacker News

Do We Create Type Systems In Dynamic Languages?

codethinked.com

1–10 of 27 posts

Re: Do We Create Type Systems In Dynamic Languages?

#2
Not if you are doing it right. The article context is unit testing a dynamic languages vs a static language, saying that you have to do more testing with a static language. If you do thorough unit testing, the difference isn't all that great. The article implied that unit testing doesn't need to be as thorough with a staticly typed language, That is just plain wrong. You may need to do some additional testing with a dynamic language, but overall you come out way ahead. Python instead of Java, you come out way ahead. Python framework vs a full Java framework, the difference may be 5x or 10x.

Re: Do We Create Type Systems In Dynamic Languages?

#3
I am an avid haXe user. It has static inferred typing with a "Dynamic" type, "untyped" blocks, and casting, all of which work more-or-less as advertised: the type system gets out of the way when you ask it to, and the rest of the time you get nearly-free type-checks. Sometimes it needs a little bit of annotation to help it along, but on the whole it's very handy for refactoring code.

In fact, I'm sure my iteration time goes up in haXe because I see most errors at compile-time. The ones I don't see are logic and uninitialized values.

ed: I mean time goes down, not up. Progress goes up.

Re: Do We Create Type Systems In Dynamic Languages?

#4
post #2

Not if you are doing it right. The article context is unit testing a dynamic languages vs a static language, saying that you have to do more testing with a static language. If you do thorough unit testing, the difference isn't all that great. The article implied that unit testing doesn't need to be as thorough with a staticly typed language, That is just plain wrong. You may need to do some additional testing with a…

The Python versus Java comparison is a red herring, I think. While Java is more verbose than Python, and some of that verbosity is from its type system, not all of it is.

A better comparison would probably be Python versus Scala, or Python versus OCaml.

Re: Do We Create Type Systems In Dynamic Languages?

#5
I think it's just wrong to test for the type of the variable, unless it's really needed. Such checking detracts from what you are trying to accomplish and from relying on the exception backtrace to give you a clue of what went wrong when an error occurred. Also relevant is that if you are trying to pass in a new object that should work despite not being a direct descendent of a certain object, by checking for a certain type you restrict the usefulness of the API. Even "mocking" a certain object can be more troublesome then.

That said, whereas many Rubyists can make more use of respond_to?(), I can make a few uses of is_a?() every now and then. They usually make use of more idiomatic Ruby that way than me.

On the Spec/Test side, I hope everyone is testing more functionality than types as I am sure the type checking is just redundant in Ruby. Speaking of redundancies, a famous motto is all you need to follow to keep it cool: "don't repeat yourself".

Re: Do We Create Type Systems In Dynamic Languages?

#6
post #4
post #2

Not if you are doing it right. The article context is unit testing a dynamic languages vs a static language, saying that you have to do more testing with a static language. If you do thorough unit testing, the difference isn't all that great. The article implied that unit testing doesn't need to be as thorough with a staticly typed language, That is just plain wrong. You may need to do some additional testing with a…

The Python versus Java comparison is a red herring, I think. While Java is more verbose than Python, and some of that verbosity is from its type system, not all of it is. A better comparison would probably be Python versus Scala, or Python versus OCaml.

True, but I speak of which I know. If someone has such a comparison, I would love to see it. The real measure is tokens not LOC.

Re: Do We Create Type Systems In Dynamic Languages?

#7
post #4
post #2

Not if you are doing it right. The article context is unit testing a dynamic languages vs a static language, saying that you have to do more testing with a static language. If you do thorough unit testing, the difference isn't all that great. The article implied that unit testing doesn't need to be as thorough with a staticly typed language, That is just plain wrong. You may need to do some additional testing with a…

The Python versus Java comparison is a red herring, I think. While Java is more verbose than Python, and some of that verbosity is from its type system, not all of it is. A better comparison would probably be Python versus Scala, or Python versus OCaml.

It's a surprisingly common fallacy to equate Java with Type Systems.

Type systems can be far more expressive than what is available in Java, and can and should be used to enforce program correctness, reducing the necessity for additional testing.

Type inference, polymorphic typing, structural types -- the available tools in a comprehensive type system are woefully under-explored by most practitioners who consider Java to epitomize type systems.

Re: Do We Create Type Systems In Dynamic Languages?

#8
post #6
post #4

Earlier quoted context omitted.

The Python versus Java comparison is a red herring, I think. While Java is more verbose than Python, and some of that verbosity is from its type system, not all of it is. A better comparison would probably be Python versus Scala, or Python versus OCaml.

True, but I speak of which I know. If someone has such a comparison, I would love to see it. The real measure is tokens not LOC.

Then your knowledge may be too constrained to derive sufficiently representative generalizations.

I can highly recommend:

http://www.xoltar.org/old_site/misc/static_typing_eckel.html...

The article (from 2003!) is an excellent treatise on the value of a proper type system as compared to Python, and moreover, how Java's type system (or C++, ...) should simply not be equated with "static typing".

Re: Do We Create Type Systems In Dynamic Languages?

#9
The more I have thought about fully dynamic languages that don't allow any form of static typing information, the more I have begun to think that they are not very useful. Sure, polymorphism is nice, overloading is nice, but all of the programs I have written, have relied on some sort of typing discipline, be it dynamic, static or whatever. I can't imagine writing a useful function for which I wouldn't know what it's type is. Just because Java, C++ etc. implement static typing poorly, doesn't mean static typing has to suck when there are many languages that have inferred static typing, which in my opinion can provide best of both worlds.

EDIT: By "best of both worlds" I mean "concise code and the benefits of the program being well typed"

Re: Do We Create Type Systems In Dynamic Languages?

#10
post #5

I think it's just wrong to test for the type of the variable, unless it's really needed. Such checking detracts from what you are trying to accomplish and from relying on the exception backtrace to give you a clue of what went wrong when an error occurred. Also relevant is that if you are trying to pass in a new object that should work despite not being a direct descendent of a certain object, by checking for a certa…

Functions only work for a very specific set of input types. On all other inputs, something goes wrong, but that 'something' can take quite a bit of investigating to figure out. Therefore, an assertion that verifies that the input is indeed part of that specific set of input types is valuable: it catches the problem at the earliest possible moment and it pinpoints the exact problem.
Post reply on HN