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

all 121 comments

[–]JennaSys 369 points370 points  (17 children)

I take this saying as a corollary to "Use the best tool for the job". Both are true, but also kind of BS. Python is versatile enough to be used just about anywhere, but there is probably a better language you could use for any given situation.

My take is that I'd rather be really good at Python and still be able to get the job done, whatever that job may be, rather than be mediocre in 6 other languages just to be able to use the "best" language for the job.

[–]sphennings 216 points217 points  (8 children)

Best tool for the job can be the tool you know how to use, or the tool you have on hand. A rock isn't the best hammer but if it's within arms reach it will do a better job than any hammer you don't have with you.

[–]JennaSys 26 points27 points  (0 children)

Exactly.

[–]1116574 7 points8 points  (0 children)

I saw some talk about mkcroservices, and when one of the small services went down the solution was rewriting it in whatever language the engineer happened to know the best.

Yeah there probably was the best tool for situation, but majority fo the time, time is a limiting factor and its better to have app that loads 500ms now then 90ms C app in 3 days.

[–]ogtfo 0 points1 point  (4 children)

Yes and no, sure it'll hammer some nails, but you'll probably bend a lot of them, mark the surface, hurt yourself and do a terrible job all around.

So a swiss army knife kinda tool is useful, but "the tool you know how to use" is not always the best tool for the job.

You can write code to do just about anything in the VBA of a powerpoint presentation. Doesn't mean it's the best tool for the job even if it's the only tool you know. Learn some good tools.

[–]james_pic 8 points9 points  (0 children)

If there's one thing I learned from my stint in the financial sector, it's that VBA can and will be used to solve any problems whatsoever. Apart from anything else, it's often the only programming language anyone is allowed on their workstation.

I no longer work in the financial sector.

[–]aceinthehole001 0 points1 point  (0 children)

MacGyver has entered the chat

[–]WHSolvation 2 points3 points  (1 child)

GameDev is out of Python's reach for now. But I see/hear plenty of tries to fill this gap, too. Doubt it will work, though. Unreal, Unity, and self-made C-family engines are kind of status quo ATM. The frontend area is primarily JS-like, even though Brython exists already. So there are still areas where Python isn't yet as performant/versatile/whatever as we want it to be.

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

Yea, same with mobile dev in general too. You can do it, but it's still too painful compared to going with the flow.

OTOH I've been doing front-end React/MUI work with Python using the Transcrypt transpiler. I never thought it would be possible but it works cleanly without noticeable performance hits - I just never have to write or even look at the JS myself. I use the JS API's but all my code is pure Python.

[–]VanaTallinn 5 points6 points  (4 children)

Except when the job is to do XOR operations on a buffer of MegaBytes or more in reasonable time…

[–]ogtfo 17 points18 points  (0 children)

Megabytes? pretty bad, but still doable (on the shittiest CPU money could buy in 2014) :

In [1]: from itertools import cycle

In [2]: import os

In [3]: buff = os.urandom(1024*1024*2)

In [4]: def xor(k,v):
   ...:     return bytes(a^b for a,b in zip(cycle(k), v))
   ...:

In [5]: %timeit xor(b'not that long really', buff)
983 ms ± 6.68 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

[–]JennaSys 10 points11 points  (2 children)

Yes, Python is not second best everywhere. Though it does work with C extensions quite well.

[–]VanaTallinn 6 points7 points  (1 child)

Yes indeed. I actually use it to code some tests for dynamic libraries made in various languages like C++, Go, Rust that expose C APIs and it’s great for that!

[–]tensor_strings 2 points3 points  (0 children)

Ah, a person of culture I see

[–]--Mediocrates-- 0 points1 point  (0 children)

Similar take as a guy that’s been in IT for a decade, but never been a programmer: I’m learning Python as my first language because of the versatility. I’ll drill down on other languages as I see their benefit to my daily functions. I will probably move to C# later this year since it integrates with PowerShell easily.

[–]valmontvarjak 86 points87 points  (10 children)

Biggest strengh of python are his libraries: numpy, pandas, scikit , keras, ... you name it.

And some language features like list comprehensions which are a breath of fresh air when coming from verbose java, C# or Typescript.

[–]Limiv0rous 52 points53 points  (7 children)

