10 ms·
Comparing Python to Java 8 and saying it’s more readable isn’t showing much. And it’s not very portable the second dependencies with native code (which is comm
by pharmakom 4y ago
Comparing Python to Java 8 and saying it’s more readable isn’t showing much.
And it’s not very portable the second dependencies with native code (which is common since pure Python is too inefficient for many tasks) are used.
I think Python is popular for two reasons:
- it’s believed to be beginner friendly compared to other languages. I’m not really sure why - maybe the whitespace?
- it has an enormous set of libraries available to use
In other words, Python has momentum. The language itself isn’t great, but that is a secondary concern to most, if they are even aware of this at all!
- Akronymus 4y ago> - it’s believed to be beginner friendly compared to other languages. I’m not really sure why - maybe the whitespace? I am leaning more towards it looking like pseudocode > - it has an enormous set of libraries available to use I believe that to be the actual reason. I've long held that python is a kinda bad language, but with FANTASTIC libraries
- deafpolygon 4y ago> but with FANTASTIC libraries written in C _and FORTRAN_ ftfy - it's the only way a tragically slow language like Python can keep up. Edit: didn't forget FORTRAN
- dagw 4y agolibraries written in C That is simply not true. Even libraries like numpy, scipy and scikit-learn are majority python code.
- deafpolygon 4y agoMajority python code, being ~60% is mostly wrapper code, with the slowest parts (the parts that matter) written in C. https://stackoverflow.com/questions/1825857/how-much-of-numpy-and-scipy-is-in-c https://stackoverflow.com/questions/1825857/how-much-of-nump...
- ihatepython 4y agoDon't forget about FORTRAN
- grog_tremor 4y agoEh, you massively overestimate the importance of performance. For the vast majority of use cases, performance just isn't a priority. Doubly so for Python, that shines for simple automation, command line applications, and perhaps some serveless computing. Being easy to write, having a good ecosystem of libraries, and being widely known is typically good enough. I wouldn't use Python to write a robust backend server side application, mostly because the language doesn't lend itself well for it.
- deafpolygon 4y agoEh, you make incorrect assumptions about me. I'm stating a fact why Python is used - the data science ecosystem in Python thrives because of well-written libraries _written in C_ under the hood AND an easy-to-use language that writes like pseudocode. If it was too slow, we'd be doing all of this in Java, the C# or maybe doing it in C/Fortran. But because of some early design decisions (Guido being on the matrix-sig helped), the history behind Numeric/Numarray and finally NumPy and SciPy being based on those efforts allowed it to thrive.
- grog_tremor 4y ago> it's the only way a tragically slow language like Python can keep up. Those were your words, not mine. I need not make any assumptions. I just replied listing use cases where Python shine due to its strengths, performance being mostly irrelevant. I didn't even mention data science. And although it's beyond the point, if I was to use Python, why should I care in which language a library was written? If the language allows libraries written in other languages, this is actually a nice feature.
- UncleEntity 4y ago> If the language allows libraries written in other languages, this is actually a nice feature. That’s actually my primary use case for python, playing with C/C++ libraries in a repl because they don’t natively have one. Sure, it takes work to wrap a library but that’s something I enjoy doing.
- mort96 4y agoDoes it matter?
- UncleEntity 4y agoBecause it’s proof, PROOF!!!, that python is inferior to their favorite language. Just wait until they learn the python interpreter is written in C… <grabs popcorn>
- pharmakom 4y agobeginner programmers don't know pseudo code either though! the best teaching language (imo) is one with few features or surprises. I think Scheme might come out top here.
- dagw 4y agoI think Scheme might come out top here. Depends what you are trying to teach. If you're trying to teach computer science and programming fundamentals, then sure. If you're trying to teach people how to get 'real work' done quickly and efficiently then Scheme will only get in the way and slow people down. For example when I've taught programming, one of the tasks I taught fairly beginner programmers was to grab some satellite images between certain dates, try to detect if there is a forest fire, measure the spread of the fire and plot the spread on a map. With python (and its excellent libraries) this is quite quick and easy, and most people are up and running and hacking around with their programs in pretty short order. They find it really cool and inspiring and makes them quickly realise that programming could be something useful in their day to day job. Trying to start with chapter 1 of SICP and Scheme and working up from there to solving the above problem would probably lead to most of these people giving up on programming very quickly. That being said the few people that made it all the way through that would no doubt be much much better programmers because of it.
- Izkata 4y ago> beginner programmers don't know pseudo code either though! It looks like English. That's all pseudocode is, and they know that well enough.
- mr_mitm 4y agoAnd fantastic documentation!
- ericholscher 4y agoThis is an under-discussed point, at least from my biased opinion. It seems like the Python documentation ecosystem is the best, and has been building fantastic tooling for over 10 years now.
- dagw 4y agoA third point is that python is the default scripting and plugin language in a lot of popular commercial and professional applications. A lot of people I know who learned python did so to automate or extend applications they used for their 'real' work, like ArcGIS, FME, Rhino/Grasshopper, Revit/Dynamo etc.
- pharmakom 4y agoIndeed. I wish Microsoft would push F# as the default macro language for Excel.
- throwawayjdk81 4y agoThe classic "public static void main" example is also getting old. It's been so long since I last wrote it, that I actually had to copy/paste it from the article. I just generate a new project from the "Spring initializer" plugin and jump straight into the real work. If we want to measure developer productivity we should try to compare actual real world usage that goes beyond "hello world" using Notepad. The author did provide more examples in the article, but I think we should just retire the basic minimal hello world example for these types of discussions. If their argument is that Python is simpler for quick scripts and programs, I agree. The same applies to ML / AI where Python has lots of great tools. Once you start looking at other areas (Django and FastAPI), there are many alternatives based on other languages where you can be just as productive. Most of the time consuming work is spent doing business logic where the differences between languages doesn't matter as much. They all have advantages and disadvantages. Personally I prefer static typing for larger projects and teams. If their argument is that Python is better in general, they need to provide better arguments.
- AceJohnny2 4y ago> - it’s believed to be beginner friendly compared to other languages. I’m not really sure why - maybe the whitespace? Good bait. I'll take it. - dynamic, weak (really "duck") typing, meaning users don't have to worry about conversion between things. Want to print() a dictionary of whatever? Sure! - no semicolons to terminate a statement. End of line, that's it - rich standard library, so you can actually get going on things without having to go on a quest to find the right library for your thing. JSON? It's right there. argument parsing? argparse. Http? http.client works... - also yeah the "pseudocode" thing. Python is light on extraneous syntax. Now eliti^H^H^H advanced programmers will frown on many of these same things that make it beginner-friendly... Dynamic typing means that complex designs have to be careful with their APIs, lest you can get tangled up in deep type errors if you're not careful (I particularly hate the "mix-in" pattern). No semicolons mean, uh, long statements need to escaped? The standard library is "where lib go to die" because they can't evolve as much. "Significant whitespace!? What is this, COBOL!?!11"
- pharmakom 4y agoStatic typing had a tighter feedback loop - you don't even need to run the code to see you made a (type) error. Ability to do structural printing of arbitrary structures is not restricted to dynamically typed languages. However, I actually think a good beginner language could be dynamic or static.
- teekert 4y agoI started in Python, as a Biologist (hooray for Jupyter-lab, coding so visually, in small steps, with output just there is so great when starting to learn Python). I ventured into other languages every now and then. For example I tried to make an Android app in Kotlin that gets info from some API. I expect something like this but with more brackets everywhere: import request data = request.get(https://some.api/get_some_json) some_value_I_want = data['dig']['into']['nested_structure'] I didn't get it to work at all, I was lines and lines of code into the program when I didn't even get to see any returned values. Also, say I want to make a nice plot of some tabular data (.tsv), I do: import pandas as pd import seaborn as sns data = pd.read_csv('some_file.tsv', sep='\t') pd.melt(data, value_vars=['s', 'max_vms'], id_vars=['sample', 'process', 'N']) g = sns.FacetGrid(data=data, col='process', row='variable', hue='sample', sharey=False, margin_titles=True) g.map(sns.barplot, 'sample', 'value', order=data['sample'].unique()) Boom, what a plot (or large grid of plots actually), so much information. Can anyone show me how to do this in some other language (but R)? Idk, maybe I'm just not so smart, I just learned to program at 35 after always being a biologist, but any venture into any language has me thinking: Why does this have to be so complicated? (Btw, I'm putting 4 spaces in front of the code, why is it not rendered as code?) When I just started I used Python to read, sort and transform images and output them to a PowerPoint file. One can use CSS like synthax to format the slides. Boom PPT with 120 slides with images and data from some Excel file that convinced a lot of people with a lot of data that fluorescent images next to H&E stains + metadata can be nice. Is it the best way to present such data? Meh. But man was it cool and easy and time saving.
- ihatepython 4y agoThis isn't really programming though. This is just calling out to seaborn and pandas with an unpleasant interface (Python).
- teekert 4y agoOk, then I'm not programming. Call it anything you want, I call it "Being productive." Or, "Saving on time spent clicking around in Excel." or "Automating the boring things." And I find it to be quite pleasant. Maybe it also doesn't help that out there, in the C++, Rust, Javascript, Go world I'm going to run into people with usernames like "ihatepython".
- bionade24 4y ago> Comparing Python to Java 8 and saying it’s more readable isn’t showing much. It shows an obvious reason why a lot of beginners choose python, even when learn Java basics in university first.
- noirscape 4y agoPython's biggest advantages are in my experience: 1. Near zero boilerplate. Python's boilerplate is usually no more than setting up a class and then calling a method. Often you can skip the class and just call it directly. This is probably the biggest strength; to give you an example, my standard test for a languages approachability is "how much work do I need to put in to get a very simple JSON file from a web URL" (nothing fancy like POST, just an HTTP GET). With python, a call to urllib.request.urlretrieve and then a call json.loads are all you need. In Java, you need to manually implement a bunch of boilerplate code that looks horrible, need to think about the size of your response in memory and often need to pass in configuration options that should be a case of "works by default" but aren't because the standard is ages old so it needs to be manually toggled on. Part of that is that the Java stdlib consists largely of reference implementations rather than actual implementations, which means that anyone who wants to implement something in Java will usually end up falling back to the stdlib interfaces, which in turn suffer from being stdlib interfaces, so a lot of "should really be on by default" expectations aren't on by default since the stdlib is where code goes to die, so you instead start piling on features. 2. Interop with C. I hold the opinion that C is a great language that doesn't work very well once you get to any form of scaling. Python allowing developers to take the slowest parts of their code and writing it in C to speed it up is one of the easiest speed gains to make and it avoids the biggest bumps that come with using C as your primary language in terms of project structuring. 3. Library support is as you say, good. If you need it, there's probably a package for it. Pypi is dependency-wise kind of a disaster but if you know how to set up requirements.txt, it works really well. Most libraries ship with "sane" defaults too. All of these combine to a language that's easy to prototype, easy to expand It's important to keep in mind that pythons biggest successes aren't in the speed-focused, low-memory environments where every speedgain is necessary. Its success lies in conventional desktops and servers, which have much more processing power and often have more leniency in being a bit slower. With python you can write something in 3 hours what would take a day in another language, at the cost that instead of being lightning fast and done in 10 seconds, you need to wait 30 seconds. That's an issue for some environments but in 99% of the cases that's not a problem. That isn't to say the language is perfect (no language is), but speed of development at the cost of slightly slower execution time is the main reason why python got popular.
- 4y ago
- Kwpolska 4y agoI agree comparing hello world code in Python and Java is a bit pointless. Hello worlds might be much shorter, but at scale, this becomes less relevant. Also, comparing to a language that hates change is unfair, if you compare it to C#, which is improving over time, you'll see the hello world also takes one line (but is 13 characters longer, so Python still wins!)
- goto11 4y ago> if you compare it to C#, which is improving over time, you'll see the hello world also takes one line Well yes it it does now, since C# 10 or, but in Python is have been a one liner since the beginning 30 years ago, and over the decades it has build a following. And even with recent efforts to cut down on boilerplate, C# still has more cryptic syntax than Python. I'd argue C# is more maintainable in the long run due to the static typing, but there is no way it is as accessible to beginners.
- goto11 4y ago> it’s believed to be beginner friendly compared to other languages. I’m not really sure why - maybe the whitespace? Experienced programmers tend to forget how the experience was as a beginner programmer. But Python grew out of actual usability research into teaching programming to beginners. Logo is another language with the same background, but it never escaped that niche. The success of Python is because it attractive to beginners but remains a powerful tool as the programmer becomes more experienced. Whitespace is definitely a factor - or rather the lack of redundant braces. Beginner programmer seem to really struggle with the lack of correspondence between the visual structure and the logical structure in most languages. Even experienced programmers get tripped up by erroneous indents. Python just solves this once and for all. The lack of type annotations is also a factor. For beginners this is just an additional layer of complexity. Scheme is great for teaching computer science students, but if you are just a regular Joe researcher wanting to get the job done, you want to write "2 + 2" like everybody else in the world, not "(+ 2 2)" Most languages are designed to attract experienced programmers, e.g. by having C-like syntax which they may already be familiar with. But it has a cost for beginners.