News for hackers. Stuff that matters.
Re:Why Python keeps growing, explained by teekert on Friday March 03, 2023 @03:58AM (#35007337)
I 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.

Re:Why Python keeps growing, explained by ihatepython on Friday March 03, 2023 @04:13AM (#35007430)
This isn't really programming though. This is just calling out to seaborn and pandas with an unpleasant interface (Python).
Re:Why Python keeps growing, explained by teekert on Friday March 03, 2023 @04:18AM (#35007451)
Ok, 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".

Re:Why Python keeps growing, explained by polotics on Friday March 03, 2023 @04:37AM (#35007576)
Don't feed the trolls! Case in point, this is a quote:

quote_from_user_ihatepython == """ ihatepython 1 day ago | parent | context | prev | next [–] | on: Moscow Metro launches longest metro circle line

    You realize that the Nazis still exist and are Ukrainian, right?
"""
Re:Why Python keeps growing, explained by trymas on Friday March 03, 2023 @11:01AM (#35011306)
Sometimes I wish for "block" function in HN for such trolls (I really hope it's no-life troll working for 5 rubles per comment and not a real person with genuine hateful opinions like that).
Re:Why Python keeps growing, explained by dagw on Friday March 03, 2023 @04:31AM (#35007532)
This isn't really programming though.

It is however what a lot of people who 'program' at work do every day. Python actually lets working professionals solve real problems they actually have at work quicker and easier than any other programming language.

Re:Why Python keeps growing, explained by UncleEntity on Friday March 03, 2023 @04:32AM (#35007536)
Ironically, TFA claimed there are a bunch of people “not programming” in python getting real work done out there.

But, with a user name like that, I know I’m just wasting my time responding to you.

Re:Why Python keeps growing, explained by vgatherps on Friday March 03, 2023 @08:07AM (#35009046)
"That's not programming, that's just calling libc with an unpleasant interface"
Re:Why Python keeps growing, explained by DeathArrow on Friday March 03, 2023 @08:13AM (#35009116)
Your examples don't depend on the language but on the libraries. You can be as simple and concise in most languages, provided the libraries let you, instead of needing to add boiler plate.

But what if your web request fails? Do you deal with it in time or use some_value_I_want which might contain junk?

Re:Why Python keeps growing, explained by UncleMeat on Friday March 03, 2023 @08:22AM (#35009223)
This is just a property of having libraries. If you've got the same libraries in Java then the code looks identical except that you stick to word "var" in front of lines 4 and 6 and you don't have named arguments.

Python does have a great data processing ecosystem. But that isn't really a property of the language.

Re:Why Python keeps growing, explained by pbourke on Friday March 03, 2023 @11:37AM (#35011806)
Creating a new venv, installing a few needed libraries that you know the names of with a simple command and writing a quick low-ceremony script that uses those libraries is frictionless in Python. Doing that repeatedly in nearly every other major language is not as easy.

Some languages have a good integrated tool chain (Rust, Go) but are not as approachable and forgiving.

Some are approachable but lack the friction-free story for locating and installing 3rd party dependencies.

Re:Why Python keeps growing, explained by teekert on Friday March 03, 2023 @11:53AM (#35012061)
Poetry is indeed very nice for that. Bit of a learning curve but then very easy to push packages to PyPI or internal things like Artifactory.
Re:Why Python keeps growing, explained by sethrin on Friday March 03, 2023 @12:03PM (#35012210)
The most similar language to Python is Ruby, not Rust or Go, and Ruby is better at the things you've listed. Which would bring us back to the previous point that it's not actually about ease of use.

Someone else identified Ruby's fatal flaw as not having good C tooling, and I think that's probably accurate.

Re:Why Python keeps growing, explained by mixmastamyk on Friday March 03, 2023 @12:21PM (#35012469)
Ruby has odd, once unique syntax that looks strange to anyone raised on C-like syntax, including js and java. Python is similar, simply removing redundant braces. So no ruby was not better at things most folks care about.
Re:Why Python keeps growing, explained by sethrin on Friday March 03, 2023 @05:11PM (#35015743)
You seem to have confused personal familiarity with ease of learning.
Re:Why Python keeps growing, explained by mixmastamyk on Saturday March 04, 2023 @01:25PM (#35023104)
Things that are familiar are easier to learn, it’s a fact. As someone raised on math notation, then industry exposure. Ruby being a odd one out did it no favors.
Re:Why Python keeps growing, explained by pharmakom on Friday March 03, 2023 @09:58AM (#35010416)
I think you are confusing familiarity with ease of use.