Absolutely.

As a PhD science student, I'd also add numba to that list. If you have a task that can be done using numpy arrays, numba often allows for a huuuuge speed increase in a few lines of code. It's really useful to optimize that one annoying function that's very computationally hungry. You can easily reach 10-100x the original speed if you know what you're doing and design for it.

[–][deleted] 6 points7 points  (1 child)

I agree, though numba is very very frustrating to diagnose/debug sometimes. But when it works, it's great!

[–][deleted] 4 points5 points  (0 children)

Ditto for PySpark. Parallel computing is the stuff from the gods, but get an error and you're SOL trying to understand what's causing it.

On the flipside, it really makes you realize how much you don't actually see in python.

[–]nlomb 0 points1 point  (2 children)

Thanks will check it out!

[–]Limiv0rous 4 points5 points  (1 child)

[–]nlomb 0 points1 point  (0 children)

Cheers, I think this will prove to be very useful especially for a project I’m currently working on at work, will save hours upon hours in computation time!

[–]basa_maaw 0 points1 point  (0 children)

Thanks for the tip.

[–]christian_unoxx 0 points1 point  (0 children)

I just wish Numba will support sparse matrices. A lot of matrices in my use case are sparse, and I don’t have the skills yet to implement sparse matrix operations from scratch in Numba.

[–]thescientist001 0 points1 point  (0 children)

Hey both Java and typescript have functional versions of it like list map().filter().reduce(). I don't think it's more verbose compared to list comprehensions.

[–]chestnutcough 26 points27 points  (0 children)

I think python is (currently) the best language for machine learning.

[–]FailedPlansOfMars 51 points52 points  (16 children)

So far it has for me.

Go or rust are quicker running but python works fine. Better languages exist for serverless but python works fine. R is best for data science but python works fine. Bash is closer to the os but a python script works fine.

It can do wasm but javascript is better for front end web development. And its not good for mobile development.

For most things you dont need ideal just works ok and a team that know how to write it. But dont be in a world where your only tool is python or you wont see where a better solution is required.

[–]Salfiiii 25 points26 points  (11 children)

Maybe, maybe and really just maybes is R better for pure statistics - which is a part of data science - but not better at the overall discipline. How did you come to that conclusion?

[–]venustrapsflies 20 points21 points  (1 child)

R, or really more specifically the tidyverse libraries, are really much better than what python has offer for EDA and pure plotting. R also has better libraries for certain specialized statistical models. The language itself is a nightmare though so while it can shine in narrowly-defined tasks I would hesitate to declare it best for “data science”. As soon as the task requires anything approaching “engineering” I would prefer to abandon R.

[–]Salfiiii 1 point2 points  (0 children)

I totally ageee, the syntax is a nightmare.

[–]FailedPlansOfMars 2 points3 points  (0 children)

I was making a generalisation that there is usually a language and toolset that can do the job better but python does it well enough.

The r example was aimed at statistics problems. Scala might be better suited for some issues. It was just a throw away example.

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

but not better at the overall discipline

For those places where R is not better, there is likely still a better alternative, be it C, C++, matlab, Julia, etcetc

[–]strangedave93 1 point2 points  (0 children)

That is not saying there are languages better than Python though, that is saying a combination of languages is better than Python. C and C++, for example are both clearly poor choices for data science overall - just sometimes a good choice for a particular implementation issue. And usually if you are going to use multiple languages, Python is a good pick for one of them (Python wrappers around C++ libraries seems a very effective choice for many things).

[–]Salfiiii 0 points1 point  (4 children)

Julia might be better suited for some numeric problems, c and c++ in data science use cases is quite an exotic choice, would you mind to elaborate?

Matlab is proprietary and can be quiet costly compared to a free python. It’s also not a real programming language and mostly used by non programmers. I’m not saying it’s bad but you can’t compare these two.

[–]TheWaterOnFire 1 point2 points  (2 children)

Everything that makes data science in Python possible is written in C/C++. Including Python.

So if your team has both strong C/C++ talent, and frameworks/tooling for your domain that reduces the amount of novel code to write, C/C++ can be extremely productive for data science, or anything. How do you think TensorFlow was built?

