8 ms·
The past month I have used Python again after a few years and I have to say I didn't quite like the experience as much as before. On one hand I also used vanill
by dep_b 6y ago
The past month I have used Python again after a few years and I have to say I didn't quite like the experience as much as before. On one hand I also used vanilla Python instead of something easier to use like Django but the amount of preventable run-time errors and the lack of IDE autocomplete support at various points was kind of off-putting after coming back from very strictly typed languages like Swift, Kotlin or F#.
It also didn't have the simplicity that Phoenix / Elixir still has, for example when you Google how to solve problems you have Python 2 versus 3, the old way to handle requests which is limited and the new way to handle requests which isn't as documented, yes you have type hints and named arguments but they're not everywhere yet and so on.
So I don't think I will circle back to use Python again unless there's some kind of reason I can't easily go around it. There are still some very good ideas in there (I like the braceless approach to code hierarchy and a standard on code formatting in general) and it's definitely not as dumb as JavaScript but it has accumulated too much cruft.
- kzrdude 6y agodataclasses are the best recent addition to Python, IMO, maybe tied with ordered dicts. Python definitely doesn't have conceptual simplicity, because there are many competing concepts in the language, and lack of focus on uniformity. (Example - enums are implemented with a metaclass and dataclasses with a class decorator - arguably the latter is the wrong choice, because it is already evident it limits what kind of features can be added to dataclasses). Another example just because it makes me irate - `typing.NamedTuple` has been added as an "alternative" to `collections.namedtuple`. Same name, new capitalization, slightly different features. Add to that, a collection type that's inside the module `typing` which is supposed to be for.. type annotations, not actual implementations.
- crazypython 6y agoNo, (optional) static typing is the best recent addition to Python. It allows IDEs to catch a large variety of errors. The static type system is part of the language and has multiple implementations. It's Hindley-Milner, making it two-way, like Haskell's type system.
- kzrdude 6y agoThere is no "No", you can just add your opinion about your favourite feature instead.
- sn9 6y agoWait what? Are you saying Python has a Hindley-Milner type system? What's it called? Google didn't turn up anything.
- kzrdude 6y agoPython doesn't have it but I think they are talking about mypy, options typechecker tool that has type inference.
- crazypython 6y agoIt's called PEP-484, and it's part of the language https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0484/ Pyre and PyCharm are third-party implementations of PEP-484.
- ericvsmith 6y agoAuthor of dataclasses here. > (Example - enums are implemented with a metaclass and dataclasses with a class decorator - arguably the latter is the wrong choice, because it is already evident it limits what kind of features can be added to dataclasses). I'm curious about what features can't be added to dataclasses because it's not using a metaclass. If anything, I think that not using a metaclasses is a good thing: it allows you to use @dataclass with classes that do require a metaclass. That metaclass would likely be incompatible with the metaclass that such a hypothetical @dataclass implementation would use.
- mcovalt 6y agoThanks for not using metaclasses for dataclasses. I’m looking forward to all libraries replacing metaclasses. For instance, in Django, I think all their metaclasses can be replaced by __init__subclass__. The main issue I have with them is how difficult it can be to compose a new abstract class using upstream classes with them.
- noitpmeder 6y agoI love dataclasses, incredibly simple to use but so useful. My only gripe is no first-class support for "__slots__".
- ericvsmith 6y agoI have a decorator to add support for slots: https://github.com/ericvsmith/dataclasses/blob/master/dataclass_tools.py https://github.com/ericvsmith/dataclasses/blob/master/datacl... (although I'll admit I haven't tested it in a while). The reason it's not an option by default is because it would be the one case where the decorator would have to return a new class, and I didn't want to do that on the first version. As it is, @dataclass just modifies an existing class. I might bite the bullet add a slots option, and we've had discussions on adding a language feature to automatically add slots to a class, based on annotations and maybe some other magic. If we did that, we wouldn't need to return a new class. But it's not a front-burner task for me.
- 6y ago
- teilo 6y agoYour blaming Python because you used a poor IDE and failed to use type annotations?
- dep_b 6y agoI'm using PyCharm, if you have anything better than that don't hesitate. But the type annotations are obviously something that also needs to be added to all other code I touch, not just my own.
- _ZeD_ 6y agoeclipse + pydev + mypy/pylint integration
- rusk 6y agoI’ve used PyCharm from time to time and I find it great but I kind of feel like you need a different approach. Coming from Java it made sense but Python is a different mindset once you get into it. I think you’re far better off treating Python as a highly structured scripting language and using an advanced text editor. I’ve come to believe that these very powerful IDEs are a kind of a window dressing that makes the more serious languages easier to work with. With more flexible languages the language itself is the tooling but it’s not so easy to audit at the end of the day.
- stevedonovan 6y agoAlthough arguably a more 'difficult' language I sleep much better at night when using Rust, because Python is always in a hurry to get a wrong program running. So then, one has to test like hell. So I feel I'm still ahead of the game.
- rusk 6y agoIt’s horses for courses. I’d never use Python for the kind of thing that rust is for. At the same time, I’ve never had occasion to use rust for the stuff I do. EDIT - just want to add: I'm not au fait with the specifics of Rust but I presume from what I've heard about it that it also supports my position, as an advanced language, that the features you need are in the language so a heavy-weight IDE isn't so necessary.
- draw_down 6y agoGotta get the js digs in. Nice.
- aesyondu 6y ago> as dumb as JavaScript Could you elaborate on this?
- dep_b 6y agoMuch better base packages. Date handling. Type hints. Not an OO fan but it does have real classes. IMHO handles complex applications better. Though Python can look a bit more clunky than modern JS.
- deleted 6y ago[deleted]
- tigr 6y agoWhat IDE do you use, that doesn’t have full autocomplete support?
- loblollyboy 6y agoPycharm autocomplete is very good - I don’t know if that is what you mean by autocomplete support Requests is one of the modules that had more change on 2-3, but being basically the most popular language (for good reason), it’s pretty easy to find documentation for either version. I imagine a lot more than for Phoenix/elixir whatever that is. I think you’re being difficult for the sake of being difficult. I am not a leet programmer and that is why I use python- it does everything for you very well and no more. If you want more “cruft” pip install cruft
- LeonenTheDK 6y agoYou might be surprised to see the quality of the docs in the Elixir world: https://hexdocs.pm/phoenix/Phoenix.html https://hexdocs.pm/phoenix/Phoenix.html
- acdha 6y agoThat looks … like many Python projects? It's slightly prettier than the default Sphinx theme but I'm not seeing anything which wasn't common a decade or two back.
- LeonenTheDK 6y agoIMO part of the quality here is these docs are generated from comments in the code. All you have to do is document your functions and modules properly, run a command, and you have an entire set of docs. It reminds me a lot of JavaDocs, although I never used them extensively. I'm also not very aware of how documentation looks in the Python world. Another interesting thing is the code examples. You write them in the comments as "Doc tests", and they are run and tested like normal tests. This means that all the code snippets are up to date with the latest version of the project (as long as you do test!). The best part, also imo of course, is that it all works out of the box.
- acdha 6y agoThat’s how it works in Python, too. You add text descriptions (docstrings), automatic documentation generated from function/class definitions (comments can add prose), and you can run doctests to test things like examples. See e.g. https://www.sphinx-doc.org/en/master/index.html https://www.sphinx-doc.org/en/master/index.html and https://docs.python.org/3/library/doctest.html https://docs.python.org/3/library/doctest.html
- ahallan 6y agoI moved/was pushed over to Python around a year ago, after writing C# for 15 years. My Python setup is as follows: * vscode * pylance * black formatter * flake8 * python typing annotations used as much as possible This seems to work very well with regards to autocomplete and preventing run-time errors. One thing I do miss is proper refactoring support.
- laichzeit0 6y ago> One thing I do miss is proper refactoring support. You should try PyCharm then. That, and their debugger is orders of magnitudes better than VSCode.
- tclancy 6y agoSeconded. I had an IDE I was used to and loved and the first time I pair-programmed with someone using PyCharm I threw it out and switched. Doesn't mean it will be the same for you, but it's miles ahead of everything else I have used in 15 years for Python. FWIW, I like VSCode just fine for everything else, PyCharm is just so handy.
- ahallan 6y agoI did try PyCharm a few times, but it seemed too complicated - and this was after using Visual Studio for 15 years! The debugging support in VS Code is fairly good, so it's just the refactoring I'm missing. I'll give PyCharm another go when I get some spare time.
- xtracto 6y agoI don't understand why someone would use Python instead of say using Ruby. I think right now it is a matter of "synergy" given that Pandas, Torch and all those libraries are more tailored for Python, but as a scripting language Ruby is just so much easier, elegant and intuitive [ len(something) vs something.length ]
- jkubicek 6y agoFWIW, I found Python far more intuitive than Ruby. For the most part, Python works like I expect it to, meaning I can write large swaths of functional code without having to look at documentation, something I was never able to do in Ruby.
- mixmastamyk 6y ago> [ len(something) vs something.length ] The first reads like english, the second doesn't.
- disown 6y ago> The past month I have used Python again after a few years and I have to say I didn't quite like the experience as much as before. Python is really a Perl replacement. It was meant for the scripting world, not software development - pretty much stuff that was too complex or cumbersome to do in bash.