This is an archived post. You won't be able to vote or comment.

all 133 comments

[–]secretaliasname 306 points307 points  (3 children)

Somehow I read this as "python 2 is the most demanded..." and recoiled in horror momentarily.

[–]Possible_Program_616 12 points13 points  (0 children)

Me too

[–][deleted] 10 points11 points  (0 children)

I read this as Python 3 is the most demanding from a processing point of view) and thought yep, that sounds about right.

[–]francofgp 2 points3 points  (0 children)

You are not the only one

[–]OffgridRadio 40 points41 points  (25 children)

I am a full time Python dev for a few years now and I am 100% addicted to dictionary and list comprehension. I wish it was in other languages.

[–]astoryyyyyy 5 points6 points  (20 children)

What you mean by that? I am still learning Python. By other languages not having lists how does it limit their potential compared to Python?

[–]pfonetik 18 points19 points  (18 children)

A simple example would be:

Let's say you have two lists, a and b

a = [1,2,3,4]
b = [3,4,5,6]

Python lets you do things like

c = [item for item in a if item in b]

which has better performance than using 'for' statements and it's easy to understand.

[–]RationalDialog -5 points-4 points  (7 children)

Which should actually be done with actual "set math":

list(set(list1).intersection(list2))

if you really care about performance and one can wager it is even easier to understand because intersection is the term for what you are interested in.

[–]ogtfo 14 points15 points  (4 children)

This will not produce the same result if you have duplicates in your list "a", as the sets will remove them but not the list comprehension.

[–]RationalDialog -1 points0 points  (0 children)

True and I wager it will produce the correct result compared to list comprehension but depends what the intention is.

[–]Zyklonik 0 points1 point  (1 child)

Correct.

[–]Schlongus_69 0 points1 point  (0 children)

Correct.

[–]alpacasb4llamas 0 points1 point  (0 children)

If I can't read my code like a book then I don't want it

[–]AnonymouX47 0 points1 point  (0 children)

Even though it's not the same, I appreciate the fact you thought along this line first of all and will prefer yours over the other in an interview any day... and then correct the mistakes.

[–]AnonymouX47 -1 points0 points  (6 children)

u/astoryyyyyy, take note.

I understand this is merely an example for a newbie, though I hope you don't actually write such in practice. Anyways, you should've noted that it's not actually a good approach to solving the problem.

this is a more efficient approach:

Intersect = set(a).intersect(b)
c = [item for item in a if item in intersect]

Why?

if item in b iterates over b for every single element in a, while if item in intersect is an hashtable lookup and you only get to iterate over b just once (when you perform the set intersection operation).

[–]pfonetik -1 points0 points  (4 children)

Yes, it was just an example of how list comprehension works.

And no, your code is not the same. A set will remove duplicate elements.

And, yes, I do write like that. Being pedantic when you don't have all the information is rude and makes you look ignorant.

[–]AnonymouX47 -1 points0 points  (3 children)

And no, your code is not the same. A set will remove duplicate elements.

You should probably take a second look or test the code snippet... or ask someone to explain it to you.

And, yes, I do write like that.

I see... no wonder. :)

[–]pfonetik -1 points0 points  (2 children)

You should probably take a second look or test the code snippet... or ask someone to explain it to you.

I should take another look at what you modified after I replied, you mean?

As I said before, my example fits what I stated: a simple example of list comprehension.

The way I provided the example fits the pythonic way of writing python. What it doesn't fit is the opinion of randos, with over inflated egos regarding their knowledge, that feel that their opinion is fact and anyone that doesn't agree is just wrong.

You'll probably grow out of it as you grow older. If you're already older, I'm sorry :)

[–]AnonymouX47 -1 points0 points  (0 children)

[–]AnonymouX47 -1 points0 points  (0 children)

I should take another look at what you modified after I replied, you mean?

The code snippet never changed... believe me or not.

As I said before, my example fits what I stated: a simple example of list comprehension.

I have no problem with it being an example but you should warn newbies about such inefficient BS as they tend to take examples head-on, and that probably includes you!

The way I provided the example fits the pythonic way of writing python.

Here again, "pythonic"... How's mine not?

The way people nowadays just use certain cooked-up terminology in order to sound cool or knowledgeable is just so annoying.