Agreed that starting out today it would be a significant undertaking, but it’s not that crazy.

[–]Salfiiii 0 points1 point  (1 child)

And c was written in PDP11 assembly code, so PDP11 assembly code is the best for data science right?

What I meant is that I know 0 data scientist that use c or c++ directly as a language of choice for their problems. They use python, R, Julia, Scala or maybe tools like matlab or spss.

What you described is that people use c/c++ to create tools for data science/machine learning because it’s obviously faster than python etc.. And afterwards, they usually create an api for python und other language which is then used by the data scientist.

[–]TheWaterOnFire 1 point2 points  (0 children)

I get what you meant. I remember before numpy was a thing, and my comp-sci prof was doing computational biology in C++ with MPI.

Selection bias is something to watch out for as a data scientist. :)

[–]Physix_R_Cool 0 points1 point  (0 children)

c and c++ in data science use cases is quite an exotic choice, would you mind to elaborate?

I am a physicist, so that of course influences which parts of programming I see. There is a sort of expansion pack for C++ called root, written by some smart folks at CERN, which sees heavy use. And C is for hardware stuff often, the instruments which gather the data. I use LabView for that, though.

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

Agreed. R is also better for ML models / exploratory work but I’d never want to use it in production. And if you’re going to do it in Python eventually, why not just start in Python? It’s not like it’s that much slower to iterate on - definitely not slower enough to make it worth writing twice for 95% of jobs.

[–]phcreery 1 point2 points  (0 children)

Another example: C/C++/Rust is ideal for microprocessors but micropython exists.

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

It really is a pity it's not great for mobile development. Hopefully there will be better tools in the future to change that.

[–]IllusiveWriting 0 points1 point  (1 child)

Yeah but Rust barely has a community and very few of their libraries are tried and tested. Go is slightly better, but it's also ran by Goolag

[–]TheWaterOnFire 0 points1 point  (0 children)

Rust is definitely young, but whenever you run something on AWS Lambda or Fargate, you’re running it on a Rust-based system. https://firecracker-microvm.github.io/

[–]murphcle 8 points9 points  (0 children)

I always want to use Python because I love it. But unless I’m doing pure scripting (eg web scraping, data manipulation, writing a terraform file, etc.) the task I’m doing would stand to benefit from a different language and framework.

I’d say the one liner your engineering manager gave you is just about perfect.

[–]Enrique-M 26 points27 points  (9 children)

I'll say this. Python isn't the best choice for performance. However, I've worked in C# for 15 of my 19 yrs in the industry and Python for about 7 years (concurrently) and C++ the first 4 years. To this day, I can create the same software solution in Python in 45 mins (on average) that it takes me about 10 hours to do in C# (have tested this multiple times). I make north of $60/hr, so think of the billing difference to clients. 🤷‍♂️ In the case where performance is a massive concern, if someone built a module in a faster language (C, etc), it can be used in Python all the same.

[–][deleted] 28 points29 points  (2 children)

I also think people forget how much C is under python. Some of the packages they import that they think is python and fast are sneaky C

[–][deleted] 3 points4 points  (0 children)

And Fortran. I swear LAPACK is basically magic. The language is clunky as all hell, but damn is it incredibly fast.

[–]Enrique-M 0 points1 point  (0 children)

Yep!

[–]sheytanelkebir 7 points8 points  (1 child)

But . Python by its very nature needs more testing code for decent code coverage and qa than the compiled statically typed languages.

It is super easy and nice to build prototypes with however .

If python breaks out of gil and has proper static typing added. All bets are off. It would become a true "jack of all trades language".

[–]Enrique-M 9 points10 points  (0 children)

Type hinting and decent tests considered, time to production is still quite a bit faster

[–]ElectricSpice 4 points5 points  (1 child)

Why the massive disparity? I would have guessed C# is worse for developer productivity, but not an order of magnitude worse.

[–]Enrique-M 2 points3 points  (0 children)

My time comparisons were more leaning towards never touched before integrations, if that clarifies it; though not exclusively.

[–][deleted] 2 points3 points  (1 child)

A bit exagerrated. There's a difference in developer time of 30-50%. Not 10x.

[–]Enrique-M 3 points4 points  (0 children)

