4 ms·
I used to take your view, but actually there are plenty of languages (e.g. ML-family languages) where you get the best of both worlds - light, clean syntax, but
by lmm 5y ago
I used to take your view, but actually there are plenty of languages (e.g. ML-family languages) where you get the best of both worlds - light, clean syntax, but also type safety and decent performance.
- tenacious_tuna 5y agoCan you share some examples? I'm very interested in a typesafe alternative to python, but low friction is also necessary.
- adsharma 5y agoWhy do you think python3 is not typesafe?
- packetlost 5y agoBecause it's not? It has a type system but it's still duck-typed at the end of the day, and no amount of Mypy will change that.
- adsharma 5y agoIt should still be possible to use the python syntax and a reimplemented stdlib to build a statically typed, typesafe variant. I think you object to the name python3, because there is a duck typed interpreter that's popular.
- packetlost 5y agoYou fundamentally cannot build a statically typed variant of Python without cutting portions of the stdlib, most notably `mock.patch`. You could do a good majority of it, probably enough to be completely usable, but at what point does it stop being Python? Go use Nim if you want statically typed Python-ish syntax.
- adsharma 5y agopy2many transpiles py3 to nim. Think of python as a way to interpret nim code if you like, with a large installed base of existing libraries. There is demand for iterative creation of software: first get the logic out with the least friction and then think about types, resource leaks, good software engineering practices etc.
- hermitdev 5y agoType safety and static typing are orthogonal. Both C and C++ are statically typed, yet are not type safe, for instance.
- metasyn 5y agonim-lang.org might interest you!
- tooltower 5y agoThey said ML family, so that's usually OCaml and SML.
- nestorD 5y agoF# comes to mind. It uses indentation instead of braces and has a nice ecosystem.
- nwatson 5y agoI use JetBrains PyCharm with type annotations in my code. I run the type-checker/linter ("Inspect Code") every 10 minutes or so, it's muscle-memory at this point. It covers most cases, problem resolved.
- lmm 5y agoPersonally I moved to Scala, which has a poor reputation because of some symbol-heavy libraries, but you can use it to write very clean Python-like code. Version 3 has actually added a more Python-inspired syntax with colons and indentation instead of braces. Standard ML was where I started. As a language it's great, as an ecosystem it's limited. OCaml seems to be where the action is (and even then its packaging/dependency management isn't great - but then it can't be worse than Python's). F# has a very good reputation but I haven't used it a lot myself.
- adsharma 5y agoI'm sympathetic to this point of view. But then there is 25 yrs of stdlib that's tattooed onto people's brains and stackoverflow. A pure python implementation of python stdlib ready be transpiled could be that bridge. Also it's possible to support multiple source syntaxes in such an ecosystem. ML based, python based or even a hybrid. In the end all I need is a well documented AST.
- ibic 5y agoAgree, just that ML-family languages take quite long for an average mortal like me to grok.
- willseth 5y agoOne of the main reasons people choose Python is the huge stdlib and vast package ecosystem. This is difficult to ignore if you need to do some very heavy lifting.
- garyrob 5y agoI experimented with OCaml and some of my Python code. I found that using Python with Numba enabled me to get much better performance than the same algorithm written in OCaml. In this case, using Numba for the performance-critical aspect was trivially simple, just the addition of a decorator. And I've found that is generally pretty close to true, at least for the kinds of things where I care about performance. That's why I'm still in the Python world rather than the OCaml world for my algorithmic work. I really like OCaml as a language and would actually prefer to use it, but Python/Numba seems to give me substantially better performance, as well as all of Python's standard libraries. And Numba lets you turn off the GIL, so you can get multiple cores going at once. YMMV, of course. I'm not making a general claim that would be true for everyone. But I think it may be worth mentioning that it could be true for more uses than one might assume.
- throwaway894345 5y agoNote that type safety typically means better tooling that what Python people are used to. If you’ve only used Python you have no idea what you’re missing out on with respect to refactoring, editor integrations, documentation generation, etc. And then there is the actual documentation for humans that is guaranteed to be correct and up to date so long as your build is green.