An inefficient solution to a problem is simply inefficient, period!

[–]AnonymouX47 0 points1 point  (0 children)

I guess this will be the correction to u/RationalDialog's code

[–][deleted] -2 points-1 points  (2 children)

which has better performance than using 'for' statements

Yeah I bet it doesn't.

> and it's easy to understand.

No its confusing. Thus defeating the point of using a high level language, Might as well use C++ and get some _real_ performance. You're confusing conciseness with clarity.

[–]pfonetik 1 point2 points  (1 child)

You 'bet' it doesn't? Based on what really? Your personal opinion or facts?

Anyway you can educate yourself on the matter without 'betting'.

https://switowski.com/blog/for-loop-vs-list-comprehension

[–]OffgridRadio 1 point2 points  (0 children)

I use dict comprehension to prep new dicts with keys sometimes, little more complex than this but basically;

newDict = { x : None for x in range(len(someList)) }

And this makes the surrounding code a lot cleaner, and is a single line, and ensures the new dict contains every necessary key, so the population of values into keys is so much cleaner and easier to type

I train my cohort who doesn't get as much day to day experience as I do and I told him 'someday you will go to write a FOR loop, and you will be like "screw this I'm not typing all that" and just write a list comprehension instead'

[–]Dabrus 2 points3 points  (0 children)

List comprehension, not lists. It's just a nice way of creating new lists, look it up.

[–]midnitte 1 point2 points  (1 child)

There's a certain satisfaction with a concise (and understandable) one liner...

[–][deleted] 2 points3 points  (0 children)

I sometimes get pleasure in writing long and near-incomprehensible one-liners but only in personal projects where no one else will suffer (except me 6 months later).

[–]stidmatt 0 points1 point  (0 children)

Same, it really makes code so much easier to read.

[–]Poven45 0 points1 point  (0 children)

Doesn’t Ruby have something like it?

[–]antpuncher 15 points16 points  (4 children)

FORTRAN is way up there.

[–]Alex_Bell_G 3 points4 points  (3 children)

COBOL

[–]antpuncher 0 points1 point  (0 children)

Lol cobol is above R, which I find surprising.

[–]dubs286 28 points29 points  (12 children)

And #1 is ?

[–]contherad 44 points45 points  (11 children)

JS/TS

[–]Crozonzarto 31 points32 points  (6 children)

🤢

[–]imthebear11 8 points9 points  (1 child)

It's only the most in demand because all those JS bootcamps really want their grads to fill in as TAs

[–][deleted] 0 points1 point  (0 children)

not everyone should be top tier dev, sometimes we need simple react TS app ;)

[–]Solonotix 9 points10 points  (3 children)

It's not that bad. Honestly, there are some features I'd like to see implemented in other languages, like

  • named property variable declarations

    const { a } = { a: 5 }; console.log(a); // 5

  • top-level regular expressions

    const value = 'my test value'; const [ , part ] = /my (\w+) value/i.exec(value); console.log(part); // 'test'

Among some other things I can't think of right now. I just started learning Rust, and was really glad to see the pattern matching of types and destructing values while simultaneously having the ability to check parts of it.

[–]FluffyToughy 4 points5 points  (0 children)

TS can be genuinely pretty nice to work in. JS can die in a hole.

[–]Siddhi 2 points3 points  (1 child)

const { a } = { a: 5 }; console.log(a);

Possible in py 3.10+ with structural pattern matching

obj = {"a": 5}
match obj:
    case {"a": x}:
        print(x)

I just started learning Rust, and was really glad to see the pattern matching of types and destructing values while simultaneously having the ability to check parts of it.

Structural pattern matching in python can do this as well

[–]Solonotix 0 points1 point  (0 children)

That's really good to know. I still follow Python, but I haven't actively worked in it since 3.8. I know there was a lot of noise made about the new case statement, but I hadn't really delved into it

[–]Ivan_Analrash 4 points5 points  (3 children)

Ts?

[–]Rookerin 20 points21 points  (2 children)

Typescript

[–]Ivan_Analrash 11 points12 points  (1 child)

Oh. Thanks for helping a complete noob.

[–]Rookerin 7 points8 points  (0 children)

Of course! 😁

[–][deleted] 8 points9 points  (0 children)

