Hacker News new | past | comments | ask | show | jobs | submit login

> writing out a type (= a few characters) is negligible anyways when compared to the time you spend thinking about what the type is

Writing out a type is only a few characters if it's a type that's already built into your type system. (In which case, as others have already pointed out, you probably won't have to write it anyway in a statically typed language because the type system will automatically infer it. But in such cases, you're not gaining any documentation benefit from it.)

If it's a type you're having to invent as part of writing the code, writing it out everywhere it gets used can be a lot more work.

> I have to think longer in python because 1) APIs not always well documented

Meaning, not well documented compared to APIs in other languages? That hasn't been my experience; my experience has been that API documentation pretty much sucks everywhere.

> a well documented API that uses statical types is still easier to use due to the automatic compiler/IDE support

If you use an IDE, perhaps. (I don't; I find that they cost me more than they save me.)




> Writing out a type is only a few characters if it's a type that's already built into your type system.

Right, but if it is not, then you also have write extra code in python (e.g. create a new class).

Of course alternatively you can also just use "String" for everything (you can do that with a statical typesystem too), but I hope you agree with me that this isn't a great idea in any language.

I also have the feeling that you might change your mind if you try out a modern fully fledged IDE with a good statically typed language. The reason why I think this is because of things that you said such as "But in such cases, you're not gaining any documentation benefit from it." which are correct if you are not using an IDE. But if you do, it's actually wrong. IDEs like IntelliJ can be configured to show all (or only certain) types that are not written in text but that the compiler infers - without pressing any key. I like to use this feature a lot when diving into an unknown code base.

> Meaning, not well documented compared to APIs in other languages?

No, just not being well documented. Many popular libraries in python are well documented, but not all are. And the less popular/public ones are often poorly documented. The same is true for other languages as well, but in those, you at least you often have a "basic" documentation through the types.


> if it is not, then you also have write extra code

In any language, not just Python. A type that isn't already built-in has to be defined in your code no matter what language you are using.

> I hope you agree with me that this isn't a great idea in any language.

Of course it isn't. Different types exist for good reasons.

> I also have the feeling that you might change your mind if you try out a modern fully fledged IDE with a good statically typed language.

I doubt you would have this feeling if you knew how many times I have tried "a modern fully fledged IDE with a good statically typed language". And every time has ended up the same.

> IDEs like IntelliJ can be configured to show all (or only certain) types that are not written in text but that the compiler infers

This is a fair point, but in a language like Python this could be provided as a library function if it were needed. (Python already has the "help" built-in function that shows you the documentation for whatever object you pass it as an argument, at the Python interactive prompt. Inferred types could be handled the same way if Python had them.)

> at least you often have a "basic" documentation through the types

Which might be significant useful information. Or it might not. It depends on what kind of code you are dealing with. It's quite possible that the particular kind of code I have dealt with has simply not been the kind where static typing is much of a help, and that there are other kinds of code where it is. But the original claim that I responded to was "Everyone needs types" (by which was meant "everyone needs static typing"). It is that blanket, general claim that static typing is always better that I was disputing, not the claim that static typing can be helpful in some cases.


> In any language, not just Python. A type that isn't already built-in has to be defined in your code no matter what language you are using.

Yeah exactly! So it's the same for every language. I just don't understand why you then say that I would have to type more in a statically typed language.

> I doubt you would have this feeling if you knew how many times I have tried "a modern fully fledged IDE with a good statically typed language". And every time has ended up the same.

Everyone is different and that's one reason why people choose different tools and languages. Nothing wrong with this - one of the best developers that I know uses vim for everything. I on the other hand would not be productive without a good IDE.

> But the original claim that I responded to was "Everyone needs types" (by which was meant "everyone needs static typing"). It is that blanket, general claim that static typing is always better that I was disputing

Fair enough, I agree with you on that one. The thing I disagree with is that is static typing requires (always) more effort when writing code. For Java this is totally true, but for many other languages, my experience is that I neither have to type more nor that I have to think more.


> If it's a type you're having to invent as part of writing the code, writing it out everywhere it gets used can be a lot more work.

Not really; you write it out fully once, when creating a type alias/definition, and then just use the name later.

> Meaning, not well documented compared to APIs in other languages?

Yeah, I’ve found Python to have a pretty good documentation culture (docstrings especially facilitate this), often better than some statically typed languages with ecosystems where signatures are regularly mistaken for adequate documentation.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: