Python overtakes JavaScript as most questioned language on StackOverflow
globalapptesting.com
globalapptesting.com
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.
This statement is not true at all. There are plenty of developers that don't post questions to or answer questions on StackOverlow.
Yep, and so is abusing it and making the wrong conclusions. It's equally as likely that dictionaries require far fewer questions than strings either because their methods are more intuitive or the questions most people come up with have easily searchable existing answers.
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.
Outside of lisps, I find Python to be one of the simplest syntaxes, so the only effort is the logic to solve the problem.
Golang, by contrast, is really quite schizophrenic sometimes about whether it wants to be a high or low level language.
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
You can still create a hashable key from a dict with FrozenSet(mydict.items()).
tuple(d.items())
>>> tuple({1:2,3:4}.items()) == tuple({3:4,1:2}.items())
False
>>> frozenset({1:2,3:4}.items()) == frozenset({3:4,1:2}.items())
TrueMany major programming languages undersell how natural key-value data structures are; usually by providing unwieldy mapping data types. Clojure has spoiled me.
> you could throw one together
Yeah, I do. Most Python programmers wouldn't see a need for that, but that can be attributed to Python not having the capability by default and so they've just internalised not to use dict for anything that needs to be a key. World's mildest form of learned helplessness, I suppose.
You're being extremely uncharitable here.
To a Python programmer "using a dict as a key" is a nonsensical idea for the same reason "using a list as a key" is — both dicts and lists are mutable. Python programmers don't think of dicts or lists as synonymous with their content.
I'm assuming you don't want to literally use a dict as a key, you want to use the keys and values contained in a dict as a key. Nothing stops you. You just have to say it:
point = dict(x=4, y=5, z=1)
point_reviews = dict()
point_reviews[tuple(point.items())] = "A+++ great coord would point to again"
You might wonder why you can't just use dicts directly. Again, dicts are mutable. What happens if you write: point = dict(x=0, y=9001)
point_reviews = dict()
point_reviews[point] = "Love how it's over 9000 here!"
point["y"] = 8999
result = point_reviews[dict(x=0, y=8999)] # Is this a KeyError or not?
More detail on this issue is explained here: https://wiki.python.org/moin/DictionaryKeysIn the simplest case where you have a predefined list of keys, I'd suggest using a namedtuple instead of a dict. If you need to treat a dict's content as hashable but can't enumerate the keys, `tuple(d.items())` is probably the best choice in recent Python versions. Be aware though that in older Pythons you can't rely on stable sort order of dictionary items, so you have to use something like `frozenset(d.items())`.
>>> tuple(dict(a=1, b=2).items())
(('a', 1), ('b', 2))
>>> tuple(dict(b=2, a=1).items())
(('b', 2), ('a', 1))
Of course, if you can absolutely guarantee how the dictionary has been constructed, it is possible. No rules are absolute. But in my experience, frozenset() is probably better: >>> frozenset(dict(a=1, b=2).items())
frozenset({('b', 2), ('a', 1)})
>>> frozenset(dict(b=2, a=1).items())
frozenset({('b', 2), ('a', 1)})
(Or sometimes even id(), as, if you are confident enough that the dictionary is identical, that might be because it came from the same place. If you are building a reverse dictionary, say, or a cache of indices. Though obviously that it is much more situationally dependent.) dict(a=1,b=2) == dict(b=2,a=1)
is True (on 3.7.3). I'm not too keen on introducing a third type of equality on the same type, even if it makes some theoretical sense. >>> a = {}
>>> x = id(a)
>>> del a
>>> a = {}
>>> y = id(a)
>>> x == y
TrueGive them a string, they return a table or function. Give them the table or function, they return a string.
It’s a useful technique that you can only apply if your hashmap can map anything to anything.
Any hashmap will have problems with storing mutable objects, where the hash value itself can change after the object has been stored, causing some very unwanted paradoxes.
And that is the problem with Python dicts as keys.
I just assumed it was the former, based on the fact that dicts are disallowed as keys.
The reason for that choice is because the object is mutable.
dict = { "foo" : "bar" }
set = { dict : true }
set.has_key?(dict) # true
I'm sure there are other use cases where dict keys can be convenient.
someset = {"one", "two", "three"}
"one" in someset # true
frozen = frozenset(someset)
somedict = {frozen: "example"}
frozen in somedict # true somedict[frozen] # "example"
I would think a NamedTuple would do the trick? (https://docs.python.org/3/library/collections.html#collectio...)
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.
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.
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.
I've met some of the nicest people I know in the JavaScript open source community and some of the most empathic though.
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.
To be clear, I think you’ve done an absolutely great job writing the prose — I just don’t get the cultural conventions around Readthedocs :p
(There’s still wild differences in quality between those four. It seems like documentation UX would be more of a solved problem by now.)
[1]: https://docs.rs/reqwest/0.9.15/reqwest/#structs [2]: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_... [3]: https://developer.apple.com/documentation/corevideo [4]: https://doc.qt.io/qt-5/qtwebengine-index.html
https://yeelight.readthedocs.io/en/latest/yeelight.html
Rust does the same, as far as I've seen (although the docs are a bit too index-heavy). Do you mean something different?
Thanks for pointing this out, and thanks to Stavros for promptly engaging too :-)
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.
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)
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.
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.
In Pandas, a DataFrame's shape is a property and not a function or method.
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.
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.
We can't expect them to known about dataclasses yet.
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.
Sphinx starts from the point of view that you're going to write your documentation as if you were writing a book, then on top of that it has some optional features for pulling in information from source files.
Most of the others start from the view that you're autogenerating documentation from source-code comments, and on top of that there are some optional features for pulling in some extra content from documentation-specific files.
I think the Sphinx way tends to produce better documentation in the long run, but it takes more effort to get to something just-about-adequate.
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.