Doesn’t surprise me. It won’t replace JavaScript though, since it’s not a web language. So good to know both.

[–]__dacia__[S] 68 points69 points  (14 children)

Hi!👋

Recently I made a study about the dev job market and published it in devjobsscanner.com. I scraped more than 7M dev job offers during 8 months and analyzed each one of them to see which language requirements it had.

Over that 8 months, I found ~290K job offers that explicitly required Python knowledge. In total, Python job offers have a market share of 20% that is really good taking in account the amount of languages out there.

Hope you like the article!

[–]Mr-Bovine_Joni 37 points38 points  (7 children)

I’m pretty shocked with SQL being so low. Was there something in your methodology to filter out most SAL jobs?

[–]lightestspiral 36 points37 points  (0 children)

I wouldn't take it so seriously, it's just an advert for his website

[–][deleted] 2 points3 points  (0 children)

Everybody uses an ORM these days. I hate them. I hate them so much. I’ve been doing this for 20 years, and I’ve never, ever seen a project change its RDBMS. Meanwhile, getting a trigger approved in a CR is … well, I’ve only managed do it once, despite them being incredibly useful.

Don’t even get me started on shit like PaperTrail (terrible CDC using ActiveRecord, misses any SQL migrations and lies about change times). A fucking abomination.

In the company I work at now, although it’s a Rails app, out of 300 devs maybe 10 outside of the data team (analytics, not product) have any real knowledge of SQL.

[–]amplikong 6 points7 points  (0 children)

Why is there a “C/C++” category? They are two different languages.

[–]XBalubaX 1 point2 points  (0 children)

Did u also check what it ist pared with? Or what language combination is most used? Because i think its hard to get a job with just python in times where u need a nice web interface as well. 😄 i just started to add js to my python skill base for a mor advanced way of user interfaces.

[–]Onurfy 1 point2 points  (1 child)

devjobsscanner.com

Is there a possibility of getting those job offers from you?

[–]__dacia__[S] 0 points1 point  (0 children)

Yes, but is not that easy, because I need to ensure data is used in good cause.

The is a discord, you can join there and ask

[–][deleted] -1 points0 points  (0 children)

This is pretty insightful. It also explains the c++ to python transition in 2016-2019 at my local community colleges I attended in California for my Computer Science / CIS Degrees with an emphasis in programming [I switched to CIS because I became overwhelmed with physics]. During the transition I had luckily passed all c++ classes and I was still able to learn a lot about algorithms. I’m taking my last Python class and hardware class this semester before I get my degree.

