7 ms·
> Documentation. There’s a common mis-conception that type systems make code verbose. Firstly, type inference is pretty doable and addresses the problems that g
by emodendroket 9y ago
> Documentation. There’s a common mis-conception that type systems make code verbose. Firstly, type inference is pretty doable and addresses the problems that give rise to these beliefs. Java and C++ aren’t verbose because they have type systems, they’re verbose (partially) because they have bad type systems. Second, in my experience, actually clearly documenting an interface in a language that doesn’t have types ends up being much more verbose than it would otherwise be. You need docstrings regardless, but if the type of the thing says it’s an integer, you don’t have to write “x is an integer” in the docstring too. And now you have a concise, agreed upon notation for that sort of fact.
Preach it. Also, you don't have to worry that a method whose signature is `public int DoWork(string input)` actually expects char[] as its input and returns a long, the way you do when the types are only documented through comments.
- sametmax 9y agoExcept Python is not only used for what you do. People use it for batch testing, SIG embeded language, sciencitic analysis, sys admin, 3D tool scripting, glue code, product pipelines, etc. Having a required type system for this huge part of the community would be a great let down. Those criticism come from people comming from a strong dev background. They completly ignore the rest of the world. That's why having the current OPTIONAL type system is so good. Because you can use it and benefit from it, and many do, but you don't screw half of your community. Python strength is versatility. It's not the best at anything. But it's very good at most things. That's why if you know it, you can solve most problems decently. That's what makes it fantastic. I'm still waiting for people doing data anaylsis in Go, sysadmin in JS, 3D scripting in Haskell, batch testing in erlang or geography in lisp. Because Python... well it can. And AI. And Web. And embeded systems. And IoT. And... And...
- DarkKomunalec 9y agoHow would a type system hinder those people?
- sametmax 9y agoMost of those people are not dev. They don't write libraries, don't have time to learn many docs or type many lines. They have 30x 200 lines longs scripts and couldn't care less about code quality. They just want the result.
- DarkKomunalec 9y agoI am unable to find an answer to my question in what you just said.
- sametmax 9y agoPath of least resistence. A strong type system is much more extra work than you think.
- DarkKomunalec 9y agoI have worked with strong and no type systems, and have found that the absence of a type system is extra work. Instead of the compiler telling me exactly what something is, what I can do with it, and if it makes sense to pass it to some function, I have to figure all of that out myself, greatly slowing me down. Edit: It occurs to me I have yet to hear an answer to my question of how types hinder anything, especially if they are inferred. The only exception is the trivial requirement of sometimes having to cast between numeric types.
- emodendroket 9y agoYeah, you basically make initial implementation easier at the expense of maintenance and debugging, which sounds like a good tradeoff until you think about the relative amount of time you spend doing one thing vs the other.
- loup-vaillant 9y ago> at the expense of maintenance and debugging, Do you realize how insane that sounds? Static typing makes programs harder to debug? Harder to maintain?? On the contrary, static typing helps debugging and maintenance: changes that break invariants are more likely to be caught by the type system. This speak of tradeoff sounds wise on the surface, but this is hardly a tradeoff at all. For many people (including me), a good static type system makes prototyping and maintenance easier.
- scardine 9y agoHey, Lisp is pretty good for geography and was the language of choice for writing quick extensions in Autocad back in the day. Lisp lists are as natural for representing 2D and 3D points as Python lists and dicts. My first programming job was writing map reports (choropleth maps) using AutoLisp.
- sametmax 9y agoThe geographes I know would never, ever be able to do in lisp what they do in Python. They are not computer minded at all.
- KirinDave 9y agoThis meme about "computer-mindedness" is pseudo-scientific nonsense. It's something I fell hard for as well, because it's a lovely idea. But it's simply not true.
- scardine 9y agoLisp is not for the enlightened only! Anyone that ever used a scientific calculator can hack around. In fact Lisp can be much simpler than Python, it is just like using a RPN calculator if you don't want to dare into macros and other advanced stuff.
- emodendroket 9y agoOK, sure, but people are pitching Python not just as a language to write scripts but also one to do development of large projects on large teams, and I think this property makes it somewhat ill suited for that.
- sametmax 9y agoI wrote plenty of big projects in Python. It works very well, the problems and solutions you have are just different that in other languages you are used to. The question is more about "what kind of problem do you want to have and what price are you willing to pay to solve them ?". After that, choose the tech that matches this wish. For me the iteration speed, the ease of adding new members and the flexibility are key. But what I discovered is that most people just code bad Python and say they have problems, just like most people write bad C/java/whatever and blame the language. You are supposed to writte Python in a certain way, like any language, to scale.
- sethrin 9y agoWould you perhaps mind giving your opinion of Ruby?
- sametmax 9y agoI had the choice between Ruby and Python years ago. I choose Python because of the community, not the language. They are more or less equivalent, although I prefer forced indentation. Nowaday, ruby is dying in his RoR and Japan niches so the question is moot.
- emodendroket 9y agoIt is of course possible to build a great large product in Python, just like it is possible to do so in whatever your least favorite language is. But I'd argue there is more discipline needed to do so than there is in other languages with more type checking and there are whole classes of errors you simply wouldn't have to worry about.
- KirinDave 9y ago> batch testing, SIG embeded language, sciencitic analysis, sys admin, 3D tool scripting, glue code, product pipelines, etc. > Having a required type system for this huge part of the community would be a great let down. ... Why? These days types generate much more code than they cost in modern FP languages. E.g., https://github.com/haskell-servant/example-servant-minimal/blob/master/src/App.hs https://github.com/haskell-servant/example-servant-minimal/b... > That's why if you know it, you can solve most problems decently. That's what makes it fantastic. Most of the things you're talking about are available in other languages. And quite frankly, if pure versatility and available open sourced code is your argument? Then why aren't you using Javascript and nodejs? Name a general domain that I can't find at least one or more well-maintained projects supported on NPM. I dare you. > And embeded systems. Who.. who is doing IoT and Esys in Python outside of toymakers?
- vacri 9y ago> who is doing IoT and Esys in Python outside of toymakers? Aren't most IoT things basically toys anyway?
- KirinDave 9y agoZing.
- cwyers 9y agoYou may be able to find a well-maintained data science/machine learning project on npm, but I doubt you'll find as many as are needed in a typical data science workflow.
- KirinDave 9y agoMaybe, not sure how that is relevant. You definitely CAN do it, it's just not as common. Same could be said of F#.
- cwyers 9y ago> Name a general domain that I can't find at least one or more well-maintained projects supported on NPM. I dare you. one is named > Maybe, not sure how that is relevant. Man, it was your dare!
- mgrouchy 9y agoPython 3.5+ has type hints now (and a standalone typechecker). It doesn't do runtime checking by default, but you can use a 3rd party library to enforce these things if you are concerned about type safety (at the boundaries of your programs for checking inputs for example). More info on this in the pep: https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0484/
- sametmax 9y agoRead again, I got it covered.
- Turing_Machine 9y agoI am thinking of a function in the Windows 3.0 API that was declared in the header file as returning BOOL, but actually could return TRUE, FALSE, or -1 (which, of course, is true according to C's rules). Worse, I didn't have the docs -- just the header file. That one cost me a fair amount of head scratching before I figured it out.