Live data from Hacker News

Ask HN: How did Python become the lingua franca of ML/AI?

news.ycombinator.com

61–70 of 99 posts

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#61
post #49

Earlier quoted context omitted.

Monkey patching is a terrible practice outside of unit testing and can lead to extremely difficult to debug bugs. Also monkey patching isn't unique to python.

FWIW I tried looking a few up and standard library seemed hit-or-miss: JavaScript it didn't work: class testClass { constructor() { } callHoHe() { console.log('ho', 'he'); } } let hi = new testClass(); hi.callHoHe(); testClass.callHoHe = () => { console.log('haha'); } let heh = new testClass(); heh.callHoHe(); This ended up just printing 'ho', 'he' twice, For Java people didn't think it was possible: https://stackove…

In Scala it's possible, but only at object creation time.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#62
Pythons' USP was and still is its ability to provide a simple & intuitive "glue layer" over lower-level libraries. Most of the performance-critical functionality that Python relies on for ML is written in C/C++/Fortran and Python mostly provides the UI layer (this is an oversimplification of course).

Wrapper generators and compiler tools like Cython and before that SWIG made it very easy to glue existing functionality to Python, so together with Pythons' great usability and user-friendly language it created a killer combination for productive data science & ML.

That said other languages could've pulled this off as well, Ruby for example. Python had more early traction in the scientific and high-performance computing communities though whereas Ruby was more popular in web development (due to Rails), which ultimately gave Python the edge and attracted more and more toolmakers to its ecosystem, which in turn spurred further growth. Great "IDEs" like the iPython/Juypter notebook were also a key factor in Pythons' success, as they provided a super user-friendly UI for data scientists.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#63
post #22

Another way to analyze the problem: what other language would it have been, given the moment ml hit? You say compared to other scripting languages'. Let's list them. Ruby: no numeric support Go: unnecessary typing, modest numeric support, shitty generics Bash: ha ha ha Scala, java, c, cpp: not a scripting language, complex Tcl, php: out of favor Rust: hadn't happened yet R: in memory bias, not as simple Other languag…

APL/array languages.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#64
I think there was a strong cohort of scientists using matlab, and python and numpy adopt the same language conventions. Going from matlab to python is effortless.

Moreover, scientists are typically so-so programmers so not having to worry about complexities like dereferencing pointers, specifying types etc, makes the language much easier to pick up.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#65
Because a lot of the early development in these areas was done by mathematicians and physicists who weren’t programmers (and who had less exposure to languages). These are folks who just wanted an answer to a question or a premise, and the elegance of the path that took them to the answer was utterly insignificant.

In some cases you might see a 3000 line python script with no defined functions… just loops and conditionals and lots of copy-pasted code with small variations in each section.

It’s really a shame, since there are so many more elegant languages which are equally or more powerful. But python is not a terrible language… it’s just an everyman get-shit-done language. We could be worse off.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#66
post #9

My last job was at an ML company. Most ML people there cannot build large robust systems and some struggled with the non-algorithmic bits of software. I am sure that some can out there in the world, but for the most part our ML people were very good at creating models and not very good at the development part, especially as the program grew (part of the motivation to hire devs like me in the first place). Python gets…

I don't think this is a fair assessment of "most ML people" Some of the biggest distributed systems built today are used for statistical inference or scientific computation Most "ML people" I know are highly versatile in software, networks and deep hardware knowledge, i.e., essentially they have a very good understanding of what a computer is and what is capable from Its very naive to think that you can assemble mach…

Most ml people (aka data scientists) I've met have little understanding of what a computer is, and it's fine. They understand stats.

The tiny subset of people who build ml systems (say tensorflow core devs, write actual distributed systems, etc) are actually hpc specialists, and have all the qualities you describe.

Of course, you may work somewhere where you're lucky enough to have everyone be good at everything!

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#67
post #13
post #9

Earlier quoted context omitted.

I don't think this is a fair assessment of "most ML people" Some of the biggest distributed systems built today are used for statistical inference or scientific computation Most "ML people" I know are highly versatile in software, networks and deep hardware knowledge, i.e., essentially they have a very good understanding of what a computer is and what is capable from Its very naive to think that you can assemble mach…

The most insane thing about Python is how you can override single methods in classes and use the class like normal. One time I was working on getting FIFO working on Windows, and none of the Python built-ins were set up to handle any random process writing to a named pipe that wasn't within the same Python instance. So what I did was I took the closest implementation Python offered, which was in the multiprocessing m…

Ruby has the same ability. Although it might be footgun if you(or dependency of dependency) modify or extend orignal class.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#68
post #22

Another way to analyze the problem: what other language would it have been, given the moment ml hit? You say compared to other scripting languages'. Let's list them. Ruby: no numeric support Go: unnecessary typing, modest numeric support, shitty generics Bash: ha ha ha Scala, java, c, cpp: not a scripting language, complex Tcl, php: out of favor Rust: hadn't happened yet R: in memory bias, not as simple Other languag…

R is definitely a good language for quant work. In some ways it could have been the natural choice, and there are still places where it's a better choice than Python. It's just far to fragmented, only really good for numeric work (and thus harder to integrate with production systems), and full of the weirdest gotchas. https://www.burns-stat.com/pages/Tutor/R_inferno.pdf

R has a few advantages over Python for data science work, but Python has a big one: it's also widely used by software engineers who are not data scientists.

I found it easy to jump from the software side of things to the data side of things because I already knew the quirks and tricks of Python. Having to learn a new language would have made this transition harder.

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#69
I suspect some of the popularity came from IT and engineering departments preferring to run Python compared to, say, Matlab, Excel, or some other GUI based application not designed to run on servers. R also has a lot of adoption but I think Python is a little more natural to run since so many infrastructure tools are written in Python

It also works fairly well cross platform. That means you can develop on Windows and run on Linux without too many issues (at least for ML/AI stuff, common frameworks usually have per platform binaries published)

i.e. Python is familiar to the people supporting production systems

Re: Ask HN: How did Python become the lingua franca of ML/AI?

#70
post #28
post #22

Another way to analyze the problem: what other language would it have been, given the moment ml hit? You say compared to other scripting languages'. Let's list them. Ruby: no numeric support Go: unnecessary typing, modest numeric support, shitty generics Bash: ha ha ha Scala, java, c, cpp: not a scripting language, complex Tcl, php: out of favor Rust: hadn't happened yet R: in memory bias, not as simple Other languag…

Non ML/AI coder here: Why does ML/AI work need to be written in a scripting language? Why can’t it be something like C++ etc instead?

Just one reason is that some Python libraries (numpy, tensorflow, pytorch) allow you to work with high dimensional arrays (3-4 dimensions) without for loops.

ML also needs reverse autodifferentiation, which would be a real pain in C++.

Post reply on HN