Live data from Hacker News

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

news.ycombinator.com

81–90 of 99 posts

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

#81

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…

Python is a kind of a new Fortran for this generation of scientists. (And Python makes things even easier, ofc, compared to Fortran.)

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

#82

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…

JRE/JDK is a rather simple thing to set up. Compared to the complexity in most other stacks Java is rather straightforward to setup and start building things with.

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

#83

Python's a lingua franca in AI/NN because it was already a dominant language in scientific computing. Its dominance in scientific computing grew steadily through the 1990s and 2000s, for a few reasons: 1) Python -- specifically CPython -- made it easy to wrap existing, thoroughly tested high performance libraries in Python APIs. So, you got easy access to things like GSL and BLAS and LAPACK, but you get to call numpy…

Extending the comment a little: I'm crediting CPython for the nice APIs, but really I should be crediting David Beazley's SWIG. That got the ball rolling on a lot of projects.

He gave a talk on this very question in the past week. I strongly recommend. See https://m.youtube.com/watch?v=4RSht_aV7AU

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

#84

NumPy, SciPy and the ecosystem around them. So much of what you do in ML involves matrix operations. People used to do this stuff in Matlab. Matlab is good at numerics but it's not a very good programming language, and doesn't have very good libraries outside of the numeric domain. The open source nature of NumPy and Python encouraged a big open source community that is hard to get going if you're building open sourc…

Matlab is an excellent language. With great packages, C/C++ interoperability, seamless GPU support, and JIT compilation. Arguably it w is easiet than python for this purpose.

But. It's commercial. And thus prohibitive to the hobbyists and enthusiasts who are ultimately reaponsible for this kind of network effect.

And while I have a lot of love for octave, without the slew of proprietary packages and functionality available to matlab, it is hard for it to compete in such an ecosystem, despite some nice courses out there that use it (notably Andrew Ng's ML course).

If more people contributed open source packages to octave I'm sure it would become as big a player as python.

(inb4 julia: yes, but julia has other problems)

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

#85
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…

>Ps. it would have been nice to have monkey patching when dealing with btoa and atob in JavaScript, since they have different function on NodeJS vs the browser.

The better solution is to encapsulate the class and override the methods. Monkey patching is terrible because the behavior of the function is changing at run time. If someone is not aware that you are monkey patching a function the only way for them to determine what is going on is to step through the code with a debugger.

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

#86
post #6

Because Python has NumPy, which implements vectorized math on arrays and matrices. Machine learning algorithms are implemented naturally and efficiently with those primitives. PyTorch, TensorFlow, and I think every other machine learning framework in Python all use NumPy. JavaScript, Ruby, and Perl either don't have this abstraction at all, or they have much weaker versions of it, and many fewer scientific libraries.…

> JavaScript, Ruby, and Perl either don't have this abstraction at all, or they have much weaker versions of it, and many fewer scientific libraries.

I don't know that Numo for Ruby is “much weaker” than NumPy. It looks like installation is rougher since it doesn't bundle dependencies, and its newer and thus there is less downstream ecosystem.

> JavaScript doesn't have operator overloading; I'm pretty sure Perl doesn't, but not sure about Ruby

Ruby and Perl both have operator overloading. (Perl has “use overload”, and in Ruby operators are defined via overridable methods.)

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

#87
>I bet there's some interesting history here.

ML / AI were derived from Data Science. So hence it was built up upon the same python foundation.

As to why Python on Data Science. One needs to be reminded most people doing Data Science, or any Matlab type of work do not considered themselves as programmers. They dont want to learn about 20 reason why functional programming, or objected oriented programming are better and 100s other best practice with 1000 tricks to write the same program.

Although I do wonder if Julia may have a chance to dethrone it in the next 10 years.

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

#88

NumPy, SciPy and the ecosystem around them. So much of what you do in ML involves matrix operations. People used to do this stuff in Matlab. Matlab is good at numerics but it's not a very good programming language, and doesn't have very good libraries outside of the numeric domain. The open source nature of NumPy and Python encouraged a big open source community that is hard to get going if you're building open sourc…

Matlab is an excellent language. With great packages, C/C++ interoperability, seamless GPU support, and JIT compilation. Arguably it w is easiet than python for this purpose. But. It's commercial. And thus prohibitive to the hobbyists and enthusiasts who are ultimately reaponsible for this kind of network effect. And while I have a lot of love for octave, without the slew of proprietary packages and functionality ava…

Regardless of whether Matlab is a good language, it is looked at as a one-trick pony. You would never instinctively reach for Matlab to write a quick web server or to scrape a third-party API. What Python brings is all of the math and data analysis code that was noted and everything else in the Python ecosystem. It is not just that you get the Numpy, Scipy, scikit, etc collection but you also get to add everything else Python is used for as a bonus. This leads to virtuous circles where the AI/ML code is made easy to apply to other domains, so it becomes more widely known within that domain and this in turn leads to more support for those same AI/ML libraries.

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

#89
post #23
post #6

Because Python has NumPy, which implements vectorized math on arrays and matrices. Machine learning algorithms are implemented naturally and efficiently with those primitives. PyTorch, TensorFlow, and I think every other machine learning framework in Python all use NumPy. JavaScript, Ruby, and Perl either don't have this abstraction at all, or they have much weaker versions of it, and many fewer scientific libraries.…

Ruby does have operator overloading. And it is kind of sad to me that Python is so much more popular than it, even though Ruby has a much cleaner object-oriented foundation. Not to speak of underscores...

Ruby is arguably more OOP than Python, but I'd claim that doesn't help much in the scientific programming / machine learning use case. It might even hurt a little.

This kind of code is naturally expressed in "functions and data" rather than "objects" (data being vectors, matrices, etc.).

And I say this as someone who uses objects in most of my code! (which is not scientific code)

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

#90

NumPy, SciPy and the ecosystem around them. So much of what you do in ML involves matrix operations. People used to do this stuff in Matlab. Matlab is good at numerics but it's not a very good programming language, and doesn't have very good libraries outside of the numeric domain. The open source nature of NumPy and Python encouraged a big open source community that is hard to get going if you're building open sourc…

Matlab is an excellent language. With great packages, C/C++ interoperability, seamless GPU support, and JIT compilation. Arguably it w is easiet than python for this purpose. But. It's commercial. And thus prohibitive to the hobbyists and enthusiasts who are ultimately reaponsible for this kind of network effect. And while I have a lot of love for octave, without the slew of proprietary packages and functionality ava…

MATLAB is fine and could have continued to be the dominant player. MathWorks the company is hot garbage and basically destroyed the ubiquity of MATLAB.

That's pretty much the alpha and omega. MATLAB had a 20 year head start on everybody and wasted it because everybody hated MathWorks so badly.

Post reply on HN