303 points · by nnx · 7y ago · 161 comments
It may also seem that the text analyzed is the entire post including metadata. For instance "closed" and "duplicate" both show, maybe just be because of "closed as duplicate"... Maybe even including the answers. Which could explain why "pip" would show up so often.
The summaries are also pretty off. "vector" mostly because C++ is about 3D graphics vectors? No, probably just a whole lot of std::vector...
Take data structures for example. "string", "array", and "object" are about as equally prominent in both JavaScript and Ruby (where the dictionary is called "hash"). In Python, however, "string" and "list" far outweigh "dictionary" and "object", which probably says something about what kind of data structures Python developers deal with the most in their lives. Meanwhile, C# and Java seem to be all about strings -- Are people just casting everything to string because they don't want to deal with strict types? -- and PHP is the only language where more people feel like they need to ask about arrays than they do about strings. Which is not surprising since PHP uses arrays for basically everything.
No? How would that even work? It's not really a sensible way to draw conclusions about what people do with the language. For instance, you're much more likely to type 'Object' in Javascript than you are in Python.
“Dictionary” probably loses a ton of hits by the split with “dict”. And “object” is basically a dead word in python now.
Plus, string and lists are typically hit by newcomers before they are taught dictionaries and classes. A lot of SO questions come from homework.
This statement is not true at all. There are plenty of developers that don't post questions to or answer questions on StackOverlow.
Like for this specific example:
https://stackoverflow.com/questions/2612802/how-to-clone-or-...
Knowing the right thing to do requires you be informed about the history of Python language design. Like you could just read the documentation and see that lists have a copy method but it doesn't give you a good grasp of what the alternatives are and why you might choose them. And prior to Python 3.3 you're expected to know that the best practice way to do this is to leverage an edge case in the slicing syntax or the list function. Doesn't matter if you're the best computer scientist in the world, sifting through the massive corpous of documentation and historical knowledge required to write good Python is nigh impossible unless you're willing to dedicate yourself Python.
This is something that languages need to tackle because the gap between doing a thing and doing that same thing in a way that follows language conventions and best practices is too damn high.
That said, copying is in this case the end result of distinct different methods. In the stackoverflow answer, the only redundant way to copy is the .copy method list has. If I understand right it is just a convenient method in order so new programmers don't need to import the copy module.
list() is a common way to create a new list, and the constructor can take a initial sequence. Lists are sequences, so list can take a list, but that is just a side effect.
Slicing is very useful for taking the first or last objects of a list. if you take all the first and all the last objects, you get a copy. Its not the primary function of slicing, but a useful side effect.
The copy module is a lower level interface to work with python objects. As any other lower level interface it mostly used in exception cases when you really want a "deep copy". I have used that trick once in my whole programming career, and it was to work around a restriction in a third-party module for a corner case which they clearly didn't consider.
This, above many other things, keeps me coming back to Python year after year.
Compare it to C, which it has displaced as an introductory language. Python and C are superficially interchangeable to a beginner, but to learn C you have to invest time into pointers and memory management. Python sacrifices the efficiency of direct memory management to avoid the complication of pointers. Arguably, this is a significant benefit because it also cuts down on ways to introduce bugs.
Compare it to a Lisp - Python has a pretty inferior set of basic capabilities (can't even use a dict as a dict key, drives me mad), but that just means there is only one easy way to do things that everyone uses. Less room to think up clever ways of doing things, less complexity reading other's code.
Being the 'best' language for a task has a huge cost - incidental complexity created by including specialist constructs. Python's success suggests maybe programmers prefer this complexity to be encapsulated in a library rather than the language core.
Curious, is this actually something you want to do often? While there is no hashable+immutable frozendict ala frozenset, you could throw one together or even define a hash function on a subclass and "swim at your own risk" not to mutate it later.
I've encountered this enough with lists and the obvious solution is to cast them to tuples. Can't say I've found the same with dicts tho.
As for the comparison with lisp - in most lisps this is a non issue because nearly all structures are immutable
Golang, by contrast, is really quite schizophrenic sometimes about whether it wants to be a high or low level language.
Outside of lisps, I find Python to be one of the simplest syntaxes, so the only effort is the logic to solve the problem.
but often better than master of one
You'll look like a community expert and thought leader in no time.
Helps the resume inhalers that weigh these arbitrary things.
More complex questions about specific frameworks or how that might work with your ORM and memory cache just don't get the attention.
Some programming language and frameworks have more active communities on StackOverflow than others.
So in my sprints, I would typically have 3 tasks in progress at once: 1 I would work on myself, 1 would go on Stackoverflow waiting for the answer, and 1 would be something that required progress from a different team in the company (like a new API endpoint so I could do something on a frontend, or different service)
It was pretty efficient for me. In some communities, the real thought leaders and framework developers are on stack overflow, watching the hashtag like a hawk.
You can also use github issues on the actual package you have issue with pretty well too, alongside it.
So you're really crowdsourcing a lot, and evaluating if that solution is correct enough for your implementation.
But so many times, especially with frameworks, the answer is a good copy and paste job. your mileage and use case may vary.
As for JavaScript, these days I almost entirely rely on the MDN documentation and hardly go to Stack Overflow for that topic.
Python libraries tend to have less documentation and their documentation tends to be less live whereas JavaScript has been more stable lately (something I didn't think I'd ever write).
Funnily enough the last time I really struggled with a JavaScript library's docs it was Tensorflow.js (a Python port).
Also, I'd love to see a comparison that checks "all" JavaScripts (+TypeScript).
If anyone is interested in engaging by the way: https://sopython.com/
I think it's a great measure of a programming language's ecosystem when taking part in the community is such a pleasure.
Also python has readthedoc for non stdlib doc, for js it's very heterogenuous.
All in all, I think the doc situation could be much improved, but not compared to JS.
I think it's interesting how you mention that you struggled with the docs of Tensorflow.js and attribute that to it being a Python port, rather than it being the absolute cutting edge of machine learning. Are other state-of-the-art , pure JS ML (or similar level of complexity and novelty) libraries better documented?
Sometimes parameters were missing, what values you can pass in were missing and there was a general lack of documentation on how to do things (sans a few tutorials).
I can name a bunch of examples. Here is a very simple one: what values can I pass as a loss function to LayersModel#compile? (I had to dig through the code to figure it out)
( https://js.tensorflow.org/api/latest/#tf.LayersModel.compile ) There is just consensus in JavaScript that things that don't get well documented don't get adoption.
Type hints and annotations are a step in the right direction. But the adoption is still not high. That's the blessing and curse of Python - it supports many good practices but it doesn't force you to use them so it really depends on the programmer.
To put it another way, "3 years of experience writing Python code" could mean hacking on scripts or it could mean Enterprise level system design and implementation. Hard to hack around on scripts in Java.
Few people set out to intentionally write messy code. If I had to do it all over again, my earlier code would have been much cleaner.
---
Also I bet that if each language's words were compared to the overall vocabulary for SO, or at least to the cumulative one for these languages, the differences would stand out more.
And of course, the usefulness of a word cloud visualization is highly dubious to me.
It’s a fine language and easy to get running but it seems harder to memorize things in it vs others (if I was 100% of my time using it, it probably would easier).
This x10. I love Python, and use it for small scripts when I get the chance (just used it to test some probabilities last night even), but it seems like I constantly have to look things up all the time in it and can't seem to remember even common, basic syntax in it, despite having used it quite a bit. I really don't know why. I can leave and come back to other languages and not have anywhere near as much difficulty.
I was really impressed, most languages have so many stupid syntax requirements, which really shouldn't be be needed these days - everything compiles to the same assembler code so lets not pretend these languages are doing magical things.
The goal should be for programmers to get the logic across to the computer in the simplest form - and Python is pretty good for that (apart from zfil - seriously, can you get any more unintuitive)
Nope. Some languages get compiled into binaries that are more performant with a smaller footprint. Some have a runtime that provides features like garbage collection and runtime evaluation. Others let you define macros that run at compile time, extending the syntax of the language. Some are graphical live environments. Others offer full high-level concurrency.
Languages have different syntaxes to support the features that their interpreters or compilers can convert into the code that can run on the target environment. This is not going to be the same across all languages, and there are tradeoffs.
They don‘t and many of the dynamic features of Python (and Ruby) cannot be efficiently compiled. That‘s why it relies heavily on C modules.
For example, unlike every other language there is no "unique" function that operates on streams /iterators. Why is that? Because you can do that by creating a set(...) and Pythonistas think there should be only one and one good way to do something. So now nobody ever knows the answer to this and 100% of people learn it by googling and finding the answer on stack overflow.
It doesn't help that nearly everything is untyped and consequently IDE completion is all but useless.
In Pandas, a DataFrame's shape is a property and not a function or method.
However, Python does provide more tools to do more complicated things (async, type hints, etc), but that's not what most people use. They actually don't even know about it, and don't have to care. So it's not the questions you see on SO.
Python has gotten much, MUCH more popular, and we are currently facing a wave of new beginners. Particularly from schools (it's now the default teaching language in most countries) and from loads of workers that can benefit from manipulating data with programming and are attracted to Python for this.
It is precisely because Python is still easy that it's that popular: it doesn't benefit from massive existing code bases like Java or accidental monopoly like JS. We just have a lot of people creating a lot of libs for pretty much everything, because everybody can do it.
I also think the aesthetic of the language plays a big role. Python has been designed to allow you to dev with it with just MS notepad if you have to. It means you don't need to learn about a gigantic and complicated ecosystem to be productive with it (although it does exist): it's a huge help for all those people that are just getting started or not a programmer at heart. It's also harder to create very ugly code because you don't know what you are doing, and if you do, the result will not be as bad as with other languages because Guido made sure of it.
It's also why you don't get multi-line lambdas. Everything is a compromise.
That is one thing about Python that has always been interesting. For new programmers, it's such an attractive language because it's very simple to get up to speed and pump out usable code.
But to really start leveraging Python for more serious projects it's extremely useful to use Classes. And that's actually an appreciable bump in difficulty for inexperienced devs. I've seen go to great lengths to avoid it.
Maybe named structs would be a simpler way for them to level up complexity, especially if they're coming from a C background.
Arguably too much of a compromise. This is just Guido doing a "because I say so" and imposing his bias against functional programming. Give me a properly-designed language like Ruby any day over Python's bag of compromises.
So somehow, languages promoting big chunks of anonymous code never win never win the public heart.
In fact, when you are force by an accidental monopoly to use ine, you get js. What do people do in JS ? Multline lambda are mapped to property names or replaced with await. Registries are used in every framework. We spent 2 decades fixing JS to use as little callback hell as possible.
> setting up a new documentation is very easy with Sphinx
As per my original comment, the idea that documentation should require some kind of external markdown static site generator is bizarro land.
Such as?
But back then, it was an insider's language, my teachers didn't know it existed. Then, year after year, I saw it become more and more popular.
But it is still so easy to use. Nowadays, I use it to teach programming to teenagers, and in less than a week I can teach them pretty cool and complex stuff (UCB algorithm, markov chains, simulated annealing, traveling salesman problem) because the language is so easy it does not get in their way.
"most questioned" is some combination of:
- many beginners
- incomplete or outdated documentation
- not taught (or taught well) in schools
- SO users who don't search for old answers before posting again
See how none of those things, even mixed together, are a good proxy for popularity?
We don't know the mix of the above factors for Python, but without better analysis, the headline here is meaningless outside of its specific claim.
I would expect advanced people to ask just as many questions as beginners (they just do more advanced stuff, and ask questions relating to more advanced things pertaining to the langauge). Good documentation does not stop people from asking questions, as questions are frequently asked to which "RTFM" is the answer. Schools? Actually pupils asking "do my homework" questions is probably a driver in the opposite direction.
I'd say that having many beginners alone is enough to qualify as "popularity". There are more people learning programming that programmers.
By that definition, I'd guess that Python is near the top due to its recent dominance in data science, but Stack Overflow isn't proving or disproving the idea either way.
Using my definition (and likely yours), JavaScript is certainly the most popular. But it's hard to discount the many huge organizations using Java and C#. Their beginners might not be using Stack Overflow as heavily because they have in-house mentorship.
For the last two decades people have complained about (C)Python not being multi-threaded, not jitted, not having tco, being to simplistic and so on. In practice it seem to have mattered very little. For the applications where it do matter, like if you are writing your own language vm, compiler (but see PyPy) or garbage collector, you have to ask "Yes, ok, but how often do you do that?"
But what matters in this world is short term profit. Python is easy to get started with, has a ton of frameworks than can be duct taped into semi-working software by mostly anyone and is taught in many schools.
Computation is a powerful tool wide incredibly wide applications, and Python makes this tool accessible to humanity in general. That is no small thing.
Macros, types, threads, interfaces, lambdas, tail calls, etc. are incredibly niche interests, and perfectly unnecessary for the vast majority of computations that people would like to perform.
Until the last paragraph.
There comes a point in every amateur programmer's evolution when learning which way is up and picking more powerful tools is the right thing to do.
In Python you don't have the full power of the language at your disposal, you can't add primitives like if/class/etc; in Lisp, the sky is the limit.
The lambdas are crippled; as are the threads, using processes is a completely different game.
I would consider spending some of that energy on learning Lisp.
Another problem is "virtualenv". With more "version pinning" capability, there's an increasing tendency for Python programs to require their own special snowflake environment. I keep seeing install instructions which begin "Install virtualenv".
Package authors then worry less about backwards compatibility. That's the sort of thing that generates Stack Overflow questions of the form "Why isn't X working with Y".
Just a guess, of course.
It's often easier to ask and answer your own question on the corresponding Github issue tracker and let Google index it, then to run the SO moderation gauntlet.
Ask a question for (server) Javascript- 99% of people aren't going to try because the code is too unruly to deal with. Its simply faster to google and debug.
Ask a question in python- python code is simple enough to copy paste into SO. And given python has hordes of newbies, they don't realize google is probably a better place to look.
This synergy of situation is why Javascript is getting less questions.
EDIT: I program in both, I don't see why this is invalid.