5 ms·
I’m not trying to start a flame war, but I’m genuinely curious: if you want and need all this, why not use Java? Java has all the strong typing and static chec
by motoboi 6y ago
I’m not trying to start a flame war, but I’m genuinely curious: if you want and need all this, why not use Java?
Java has all the strong typing and static checking, all you need is to type a lot more words.
- icegreentea2 6y agoThe key would be that 'you sometimes want it'. The stuff that `zope.interface` gets you is honestly on the... heavy side of what I think makes sense for a lot of scenarios (especially in Python). Which would explain it's relatively low uptake despite having been around for like... 15-20 years?? I haven't used `typing.Protocol` yet (I am mostly still working in 3.7), but it seems to roughly capture the level of 'heaviness' that seems workable. I do get your gist though. Sometimes I wonder what I'm doing type annotating stuff.
- psd1 6y ago> I do get your gist though. Sometimes I wonder what I'm doing type annotating stuff. I have to say, I despise trying to decipher untyped functions. This arg is called "order" - do you want an instance of Order, an order ID, or a function for sorting? Fine, I'll read the docstring. Instead of using the IDE.
- BerislavLopac 6y ago> I haven't used `typing.Protocol` yet (I am mostly still working in 3.7) You can use it if you install the typing-extensions package: https://pypi.org/project/typing-extensions/ https://pypi.org/project/typing-extensions/
- high_density 6y agobecause most ML libraries are python-first... as for other stuff (web-servers, what not), I don't think python can beat kotlin / typescript / etc
- marcinzm 6y agoScripts where startup time matters. Situations where you don't want the heavy-weight and complex JVM. Cases where you need to interact with C/C++ code a lot (ML, etc.). Companies where python is the norm and introducing another language adds a lot of overhead.
- remexre 6y agoGraalVM (and SubstrateVM) is actually fixing a lot of these; I had a short-lived process that I AOT compiled with SubstrateVM, and I spent a lot of time checking I had done it right and not somehow accidentally compiled in my input data as well or something -- I got a two order of magnitude speedup, with fewer than ten lines of code change.
- qyi 6y agoReplace Java with literally anything else (including whatever Java implementation does not have the issue) and the "startup time" red herring is gone.
- marcinzm 6y agoThen you get different issues including more obscure and untested systems. I responded to someone asking why not use Java. I answered it. Please don't try to change the question after the fact when you don't like the answer.
- qyi 6y agoI know you're trying to pin me as being rude, but no. Your answer is bad and ad-hoc. Just because a language is not Java does not make it magically untested and obscure. Just use Go tbh. Edit: Okay I see the original guy stated Java. It is what it is. The real useful answer is to just use any other typed language, and not use Python.
- rualca 6y agoJava's punishing startup times is not a red herring, and I'm dumbfounded someone in a forum like HN makes such a claim. Even in serverless applications like AWS Lambda, python and javascript enjoy execution times that are an order of magnitude faster than Java ones, even with hot starts and stuff initialized a priori.
- BiteCode_dev 6y agoBecause you don't always need this. In python, it's optional: you can use it when it matters.
- dempedempe 6y agoOr you could use Kotlin and keep the strong typing and static checking but do away with the "type a lot more words" part ;)
- pansa2 6y agoUsually, because you already have a lot of Python code and it's easier to write more of that, than to try and figure out Python <=> Java interop.
- fnord123 6y agoSure in Java you never have this question of structural vs nominal typing. It's all nominal.
- deleted 6y ago[deleted]
- joshuamorton 6y agoJava doesn't support protocols.
- edem 6y agoA better question is why not use Kotlin? It has most of the things Python has and much more (no decorators _yet_ though, but they are on the roadmap).
- qyi 6y agoThe idea of an interface is fundamental to computing. No matter what you do, at the end of the day data exchanged between two systems has to be structed _some how_. E.g., machine code submitted to the CPU, register configurations, C ABI, Python structures, JSON. You _could_ be hand wavy about it, maybe even use machine learning, but then it will just be ambiguous and lead to vulns. IMO the constant insistence to try and find ways around this is a huge setback. I used Python heavily in 2008 and always was annoyed when trying to figure out the essence of an API (which is what you get when there is no concrete interface). Whenever I read a Python codebase, unsurprisingly, it's full of handwaving and the resultant bugs (some people know what they're doing, but the problem is there more than in a typed language).