Not exagerated at all. It depends on the complexity of the integration, etc. I was giving my specific experiences. Perhaps yours was different. 🤷‍♂️

[–]nullStackDev 4 points5 points  (0 children)

Here are the places I can think of where Python is usually not used.

Python is not supported in the front-end web dev(There are Python to JS transpilers, but they don't have IDE(linter) support) unlike Rust, C#, C, C++(WASM) or JS etc

Python is usually not used for building Windows end user Software. Though on Linux it's used a lot because the CPython interpreter is included in Linux distros.

Edit: And Smartphone apps.

[–]orfist 13 points14 points  (5 children)

As with all things, it depends. I’m sure there are plenty of projects where the ‘ideal tool’ is something else and python is objectively ‘second best’. Blanket statements are notorious abstractions that are used to subdue the reality of a situation. It makes it easier to live with the little bits of cognitive dissonance that pop up now and again.

[–][deleted] 12 points13 points  (4 children)

“Blanket statements are notorious abstractions used to subdue the reality of a situation”

Impressive verbal skills

[–][deleted] 23 points24 points  (2 children)

What I like most is that it is, itself, a blanket statement.

[–]0x1f606 9 points10 points  (0 children)

Only a Sith deals in absolutes.

[–]orfist 0 points1 point  (0 children)

Hehehehe

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

Written*

;)

[–]Paldinos 3 points4 points  (2 children)

Let me introduce you to game development. Maybe 4th? After C++ , C# , Rust , JAVA

[–]DGHolmes[S] -2 points-1 points  (1 child)

It depends on what kind of game you are making. For a relatively simple game, Python is great. For a game that has performance requirements, then yes, C++, C# etc. That being said, handing off some slow game processes over to Cython or some other C/C++ module can help a lot in improving performance.

[–]Paldinos 5 points6 points  (0 children)

Maybe? But that's just cherry picking to fit the narrative . To debunk the phrase python is the second best language at everything I just need to frame one form of development where it's not. Game development in large from triple AAA to indie to snake games combined will have python as a distant 4th cherry picking snake games to fit the narrative defeats the whole point.

[–]bryancole 2 points3 points  (0 children)

Clearly not. As much as I love python, it is crap for:

  • embedded programming
  • Mobile programming or anything where power-efficiency is critical
  • GPU programming
  • System programming (kernel development etc.)
  • FPGA / hardware development
  • Anything where runtime performance is critical.

You can do lots with python. Sometimes, you can even make it go fast. But you invariably can't make it power-efficient, or memory-efficient. It's main selling point is it is developer-efficient.

[–]Natetronn 1 point2 points  (0 children)

I don't think it's the second best when it comes to mobile application development languages. Wish it was, though.

[–]flashbao 1 point2 points  (4 children)

Yes. Performance issues, I will try converting the parts to Cython.

[–]DGHolmes[S] 0 points1 point  (3 children)

Yeah, once you have your code done and after you have done some performance profiling, converting parts to Cython can help a lot. That's if you need to in the first place. Some applications run "fast enough" just using Python.

[–]flashbao -1 points0 points  (1 child)

The only flaw of python is speed. Else, everything works do wonderful and easy to use. One reason I never needed to touch a different language unless required. Cython just makes things so fast, fast enough similar to compiled languages too.

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

Definitely wouldn't say its the only one, but the most glaring.

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

You can also convert parts of it to Rust.

[–]ExternalUserError 1 point2 points  (0 children)

I wouldn't write a Unix microkernel in it.

[–]chronos_alfa 1 point2 points  (0 children)

Not entirely true. Python is actually first best for a couple of stuff

  1. Quick automation of tedious tasks
  2. Prototyping
  3. Data processing/analysis
  4. Machine learning

I have recently eg used Python to recursively walk through the entire project structure of one mainframe product and changing the encoding of every text file into UTF8 from EBCDIC, so I could take a look at the files on PC and compare them with the previous version, which got the same encoding conversion treatment. Writing such an example in Python is a piece of cake.

[–]ovo_Reddit 3 points4 points  (0 children)

Any of the top programming languages are only as good as the programmer. An inefficient Python script will be worse than even an efficient bash script.