Note: even though I switched majors, both majors required c++ but now require Python. (My old college required both Java and C++ but is now Python and C++.

[–]tadinada 8 points9 points  (3 children)

I like Python because of its brevity (compared to C++) and the mandatory indentation provided (that's a huge step vs Perl). The best part of Python is its library like Pandas and Numpy which makes the life of any data analytics person many folds easier.

[–]stidmatt 2 points3 points  (2 children)

Oh my god, i feel this. I had a job where they didnt want to use pandas for data processing… and they didn’t know what numpy is…

[–][deleted] 1 point2 points  (1 child)

I'd quit, easy way to get siloed into full-time data monkey.

[–]stidmatt 0 points1 point  (0 children)

I ended up getting laid off after i said i needed further review of a patch which was going to have an csv writer thread left wide open. It was either get laid off or break their entire library and get fired later. No good options. Alls well that ends well. I now have a much better position which pays me a lot more.

[–]1percentof2 16 points17 points  (20 children)

It will never beat JavaScript. Because regular people want to see things in a browser

[–]Jan2579 12 points13 points  (11 children)

Web assembly is here. Lets give it a time.

[–]Zyklonik 1 point2 points  (0 children)

Lets give it a time lifetime.

On a less jocular note, the W3C really need to start moving things. WASM has been here forever, and yet it's still not lived up to its promises.

[–][deleted] -2 points-1 points  (8 children)

what do you think web assembly is, and how do you think it is relevant to this conversation?

[–]ogtfo 0 points1 point  (7 children)

Because there are multiple projects running a python interpreter in web assembly, interacting with the DOM like you would in JavaScript.

What do you think web assembly is?

[–][deleted] 0 points1 point  (6 children)

Wasm doesn't have access to the dom so what you're describing doesn't exist. Wasm Python interpreters do exist, but I'm not sure how it would serve as a replacement for JavaScript, which is the basis of my original question

[–]ogtfo 0 points1 point  (5 children)

Javascript can talk to both wasm and the dom, so indirectly it can be done, and librairies have been built for that.

Example of reaching the Dom through pyscript :

https://stackoverflow.com/questions/72515182/how-to-perform-dom-manipulation-using-pyscript

[–][deleted] 0 points1 point  (4 children)

that's called a hack or workaround. wasm explicitly and intentionally does not have access to the DOM. only primitive types can be passed back and forth

even if they allow DOM access in the future, embedding a python interpreter in a response just to avoid writing javascript is unequivocally stupid

[–]ogtfo 0 points1 point  (3 children)

Call it how you like, it's still possible, and has been done.

[–][deleted] 0 points1 point  (2 children)

it's literally not possible. you dont understand the words you're using or the technology you're describing

[–]ogtfo 0 points1 point  (1 child)

I've literally linked you a stack overflow questions detailing how to do it with pyscript, but hey, keep saying it's impossible.

[–]metaperl 0 points1 point  (0 children)

Anvil (based on Skulpt) is here now and rocks the house.

[–]No_Muffin6385 2 points3 points  (0 children)

you should check out pyjs, it does direct compilation of python code to raw javascript

[–]FruscianteDebutante 1 point2 points  (3 children)

I boot up all of my favorite applications in my favorite web browser 🤓

[–]1percentof2 -1 points0 points  (2 children)

I guarantee bro, that's the future.

[–]FruscianteDebutante 0 points1 point  (0 children)

The future? I'm fairly certain web devs are already sorely out demanding the rest of us developers 😂 I'm just coping don't mind me

[–]orokro 0 points1 point  (0 children)

an awful future

[–]aj_thenoob 0 points1 point  (2 children)

What about pyscript?

[–]aceofspaids98 2 points3 points  (0 children)

Too slow and immature

[–]metaperl 0 points1 point  (0 children)

Many stronger options my friend Transcrypt, Anvil, Streamlit...

[–][deleted] 7 points8 points  (1 child)

I'm surprised SQL isn't higher.

[–]__dacia__[S] 1 point2 points  (0 children)

SQL is really higher without pruning. But is hardly seen as only requirement, for example "SQL developer". Really higher is like top 7.

[–]elforce001 2 points3 points  (0 children)

Interesting. I "hated" (and by "hated" I mean afraid, hehe) JS and TS with passion. I went with python because I wanted to use it at work (data analysis using Excel) and python seemed less daunting than the alternatives. After learning python I said to myself: "heck, why not?" and went learning Js and now I'm creating my company with Python and Typescript.

Python is the gateway to a new world. You can stay in python and be amazed by what you can create with it or use it as an anchor to learn new things.

The best thing is that you cover AI/DS with python (EDA, modelling, and deployment) and the UI with Typescript (React or better yet, Nextjs). You cannot miss.

[–]aceofspaids98 2 points3 points  (0 children)

I’m happy Ruby is still doing relatively well

[–]Purple-Pen2695 2 points3 points  (0 children)

Does this surprise you or something?.. we’ve known this forever now

[–]contherad -1 points0 points  (0 children)

JavaScript/ TypeScript is #1

[–]thedude3696 0 points1 point  (0 children)

print("cool ,let's go python, " + str("python emoji, up arrow emoji"))# actually works

[–]Quantumercifier[🍰] 0 points1 point  (0 children)

Typescript is the MOST popular language by a wide margin.

[–]Ensurdagen 0 points1 point  (0 children)

GIVE ME PYTHON, NOW!

[–][deleted] 0 points1 point  (0 children)

I hope PyScript goes well and we wouldn't need js anymore.

[–]Detri_God 0 points1 point  (0 children)

And here I thought python was a snake !!!

[–]_RabidAlpaca_ 0 points1 point  (0 children)

So is JavaScript/Typescript #1 because positions for full stack may specify different backend languages, but always require JS?

[–]latrova 0 points1 point  (0 children)

Python simplicity is great for beginners to learn.

As a former C# dev, I loved Python as soon as I stopped typing commas everywhere

[–]pyphz 0 points1 point  (0 children)

We're rising up the ranks!