59 ms·
Why I'm still using Python
- atoav 4y agoOne of the single language features that makes me stay with python is list comprehensions. So maybe something like that: stuff = [cleanup(s) for s in stuff if s.unprocessed] This, the way you can handle/manipulate strings and the powerful included libraries make python a good language. Downsides? Dependency managment, tooling, speed
- snowpid 4y agoList Comprehension is just syntax for functional coding (filter, map) but a very good one!
- von_lohengramm 4y agoI may be the outlier here, but I have a very hard time comprehending list comprehensions. They've always seemed like a SQL query compressed into a single line (or two if you're lucky!): readable when it's simple, Lovecraftian when it's not. I've always found the functional pipeline style much more readable and much easier to explain to others, especially with IDE type hints.
- int_19h 4y agoSQL queries are sequence comprehensions! Python comprehensions in particular are unfortunate because the flow of the query, like in SQL, is not linear - the projection part is written first, but happens last. Thus, reading a non-trivial query requires moving back and forth to resolve the references. Compare that to C# LINQ, which is also a kind of sequence comprehension. That one not only has linear syntax where the data flow in the query is strictly left to right, but it's explicitly defined by mapping it to functional pipeline style. Thus, it ends up being a strict improvement on the latter. (Another example of "good" sequence comprehensions in this sense is XQuery FLWOR)
- maxbond 4y agoIMHO the key to legible comprehensions is to use them only to express composition and to put the logic into verbosely named functions. Chained pipelines (`foo.filter(...).map(...)`) are fine to me, certainly more verbose then comprehensions for better & worse, but I get lost in pipelines expressed as nested functions (`map(filter(a, ...), ...)`).
- dragonwriter 4y ago> they’ve always seemed like a SQL query compressed into a single line (or two if you’re lucky!): If its more than a very simple expression, with one simple for, and no if or very simple if, I try to use at least (more, with parens, if necessary): one line for the result expression, one line for each for clause, and one line for each if clause. But, while the boundary is subjective, it doesn’t take much before functional pipeline style is clearer (Python lambdas being more limited and syntacticaly cumbersome, functional pipeline style isn’t as clean in Python as it is in other languages, though.)
- snowpid 4y agoit depends on your problem but in many cases simple is enough imho. There are map and filter in python avalaible. I just didnt need to use them.
- ogogmad 4y agoBeing pedantic: This isn't true in Haskell, because list comprehensions can use pattern matching, while map+filter can't. heads :: [[a]] -> [a] heads xs = [y | (y:ys) <- xs] -- heads [[1],[],[2,3]] == [1,2] Doing the above using maps and filters looks very different: heads' = map head . filter (not . null) Python doesn't really support Haskell-like pattern matching, so the above doesn't apply.
- pdonis 4y ago> Python doesn't really support Haskell-like pattern matching It does as of 3.10: https://peps.python.org/pep-0622/ https://peps.python.org/pep-0622/ Not as sophisticated as what Haskell can do, I'm sure, but I think it's a good addition to Python.
- _v7gu 4y agoThe thing you're looking for is easily found with a Hoogle search for type (a -> Maybe b) -> [a] -> [b] Which yields mapMaybe: https://hackage.haskell.org/package/base-4.17.0.0/docs/Data-Maybe.html#v:mapMaybe https://hackage.haskell.org/package/base-4.17.0.0/docs/Data-.... so you end up with heads = mapMaybe safeHead
- ogogmad 4y agoThat doesn't look like a direct substitute that covers every case.
- pharmakom 4y agoSorry, but Python list comprehensions are not very good compared to other languages.
- snowpid 4y agowhy?
- pharmakom 4y agoIn F# list comprehensions, for example, you can have full blown expressions such as loops and conditionals. This is really nice for templating. [ if List.isEmpty items then p “No items” else ul [ for item in items do li [ item ] ] ]
- snowpid 4y agoso? if len(items) == 0: return [p("no items")] else: ul( [ li(item) for item in items ] ) I am also not a fan of convoluted list comprehension (in python) so powerful is not necessarly a good thing.
- pharmakom 4y agoThat only works in a single purpose function. And consider this example: [ h1 “items” if List.isEmpty items then p “No items” else ul [ for item in items do li [ item ] ] ]
- snowpid 4y agoh1(items) + rest of my code... I might see what are you using for but I am not sure if concenating implicitly (or with line breaks / spaces) is a good design decision for a language.
- sodapopcan 4y agoList comprehensions are great but certainly not unique to Python.
- curiousgal 4y agoC#'s LINQ is far more powerful in my opinion.
- matsemann 4y agoI have a completely opposite reaction, one of the things I hate the most with Python is its list-incomprehensions. They quickly become hard to read and very imperative, instead of declarative. Something like stuff.filter(it.unprocessed).map(cleanup(it)) conveys the intention behind each statement a hundred times better. And list comprehensions becomes impossible to reason about once they involve flatmapping or other relative simple functional expressions.
- ilyash 4y agoYep. What bothers me is when you start looking at list comprehension is that you don't know if it's filter(), map(), or a combination. You have to read the list comprehension till the end to understand.
- sodapopcan 4y agoI agree very much so. List comprehensions and can be nice and concise and readable in many situations, but due to the whole "one true way" thing in Python, they're used in every situation, even when a map/reduce/filter etc would be better. Although since there are no pipes, I sorta get it.
- MrVandemar 4y agoDefinite agreement. I started a long time ago with Python2, and what attracted me was how simple and readable the syntax was. With Python3 there is a move towards "idiomatic" Python code, which to me means moving away from clear and concise to the old programmer trap/readability nightmare of "look how many things I can get it to do with one line of code!"
- fbdab103 4y agoLet's not even talk about those insane people who use nested list comprehensions. Not sure if it would make my top-5 Python-hate list (1-4 would probably be dedicated to packaging and distribution), but list comprehensions definitely feel like a misstep that contributes little value to the language.
- cortesoft 4y agoI feel like this is a lot cleaner and more clear in Ruby: stuff = stuff.map {|s| cleanup(s) if s.unprocessed }.compact
- nequo 4y agoOnly knowing Python and not Ruby, your snippet looks confusing to me. 1. What does the anonymous function return if s.unprocessed is false? 2. If it returns nothing, do I get a missing value element in the iterable that results from map? 3. And what does it mean to compact the result of the map call? The Python snippet raises none of these questions in me. But it could be because I am familiar with Python’s quirks.
- cortesoft 4y agoThe compact gets rid of all the null values returned when unprocessed is false. Interestingly I wasn't exactly sure what the python code would do, which is why I used the compact. In the python code, does 'stuff' end up only having the result of the cleanup function for items that are unprocessed? Or will it have all of the items, and the ones where unprocessed returns false just end up being returned unmodified? My Ruby version returns the processed subset of items that were unprocessed. The python version was not clear to me, since I don't know what happens if s.unprocessed returns false. So basically, it sounds like we were both confused by the same parts of the language we are unfamiliar with... what happens to elements where s.unprocessed is false? It was clear to me that in Ruby it returns a nil, but I have no idea in Python... what happens?
- nequo 4y agoHuh, our mutual confusion is interesting indeed! Thank you for teaching me something about Ruby. What compact does makes sense. Python’s list comprehension combines map and filter. [process(s) for s in stuff if s.unprocessed] is equivalent to map process (filter isUnprocessed stuff) in Haskell.
- baq 4y agoNothing, literally. This is map+filter optimized (or a for+if+append but using dedicated opcodes for efficiency) so you don’t have to do multiple passes and/or create temporary lists with superfluous elements.
- spicyusername 4y agoI almost always prefer to read nested loops and conditionals than list comprehensions. I find the syntax of list comprehensions ugly and inscrutable.
- xvedejas 4y agoAdditionally I find that it's easier to add complexity to the loops; once you want to start doing nontrivial things in a list comprehension, you often need to rewrite it into a loop first anyway.
- Spivak 4y ago> It's easier to add complexity to the loops This is basically selling point for comprehensions. You can't add complexity to them so any comprehension you see fits a few common loop patterns you can grok immediately. If you see an actual for loop in python it means "pay attention something odd is probably going on."
- gorgoiler 4y agoAnother effective technique for making readable, maintainable code is to break the list comprehension out into a generator (as a closure): This example…: a = … vs = [ v(x) for b in a.f() for x in b if x and c1(x) and not c2(x) ] …becomes: a = … def each_v(): for b in a.f(): for x in b: if not c1(x): # comment continue if c2(x): # comment continue if x: yield v(x) vs = set(each_v()) Line orienting each conditional makes commenting much easier. The collection used for vs is clear. The formatting is less susceptible to being churned up by black. You get to give the thing a name, which helps.
- Kwpolska 4y agoYou can easily replace this with various forms of map/filter in many other popular languages. Assuming cleanUp is a single-argument function/static method: // JS stuff = stuff.filter(s => s.unprocessed).map(cleanUp); // Java stuff = stuff.stream().filter(s -> s.unprocessed).map(Main::cleanUp).toList(); // C# stuff = stuff.Where(s => s.Unprocessed).Select(CleanUp).ToList(); Java streams and C# LINQ extensions also expose other nice data processing functions, eg. sum, takeWhile, distinct. And if you like Python’s dictionary comprehensions: {str(n): n * 2 for n in range(1, 11)} you can use ToDictionary in C#: Enumerable.Range(start: 1, count: 10).ToDictionary(n => n.ToString(), n => n * 2);
- skitter 4y agoThese are also easier to read and write than the Python version, as you can just follow the dataflow from top to bottom (or left to right if it fits into a single line). In Python, your eyes have to jump around to find where to the next bit of processing happens, not just in comprehensions but also with map/filter/list/len and co which are freestanding functions for some reason.
- gsinclair 4y ago“You can…” Sure, but the Python code is so much nicer. I don’t even like Python all that much but it’s comprehensions and generators are very sweet.
- Kwpolska 4y agoI find the non-Python versions easier to read, since they show the exact data flow in order (instead of Python’s [3 for 1 if 2] order) and they allow more advanced scenarios.
- atoav 4y agoSure you can do that and I use things like this all the time in other languages, but the python example was very basic. There are other cases that are sometimes harder to reproduce e.g. when iterating over dictionaries to create a list, when you have tuples etc.
- gdprrrr 4y agoHave you tried Haskell vor Scala?
- mmcnl 4y agoI love list comprehensions but my brain starts melding with nested list comprehensions. The syntax is not obvious and I have to Google it and figure it out again 100% of the time. The JavaScript .map() method is much easier to understand.
- type-r 4y agoI like list comprehensions now after having used the language for a while, but I will say they were the hardest for me to grok when I was first learning the language. even now it can be difficult to follow what's going on if you have nested ones.
- msz-g-w 4y ago> Downsides? Dependency managment, tooling, speed What's wrong with its tooling?
- stabbles 4y agoThey should put energy labels on programming languages. It’s convenient to use Python, but a waste of cpu cycles
- lylejantzi3rd 4y agoWhy hasn't anybody created a more efficient version of Python? Slap some static types on that baby, get rid of the heavy runtime, and you've got a good start toward something special.
- doodlesdev 4y agoThere are more efficient interpreters and compilers, problem is they don't work with the existing libraries. If you mean another language, there is Lua for scripting purposes and Julia for math stuff. JavaScript also exists, which despite its fame it is actually MUCH faster than Python, and you can even run it in a runtime such as bun.js and get even more out of it. IMO the biggest problem is that the Python libraries ecosystem is just too good to miss out on. I absolutely hate Python but even I have to admit it is much easier to do some stuff in Python compared to other languages simply because of the libraries available to do basically anything you could dream of.
- ravenstine 4y agoWouldn't surprise me if a subset of Python compiled to asm.js would run faster in V8 than cpython.
- JonChesterfield 4y agoProbably doesn't have to be a subset. Call back to cpython for the really dynamic madness, much like a jit tiers back out of machine code when assumptions don't hold.
- dragonwriter 4y ago> Wouldn’t surprise me if a subset of Python compiled to asm.js would run faster in V8 than cpython. I’m certain that there exists some subset of python for which this is true, but so what?
- pugio 4y agoI've been thinking (and researching) heavily in preparation for a new (offline, desktop) app I want to build. The app has a lot of data wrangling, and probably a decent amount of ML. Python seems like the logical choice, but... I've written a lot of Python, taught classes in it, deployed production code... and I still feel a semi-conscious urge to reach for something else whenever I contemplate starting a new project. Something about its approach, syntax, common idioms, always feels just a tad clunkier to me than I'd prefer. The whitespace makes it hard to paste lines into my repl, and (probably the biggest thing) comprehensions ARE NOT SUFFICIENT replacements for easy anonymous inline functions (JS () => , or Ruby's blocks). I like dynamic languages, I really like the advances in tooling with type checking and LSP support. I like dynamic notebooks (either inline in VS Code #%%, or straight Jupyter), the massive package ecosystem (but obviously hate the actual packaging tools), cool tools like Rich... but it just doesn't make me as happy to use as other languages. I'm still trying to articulate why. Maybe I was just ruined by learning Ruby first.
- pphysch 4y agoUnless you have a clear specification for what you are going to build (as in, you have most of your data schemas and processes sketched out), stick with Python and benefit from the development velocity as you figure things out. Then rewrite it later when you need to scale.
- nnadams 4y agoI have embraced this workflow completely. I used to be more concerned about which language, but now I find I much more useful to just start immediately in Python. I spend most of the time working out the kinks and edge cases, instead of memory management or other logistics. Maybe ~75% of the time, that's it, no need for further improvement. Recently I chose to rewrite several thousands of lines of Python in Go, because we needed more speed and improved concurrency. Already having a working program and tests in Python was great. After figuring out a few Go-isms, it was a quick couple of days to port it all for big improvements.
- 4y ago
- stevesimmons 4y agoPython's been my main language for 22 years now. Whenever I think I should switch to faster, more efficient language (C#/Go/Rust/...), I am repeatedly blown away by what Python lets me do, with an incredibly ecosystem of packages, and all the ergonomics of incremental development from a REPL. Case in point is my current project: building a parser for PDF bank statements from all UK banks. I can match a 10page bank statement against a library of 100 templates, and then extract its data in a standardised format, in around 50ms per statement. That's broadly comparable to the time for load the source file from cloud storage. And that 50ms is processing pages sequentially, using a single core on my little laptop. Plenty of scope to parallelise if I wanted to. The reason why I'm still using Python, to borrow a slogan from Bruce Eckel long ago, "Python fits [my] brain".
- elabajaba 4y agoMy problem with Python, especially when reading someone else's code, or my own old bad code, is that I find that Python doesn't fit [my] brain. The lack of typing (in my experience you always end up with a bunch of libraries that don't have type hints) means I spend most of my time just figuring out what I'm supposed to pass to a function (I hate the django docs. Give me something like docs.rs where I can quickly scan what functions something implements, and see what they accept and what they return instead of forcing me to read an 800 page novel that STILL doesn't give you that basic info), and writing tests and trying to guard against passing the wrong thing around.
- stevesimmons 4y agoIn my own code, I always use typehints and write good docstrings (nearly) everywhere. Visual Studio Code's type checker saves so much time and has improved my code quality to no end. It is especially powerful on polymorphic inputs, making sure the different code paths operate on the input type you expect.
- shanebellone 4y agoPyCharm is good for this too. I've recently started using Type Hints by default. At the very least, it makes your code more readable. Nothing bad comes from that.
- analog31 4y agoI'm strictly a "scientific" programmer. I've used multiple languages in 40+ years, but only two lasted more than a decade: Turbo Pascal and Python. As Python has passed the decade mark for me, I sometimes wonder why I'm still using it and what would make me get sick of it. Some of my reasons for choosing Python in the first place have been mooted. Python is free, and multi-platform, but so is everything else nowadays. I think that battle is over. For my use, packaging has not been a big obstacle, maybe because I tend to use a relatively small handful of established packages. I don't remember needing a package that I couldn't install with pip. Easy to learn? Yes and no. I think a beginner can ease their way into Python and get productive, if they start with basic scripting and progressively adding a few language features. On the other hand, some features are simply over the heads of beginners, making the code found in packages practically unreadable. But I've never found any language to be better in this regard. Fast? Sure, with numpy in its domain of use. Or writing your own C libraries. However, I think a beginner using numpy will run into roadblocks that require help from an experienced programmer, who can visualize what the array operations are doing under the hood. So, writing fast code isn't easier to learn in Python than in any other language. The editor should have a final option, that turns your code brown if it's just so bad that nobody should ever have to read it, including yourself.
- blensor 4y agoI think one big factor is easy entry but almost no limit: Like BASIC back in the day it's a language that allows newcomers to do things long before they are comfortable with the added syntax requirements of C based languages Despite that the sky is the limit, almost all problems a developer will encounter can be tackled with python. Yes for many problems there are languages that are better suited for the task, but in most cases a project does never even reach a state where that will matter. And it's installed by default in many Linux distributions.
- 6gvONxR4sf7o 4y agoAnother big one that many languages treat as table stakes these days is the whole 'batteries included' thing. Whenever a new language comes out and I have to make my own (or install) core capabilities, it feels like a huge waste of time.
- rr808 4y agoI really struggle with this because I'm a C++/Java dev who is 4/10 with Python. I dont understand why anyone would choose a single threaded language but its just everywhere I can't avoid it.
- synergy20 4y agoso is javascript, single threaded language. somehow these two are super popular. both can do async, both have libs for multithread workloads. I wonder how critical the language itself is as far as multi-threaded goes.
- vb-8448 4y agoCPU-bound tasks are limited to a single core due to GIL but, for sure, it's not single threaded language!
- kmac_ 4y agoI'm C#/Java dev who works with Python and ML devs. I'm amazed how fast they can put things together and solve problems. We've embedded Jupyter to our product recently, and what I can tell, that's the way. Even the integration team started to use it to glue things together. I'm becoming a huge fan, it does the job.
- piyh 4y agoDo you write a lot of multithreaded code that can't use a shared nothing model?
- baq 4y agoIf your problems need threads and raw CPU, you’re doing well, since that obviously isn’t Python’s niche. The thing is, most problems aren’t like that and if some parts are, Python probably has a C extension for it, so it doesn’t matter nearly as much as you think.
- rkwertz 4y agoThis language seems to require at least one positive front page post per day so people keep using it. Compare with the anti-golang posts today.
- password4321 4y agoI continue to reach for Python first for my personal scripting, especially gluing together existing libraries. Building tools multiple people will be using regularly? Might be worth speeding up at least the slow parts with another language. (I don't know it well enough for it to by my first choice here). Also: I appreciate typed languages more when working with a team. I'm not familiar with the options Python offers to keep teams on the same page.
- xwowsersx 4y agoGood post. I think this is the mature and somewhat inevitable lens through which to assess which programming language you're using. I have been using primarily Python for the last ~4 years or so. It's probably the most boring language I have ever used (it probably doesn't help that I've used Scala, Haskell, Rust, etc). Obviously, some languages are better than others for specific use-cases and one should think through the strengths and weaknesses of each before beginning a new project (assuming you expect the project to have some longevity). Similarly, it definitely is possible to make the wrong choice about which language to use. But even as a PL "enthusiast", I've learned over ~15 years of leading successful projects and teams, that evaluating languages is always team/org/business-dependent and the considerations that factor into those contexts are distinctly different from the kind of considerations that I, as a PL enthusiast (and I suspect many others in the HN crowd) would prioritize. You have to consider things like: 1. What stage in the business in, i.e. early stage where you may simply want to get something, anything working and it's viable to do so in whatever language will get you there fastest (warts and all, tech debt be damned, etc) vs the critical juncture where you're beyond finding product-market fit and you now have a business that is working and you need to increasingly focus on reliability, scalability, etc? 2. What does the pool of engineering labor in the market you have access to look like? For example, it may be the case that you'll have difficulty, for one reason or another, finding developers who work with language X, but could easily find many who can work with Y (of course, good devs should theoretically be able to ramp on any language, but whether you'd want them to do depends on how crucial using that particular language is to your venture, whether you can afford the ramp-up time, etc. 3. Also somewhat related to the quality of engineers you have access to, the community/packages/ecosystem surrounding the language may matter a lot to such a degree that even if some other language were a better fit from a purely technical perspective, it may leave you to have to fend for yourself in ways that your team simply isn't up for. .. and many more considerations. Beyond all of this, I resonate with the author's orientation of wanting the language to just get out of the way. Sometimes you're looking to geek out on a stimulating and interesting language. Other times, that's the last thing you're thinking about. Bonus points if the language you find most compelling is also the one that, for reasons like the ones mentioned above, is the one that makes the most sense for you and your team. All in all, the point is that assessing a language in isolation, without any regard for what you're actually trying to accomplish, what your team looks like, etc. doesn't make much sense. Side note: I do wish more Substack authors would allow comments even from non-paid subscribers. I could understand restricting it if you already have an established paid subscriber base and a chatty comments section. But if comments are non-existent, it seems to me like the author is potentially losing out on valuable feedback/commentary by restricting commenting to paid subscribers.
- candrewlee14 4y agoPython does a great job at putting together powerful scripts quickly. But I have a really hard time opening up a big Python codebase and making sense of it quickly. No static types can make data pretty hard for me to follow. This may just be something I need to improve at, but I have a distinctly better feeling working with unfamiliar code with static types. Python makes me feel I’m at the will of the documenter to be informed, whereas the types self-document in many cases in other langs.
- ruuda 4y agoPython has optional type annotations. Most new code tends to have them, and they help tremendously navigating and understanding large codebases.
- lordgroff 4y agoIt's a far cry from an actually typed language. I like Python and deal with its code bases for a living, but frankly it has gotten too big for its britches.
- The_Colonel 4y agoIt's honestly not very good compared to a "real" type system (platform). I've used it about a year ago for a couple of projects, and it was painful and ultimately not very useful exercise.
- depressedpanda 4y agoWhile I agree that type hinting by its very own nature feels a bit bolted on, I vastly prefer going into code bases which include type hinting. I personally always add type hinting to the code I write, as I actually consider it quite useful. In what ways do think it's painful?
- The_Colonel 4y agoI remember mypy being slow and buggy. I remember one mypy upgrade broke all our builds because they changed some type of resolution thing. IIRC after some outcry they backtracked and started providing some migration path. The other thing which rubbed me the wrong way was that the python was happy to run the code with completely wrong type hints. I guess I went into it with wrong expectations, even though it says right in the name - it's "type hints". The whole experience felt more like a formalized documentation with partially working optional verification (which can't really be relied upon).
- dang 4y agoThis was also discussed in the last day: Breaking up with Python - https://news.ycombinator.com/item?id=34177703 https://news.ycombinator.com/item?id=34177703 - Dec 2022 (172 comments)
- Simran-B 4y agoHow popular would Python be without the scientific users and the machine learning ecosystem? I have the feeling that its user base is pretty lopsided, but I might underestimate its importance in other areas, like teaching programming. I'd love to see a breakdown of its popularity by field.
- TillE 4y agoVery. Unless you're a diehard JavaScript head, it's still the language of choice for smallish projects like a Discord bot, or for any kind of sophisticated script.
- shanebellone 4y agoAll the top tech companies use Python for product. Google Facebook + Instagram (largest deployment of Django) Spotify (millions of lines of Python) Netflix Reddit Dropbox (millions of lines of Python) YouTube Plenty more examples.
- mihaaly 4y agoAll those use dozens (hundreds?) of other tech for product too. How is this an answer to the question?
- shanebellone 4y ago"How popular would Python be without the scientific users and the machine learning ecosystem?" ... do I really need to explain this?
- mihaaly 4y agoYes. P used for something in places in parallel of hundreds of (several exotic, rarely used) technologies is not really predicting how much P was used without scientific and ML uses. What if P is mostly used for scientific and ML purposes in those places, or as an experiment, study, not necessarily being a backbone? Or with other secondary agenda, overstated, etc. The mere fact that P is used in a huge amalgam of A,B,C,... tells very little alone concerning the question. Almost nothing. Yes, needs some unwrapping what you believe.
- marsupialtail_2 4y agoI just find it funny how my post on why I wrote a SQL engine in pure Python is right next to this one on the front page
- welder 4y agoWe ported a client-deployed command line program from Python to Go two years ago and couldn't be happier. It's solved all our problems around shipping code to customers in different environments. It greatly reduced our support workload. However, we still use Python for APIs and Web Apps. No language is better than another, some are just better for one solution more than another.
- buffalobuffalo 4y agoAs of late, my "language" of choice is a mashup of python and nim. I use python for the ecosystem and nim for parts that need to run fast. It's the easiest interoperability I've ever worked with.
- solarkraft 4y agoPython is pretty decent for small to medium sized stuff where performance isn't a big issue (setup stuff, simple backends, ...). A lot of stuff falls into that category. I especially enjoy the types. Coming from Typescript and being quite a fan of the "dynamic language with optional typing" pattern it was quite cool to find that Python just has that. Sadly quite a few pieces of software are likely going to stick with Python 3.7, so we are probably going to have to stick with the old syntax (explicit imports from typing and uppercase types) for a long time.
- yason 4y agoPython is a good language and I use it a lot. But I can only say Python2 was fun but Python3 is serious. I could live with the quirks and shortcomings of Python2 and still enjoy programming. But even after a decade of history I still find many of the things unenjoyable that Python3 decided to introduce. I know why they did it, it's not an intellectual complaint. It just describes the feeling of starting a new Python program. Used to be great fun. Nowadays, merely a technological compromise.
- bjourne 4y agoIt's the ecosystem. All languages have libraries for bottom-up parsing. But few are as well-documented, feature-full, and easy to use as SLY: https://sly.readthedocs.io/en/latest/ https://sly.readthedocs.io/en/latest/ Many languages have libraries for ANSI color support and pretty printing, but no other language has Rich: https://rich.readthedocs.io/en/stable/index.html https://rich.readthedocs.io/en/stable/index.html While other languages may have rudimentary datetime support, Python has (multiple!) libraries for converting between Hebrew, Hijri, Coptic, and Armenian dates.
- wiseowise 4y ago> Many languages have libraries for ANSI color support and pretty printing, but no other language has Rich: https://github.com/ajalt/mordant https://github.com/ajalt/mordant
- bjourne 4y agoYou are making my point for me. :) That library is nowhere near as well-documented and feature complete as Rich.
- revskill 4y agoI found joy in programming not by importing some libraries and use it. It's the manipulation of data that makes me enjoy programming. Python ? Not fun at all. Try list comprehension. You read it from right to left ? Or process data, not by left to right (pipeline), but in a messy order. One liner lambda ? Indenttion, self, pip hell. Too many small quirks which force me not to use Python for "fun". For serious stuffs ? Maybe python is the best choice now.
- worik 4y agoI had to install Mailman 3 a while ago. It would not run on a $5 VPS from DO, because to deploy it required more memory (two gigabytes I think... mēh). Mailman 1 ran in 40K. It was written in Perl. Clunky, not flash, and functional. Mailman 3 is written in Python using Python tooling - Django I believe. Clunky, flash, and functional. And costed my $5 a month extra. I do not hate Python, I forgive the language for people misusing it. But it is a scripting language. That is what it is good for. Calling other systems. Not building the tight loops
- deleted 4y ago[deleted]
- KyeRussell 4y agoIt’s easy (and common) to point to Instagram et al as examples of people using Python and even Django at scale. Beyond those big hitters though, Python is obviously a very popular language, and Django is a very popular web framework. The people making these tooling decisions aren’t just noobs. Python and Django obviously meet the functional and performance characteristics desired by a lot of people. I have Django projects, some of which I am going to assume are more complex than Mailman, using far less than two gigabytes in production. Not through any extreme optimisation efforts. It’s just…what’s happened. In my experience, the resource footprint you experienced with Mailman is not representative. Notwithstanding the fact that we’ve seen amazing performance improvements in Python as recently ad 6(?) months ago, if speed were my primary concern, I am obviously not picking Python. This doesn’t mean that it should be relegated to the frankly at this point outdated bucket of “scripting languages”. The language’s features, performance profile, and package ecosystem all surpass these use cases. The conventional wisdom, which I completely agree with, is that these days things are good enough that speed need not be a primary concern for most people most of the time. Sure, oldschool Mailman was fast, but did anyone want to or know how to actually work on it anymore? Evidently not.
- senko 4y ago> to deploy it required more memory (two gigabytes I think... mēh That sounds like frontend was written in something requiring a webpack or similar Node tooling, or you also ran a database on the same server. In my experience, small Django setup with PostgreSQL can run fine on droplets with 512mb of ram, provided the traffic is not too heavy. Add containers or anything node-related to the mix, and it'll be 2G+.
- college_physics 4y agoPython has only one really serious drawback for the kind of tool it is and its not remotely its own fault: its not a first class resident on mobile. In a different universe its sweet easygoing manner would have created enormous value by enabling all sorts of casual programmers to have some control over this most ubiquitus of computing devices. Alas we dont live in an era where tech aims to empower users. NB: There are a number of projects that allow some of this (kivy, beeware) but they need to swim hard against the current.
- VectorLock 4y agoPython is weak on front-end web and mobile, but I suppose its impossible to expect Python to be great at everything. For the number of niches it can fill, I think Python is still ahead.
- __MatrixMan__ 4y agoNothing interesting happens on the front end anyway.
- college_physics 4y agomaybe thats precisely because the frontend has turned into a monoculture. having multiple competing stacks with different pedigrees helps innovation. one example I can think of is the erlang/elixir/phoenix/liveview stack that revisits old patterns and gives them new life. who knows, maybe wasm and projects like pyscript will stirr things up
- arcturus17 4y ago> Nothing interesting happens on the front end anyway. That's just like, your opinion, man
- VectorLock 4y agoI know thats a big part of the reason I wish it was accessible natively and frictionless in Python. I'd like to not learn a whole new inferior language to make a decent UI.
- deafpolygon 4y agoIs JavaScript worth looking at, as an alternative to Python?
- baq 4y agoAs an alternative for web apps, yes. In other domains, not really, but it’ll work, it just doesn’t solve any problem better except it isn’t Python.
- jeremyjacob 4y agoYou might look at Deno[0] which provides that scripting language experience, similar to python. [0] https://deno.land https://deno.land
- reducesuffering 4y agoFor most web-based things, frontend and backend, Typescript is where the zeitgeist is these days. Better types, web native, more performant, better async support, better library ecosystem, new cutting edge tech projects, etc. Python's forte and niche is in ML and scientific computing. For quick scripts, either are fine.
- submeta 4y agoBeen using Python for over 15 years, and although there are many programming languages that I find way more attractive (Lisps and functional programming languages), I keep sticking with Python, because you can learn it very quickly, you have a vast amount of resources and a large community that‘ll help you, and there is nothing you cannot do with it: From Webdev to data analysis to machine learning, there‘s a module for almost everything you need to solve. (Edited ;)
- 9dev 4y ago…those ChatGPT responses are getting old real fast by now.
- flashfaffe2 4y agoExactly what I thought reading the comment.
- deleted 4y ago[deleted]
- sigmonsays 4y agoall the reasons i switched away from python (ranked most important to least) 1. packaging python is awful. Turning a large python code base into a deb is awful. I mean really, how many _different_ setuptools or pip do you really need? 2. not strictly typed. Really impedes large code refactors 3. not concurrent. The concurrency primitives are a joke compared to any other language. The GIL kills everything. 4. slow. Python gains all it's performance by doing the important parts in C python is not a good fit for anything I do these days
- baq 4y agoGood decision to move away. Tools are supposed to help, not get in the way. Though types are there, opt-in, and who cares if C modules make it fast if the end result is fast?
- arthurcolle 4y agoWhat did you switch to? Rust?
- reducesuffering 4y agoProbably Go. All of those concerns are addressed by Go, but with a much easier transition and DX (dev experience) from Python than Rust.
- velcrovan 4y agoSo, the reasons are: * I’ve been using it for a long time * I have lots of friends that use it * Even though I’m interested in other languages I don’t have time to learn them These are all perfectly valid reasons! But, they say very little about Python.
- tryauuum 4y agoOne of the reasons for me: * It's preinstalled on my favorite OS But seriously. I like how fast I can start getting results with it. Sometimes I don't even need to create a file, I simply do "python3 -c ..." or use it as an interactive shell
- bmitc 4y agoThis is usually the case with people who use and like Python, which can be a stubborn take. And I can’t quite put my finger on why Python seems to draw out these sentiments. They usually act like there's some objective reason when the reason is usually because they like Python and simply don't want to learn or use anything else. The concluding paragraph of this article confirms this. > Most criticisms I see leveled at Python are still completely unfounded. Many times the criticism can be addressed by using the language in a different way. Is that true? Functional programming missing, slow, poor module system and REPL, weird scoping, environment and distribution issues, the nightmare that was 2.x to 3.x, tacking on features a la C++, etc. > So be it; if I’m not working in one of those areas, then Python is still probably the best fit for me. I used to hear that Python wasn’t the best at any one thing, but it was second best at most things. I agreed with that line of reasoning for a long time, but these days Python is as good as any of its peers for many things, and it’s still quite effective in many areas where it might not objectively be the “best” fit. This is just weird, especially if one doesn't know or use other modern languages. F#, Rust, Elixir, Ruby, Racket, OCaml, etc. In my opinion, unless Python is being used for scripting, machine learning, or scientific programming, then it's the wrong tool. And I think other languages can even compete with the scripting and scientific programming aspects.
- osigurdson 4y agoI’ve started using Python more for fun lately (coming from C and C#). I wish more languages used white space as things are so much cleaner - the odd messed up return statement / parallax error isn’t worth all of the curly brace noise imo.
- wvenable 4y agoI don't like it because at the top of blocks it looks fine but at the bottom I don't know what's going on: something another How nested are these things? I never know.
- c-fe 4y agoWith indentantion lines its clearer. And without indentantion lines, something}}}}} another isnt much clearer anyway imo.
- wvenable 4y agoRight but then you can auto-format it to have indentation.
- dragonwriter 4y agoIf your blocks are big enough that this isn’t obvious, that itself is a code smell. (Brackets also have the same problem.)
- wvenable 4y agoIf you have a loop inside another loop and say and if statement, it can be hard to tell where the end is: I'm in the IF What am I in? vs: I'm in the if } } } What am I in? I'm sure it's just personal preference and I don't like it. I don't think significant whitespace is sort of a universal good that maybe it seemed like when it was proposed. It now seems more problematic to me.
- mberning 4y agoI wish I could just stick with a language forever and thoroughly master it. What did Bruce Lee say about it? He didn’t fear the man that practiced 1000 different kicks. He feared the man that practiced the same kick 1000 times. Something like that. The industry fetishizes the constant stream of new languages and frameworks, primarily based on nothing more than the fear of “falling behind”. It’s dumb, and essays such as the “blub programmer” feeds into it.
- mumblemumble 4y agoThe one thing that scares me about that sentiment, which otherwise I mostly share, is that "forever languages" tend to become kitchen sink languages. Typically to their detriment.
- culi 4y agoYou can learn a language just to explore new ways of thinking and eventually return back to your kitchen sink language. I think it's worth learning a lisp, a functional language, a logic pl, or something from some other paradigm you don't typically use. Maybe do a side project in it. The lessons you learn will surely make you a better programmer overall even if you don't maintain your mastery of it
- osigurdson 4y agoThere is nothing abstract about a kick however. A programming language is always an abstraction, with different languages optimizing for different things. Understanding more than one is helpful imo. The “Bruce Lee” of programming would definitely use assembler and deeply understand computer architecture at a fundamental level. The idiom of Bruce Lee is someone who is hyper passionate about their craft.
- heavyset_go 4y agoNothing really stops you from doing that, as long as you're still willing to learn other languages, libraries, paradigms and whatnot that are needed to get stuff done. I consult as an X "expert", but have worked, and do work, extensively with tools outside of X's scope.
- pkolaczk 4y agoI wish that the pgadmin team hadn't rewritten pgAdmin4 in Python. The GUI performance is abysmal. I can see it lagging when typing SQL text in the window. The experience is really worse than the worst Java IDE I happened to use in the early 2000. The previous version was written in C++ and worked much better. So while Python might be good for some stuff, please, please do think twice before choosing it for GUIs or other kinds of apps that should be snappy.
- dragonwriter 4y ago> So while Python might be good for some stuff, please, please do think twice before choosing it for GUIs The GUI for pgAdmin4 isn’t in Python. Between 3 and 4 pgAdmin didn’t just change from C++ to (largely) Python with otherwise similar architecture, it changed from a classical desktop app to a web app with a Python backend (so you could run it on machine close, in network terms, to your db server, to which your workstations would have only an HTTP, not a pg protocol, connection, without maintaining a separate code base for that and desktop use.)
- serverlessmania 4y agoFor serverless with AWS Lambda, ironically enough, Python is the fattest runtime, and the language that makes more sense, since lambdas are small functions.
- mkl95 4y agoAfter 10 years of nonstop use, I have stopped using Python almost completely. The main reason is that working with Go makes my life much easier when it comes to building distributed stuff on AWS, which is my main focus at work. I miss Python's development speed and how easy it makes it to test things, and I still consider it the king of modern monolithic apps.
- alfor 4y agoPython is the modern perl. It connect useful and fast things build in C in a more easier more expressive but way slower package. That’s his quality but also the biggest problem. When you have something that cross the boundary python/c it get painful as you have two language to jungle with the handling of packaging, compilation.
- jimnotgym 4y agoI had a team recently who were getting really frustrated with Node. They are systems people, integrators that sort of thing. I have been careful about pushing my own prejudices onto them. I made a throwaway comment about how x problem would be so easy in Python and one of the senior guys asked to try it. I showed them Flask about a month ago and they are over-the-moon. The next day they were showing what they had built! Now they have plans for a whole set of simple webapps. It's like a new lease of life!
- rattray 4y agoWhat was the task and why was it hard with express?
- mahoro 4y agoWow. Why did you say 'still'? I use python a more than decade, with other languages as well (go, typescript). And I even don't think to abandon it. I do so many things with it, that it would be nonsense. Yes, the drawbacks are here (async is not as good as in Go, typing I would say is rigid, packaging is not perfect at all). But I have a lot of projects where it just doesn't matter.
- GoofballJones 4y agoAs a layman that's only dabbled in Python, what would be a newer, go-to language today that people use instead of Python?
- tmtvl 4y agoCommon Lisp.
- hsbauauvhabzb 4y agoPeople use Common Lisp for data engineering? If not your response is terrible and the correct answer would be ‘what are you trying to code?’.
- GoofballJones 4y agoI was mainly asking what do people use today instead of Python. Things that Python was usually used for, but now people use something else? Hence the whole "I STILL use Python after all this time" kind of thing.
- ilyash 4y agoI worked with Python for quite a few years but at 2013 it became too painful for "DevOps". The more I was thinking about how things could/should be the more frustrated I was. Python and bash were the "inspiration" that pushed me to start working on Next Generation Shell. Particularly annoying in Python is running external programs (yes, I know there are libraries) and manipulating structured data (list comprehension is not aligned with how I think, which is map() and filter() and lambdas not limited to single expression).
- Zuiii 4y agoAs a person who has written Rust code professionally for 4, here's why I returned to python: batteries included. That's it. Having cargo download 1000s of package from who knows who for basic functionality is unacceptable. Rust's features, while absolutely phenomenal to work with, just aren't worth having insane npm-style dependency graphs and all the risks they entail. In comparison, Python's built-in modules are a godsend. So all in all, I think you should continue to stick with python.
- deleted 4y ago[deleted]
- jackosdev 4y agoI still really like Python for scripts and small programs, but I’m always going to use Rust now for CLI’s or anything larger, I get the problem you have with it, but the trade off is worth it for me being able refactor quickly and with confidence as the program grows.
- Zuiii 4y agoFair point. I dearly miss Rust's type system. I think python vs rust is always going to be a tradeoff either way. I just wish we had the best of both worlds in one language. Rust's base language with python's extensive library. Perhaps a new language will emerge that can satisfy both requirement now that Rust has a somewhat stable "safe" FFI. One can only wish.
- simonh 4y agoNobody uses Python anymore, it’s too popular.
- keithalewis 4y agoWhy do you publish the words you write on a website that makes it difficult to read what you have to say? Python apologists seem to be looking for excuses to avoid the hard work of learning proper programming skills.
- amai 4y agoIf one could use python in the browser and could program mobile apps with it, Python could take over the world. Otherwise I fear it will be Javascript that will ultimately conquer everything.