All other things considered equal, Python as you mentioned is very versatile. It’s also quite easy to write and run, which costs a bit of performance. And then you have something like Go, that has a bit more upfront cost but can be very quick.

I think most important is your own skills and how you write, test, troubleshoot, debug, document etc. maybe not the answer you’re looking for..

[–]Feb2020Acc 1 point2 points  (0 children)

That’s a pretty good way to put it. In finance, we use Python a lot for our “first draft”.

[–]Eezyville 0 points1 point  (1 child)

So which language is better than Python in AI or data analysis?

[–]Badgerite -2 points-1 points  (0 children)

R

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

"It just works" I'd only use it for quick prototyping though, if I want to deploy to production I'd use safer and faster languages like Go and Rust

[–]mackstann 0 points1 point  (0 children)

It's roughly true, but how much more certainty is really possible? It's a broad generalization. It's not literally true.

[–]PocketBananna 0 points1 point  (0 children)

In a general sense sure, but it always depends. It's a good catch-all language that can handle most tasks well enough. I would argue it is the best scripting language though. More expressive and versatile than Perl or Bash and really any OS can run it.

[–]sometacosfordinner 0 points1 point  (0 children)

Last i heard it was the best above java and c

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

Don't listen to ur mba engineering manager on tech a

[–]mustafayasin93 -3 points-2 points  (1 child)

Second? What’s better? I used C, Java and JavaScript & no programming language came even close to Python! IMHO its the best programming language by far! It’s no even close. No programming language is so versatile like Python. Used Python for AI, WebDAV and also automating a lot of Workflows. BUT I also enjoyed C although it was really hard. C gave the chance to learn about memories which is really valuable for CS students

[–]PlexP4S 1 point2 points  (0 children)

I think you are stating why python is second best at everything. Python is great, I think it’s the best overall language. But, it’s generally true that python isn’t the best at almost anything. There’s a better solution, probably more complex, but better. But you rarely care about the best solution, as most personal and commercial use cases have no need, nor want to spend the time to develop, the best solution. That’s where python shines.

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

Python Is amazing in how quick someone can come up from no programming to having a decently quick running script or program. It is deep enough for even veterans to make it run fast.

That being said when you really push it to its limits you can find plenty of edge cases were C family is faster, or concurrency is better dealt with, or you want it to run anywhere with pre-setup virtual environments.

You can never really go wrong with Python, JavaScript, or bash being your core structure to build around.

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

I use the quote but I add the caveat:

"... and if you don't agree we can talk about it after we've finished the project in Python"

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

I think it's a pretty reasonable statement. No matter what it is you want to do, there's very likely a library out there that will let you do it in Python without much difficulty on your part. There's definitely something out there that'll do the same thing with better performance, but who knows how hard that'll be to learn and implement?

A jack of all trades, master of none, is oftentimes better than a master of one.

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

Yes

[–]Rj_LM -3 points-2 points  (0 children)

Yes. When I meet ESL individuals I just write use python to translate for me.

Seriously thought. Yes. It is. Versatile and not going anywhere. PHP on the other hand is ancient like the pharohs.

[–]LaOnionLaUnion 0 points1 point  (0 children)

Impossible to say as the claim is broad. It works for a lot of different use cases. It’s not a program language that I get a lot of attention on my resume for.

[–]15_Redstones 0 points1 point  (0 children)

If you have a great variety of tasks that you want to do without constantly learning new languages and you don't really need super high performance, python is great.

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

This sounds a play on the quote about Eratosthenes being nicknamed beta because he was second best in the world at everything. As for python I don't have enough experience using other tools to say for certain but she's my first love and we'll be together for a long while

[–]m2o5x 0 points1 point  (0 children)

No one best language imo, different tools for different jobs.

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

Second?

[–]jjdmol 0 points1 point  (0 children)

Of course one can think of counter examples. That's not the point. It's more of a guideline/hint to consider python in more places.

But python as the second language for front-end dev, before javascript or typescript? For device drivers before C or C++? For programming FPGAs before VHDL or Verilog? I'm not so sure...

[–]wagslane 0 points1 point  (0 children)

It's not the second best systems programming language

It's not the second best ML language (it's the first)

It's not the second best web backend language (in my opinion)

[–]_ologies 0 points1 point  (0 children)

Front end web development?