News for hackers. Stuff that matters.
Re:Building a faster, smarter, Chromebook experience with th... by RadiozRadioz on Wednesday June 12, 2024 @03:46PM (#40662200)
Semi-related question: Why did the ML people choose Python and make it so intertwined with ML? It seems like a bad choice because it's slow and bad at integrating with hardware, the actual hardcore ML stuff gets offloaded to C, which creates a weird system with two languages and a weird build step to achieve one thing. If I knew nothing about the ecosystem of available libraries and was asked to pick a language to use for ML, Python would be fairly low down the list.

Is it just because it's easy, somebody picked it a while ago, made something influential, and now everybody uses it because everybody uses it?

Re:Building a faster, smarter, Chromebook experience with th... by mlinsey on Wednesday June 12, 2024 @04:14PM (#40662559)
Because modern ML is a descendant of data science/stats work being done in systems like MATLAB and R. Numpy and scipy were great libraries, and Python was a high-level language that statisticians could use, but also a reasonable enough choice to code a backend for a service in. If the field descended from systems programmers doing high-performance computing, a different language choice would probably have been made, but prior to deep learning becoming popular, compute was not nearly an obvious blocker to improved model performance.
Re:Building a faster, smarter, Chromebook experience with th... by buildbot on Wednesday June 12, 2024 @03:50PM (#40662268)
IMO, it makes more sense to think about Python or another high level language as glue code for all these C/Rust/Cuda/OpenCL kernels. Why would you choose something like Rust to also write the glue code in? Most people will be slowed down quite a bit by the language overhead, and the people writing this code need results last month.
Re:Building a faster, smarter, Chromebook experience with th... by hot_gril on Wednesday June 12, 2024 @04:14PM (#40662550)
I can't think of any alternatives. NodeJS would be sorta viable, but event loop doesn't mix well with this kind of workload, which is a moot point anyway because Python and all the killer libs like Numpy predate NodeJS.
Re:Building a faster, smarter, Chromebook experience with th... by logicchains on Wednesday June 12, 2024 @03:52PM (#40662296)
Python is a great language for ML because it allows gluing stuff together quickly. Using a 100% statically compiled language would slow things down, and the typing wouldn't help much because most languages can't properly type check tensor operations, and ones that can (like C++) tend to have awful compile times. The state of the art is tracing the execution and compiling it to a ML-specialised compiler (XLA for Jax, torch.compile for Torch), which is much harder or impossible to do in a compiled language.
Re:Building a faster, smarter, Chromebook experience with th... by csours on Wednesday June 12, 2024 @03:54PM (#40662316)
Worse is better.

Also, python is just the glue, the work happens in libraries.

Re:Building a faster, smarter, Chromebook experience with th... by wiseowise on Wednesday June 12, 2024 @04:01PM (#40662403)
What would you pick?
Re:Building a faster, smarter, Chromebook experience with th... by RadiozRadioz on Wednesday June 12, 2024 @04:14PM (#40662555)
Probably one of the math ones like Julia. Or something closer to hardware, like C++ or Rust
Re:Building a faster, smarter, Chromebook experience with th... by hot_gril on Wednesday June 12, 2024 @04:17PM (#40662596)
Julia doesn't have broad adoption because it's too specific, and C++/Rust are more cumbersome, also Python for data science and ML was popular before Rust or Julia even existed. Python's biggest advantage is that it's good enough for general usage while also being convenient for data science.
Re:Building a faster, smarter, Chromebook experience with th... by pjmlp on Wednesday June 12, 2024 @04:53PM (#40662988)
Julia has more adoption than many wannabe languages.

https://info.juliahub.com/case-studies

Re:Building a faster, smarter, Chromebook experience with th... by hot_gril on Wednesday June 12, 2024 @05:03PM (#40663098)
Sure, but not more adoption than Python. All the examples look math-focused; would you write a web backend or a batch script in Julia?
Re:Building a faster, smarter, Chromebook experience with th... by pjmlp on Thursday June 13, 2024 @01:04AM (#40666144)
No, that wasn't why it was designed for in first place anyway.

Likewise I wouldn't use Python for anything besides teaching programming, or scripting OS tasks and native libraries.

Re:Building a faster, smarter, Chromebook experience with th... by hot_gril on Thursday June 13, 2024 @12:21PM (#40671583)
Well that's the problem. Part of why Python is nice for ML stuff is because it was adopted for several other purposes too. I've never used Julia but have used niche things like Erlang, and there's always more friction that way.
Re:Building a faster, smarter, Chromebook experience with th... by 0xdeadbeefbabe on Wednesday June 12, 2024 @04:58PM (#40663036)
Tcl
Re:Building a faster, smarter, Chromebook experience with th... by alaties on Wednesday June 12, 2024 @04:52PM (#40662976)
I went to college starting 2007 (right when CUDA was released) and recall a few things about python that made it attractive in both the comp sci and math departments at my school.

  - python integrated well with lesson plans instructors had
  - python integrated well with the software math departments were using (like MATLAB)
  - python had a very easy to use interpreter environment that worked well on linux, mac, and windows
  - python had (for the era) a massive standard library, making it way easier to consume and process 
    common data file formats like XML or CSV without having to install any extensions 
    (installing extensions usually required admin permissions and... very few at school had those for very good reasons)
  - exposing c/fortran libraries into python was pretty straightforward to do and was relatively stable compared to alternatives.
Around 2007, the main competitors in the scripting space had a lot of issues:

  - tcl - somewhat popular for embedding but didn't really have a standalone interpreter that made it easy to interact
    with and the syntax didn't really look like C, and really not much of a library to work with

  - lua - similar to tcl, popular for embedding but didn't have a popular standalone runtime and interpreter.
    syntax was closer to C though. didn't have much of a library to work with

  - ruby - had a runtime for experimenting but a less stable API for integrating, plus the language was pretty
    different from C. the library was large but had a larger reliance on installing extensions than python at the time.

  - perl - both unstable and had a horrible reputation by this point as a standalone language that outside of some obtuse
    systems scripting, most people didn't want to touch this with a 12-foot pole. standard library was small and relied a lot on extensions.

  - php - similarly unstable (at the time... i think 5.3 had just come out) and had a horrible reputation... also not even
    sure it had a runtime that worked outside of an apache/nginx context... exposing a c library to PHP at this time was pretty
    straightforward though. relied very heavily on extensions at this point.

  - javascript - node.js hadn't come out at this point... so the idea of running javascript outside of a browser window wasn't really a thing yet.
If one were looking to expose CUDA to programmers who didn't want to work in C during this era, I'd argue that python was just the best option at the time.

I believe that led to a first-mover advantage that has held over time.

Re:Building a faster, smarter, Chromebook experience with th... by hot_gril on Wednesday June 12, 2024 @05:20PM (#40663240)
The usability without extensions part is underrated. Whether I'm a beginner in school or a pro trying to hammer out a quick script, I would prefer the thing that doesn't make me jump through hoops to deal with CSV JSON XML etc. Far more important than the language syntax or other things.

And the little scripts I write at work tend to grow and then turn into full-fledged services in a shorter period of time than it would've taken to set up the C++ or whatever boilerplate.

Re:Building a faster, smarter, Chromebook experience with th... by pklausler on Wednesday June 12, 2024 @07:47PM (#40664413)
scheme/guile?
Re:Building a faster, smarter, Chromebook experience with th... by bitwize on Wednesday June 12, 2024 @11:03PM (#40665503)
Didn't have a popular standalone interpreter. Also unstable.

Well, it's as true of Guile as it is of Tcl and Perl...

Re:Building a faster, smarter, Chromebook experience with th... by RadiozRadioz on Wednesday June 12, 2024 @06:06PM (#40663737)
> Perl [...] unstable

Huh? Please elaborate. The backwards compatibility is excellent. The core has been rock solid since the 90s. Especially compared to Py -2-to-3- thon.

Re:Building a faster, smarter, Chromebook experience with th... by mkl on Thursday June 13, 2024 @12:55AM (#40666090)
In 2007 Perl (to outsiders at least) seemed deep in Perl 6's "redesign and rewrite everything" phase, with no end in sight and no predictable future.
Re:Building a faster, smarter, Chromebook experience with th... by anthk on Thursday June 13, 2024 @04:52AM (#40667377)
Perl6 is no Perl it has been renamed to Raku. The rest of the Perl5 environment it's ultra-compatible with previous releases. Albeit compiling PDL it's rough case.

You look like never touched Perl seriously, Raku it's still a hard deviation.

No one used Perl6 on real life environments. It's the Duke Nukem Forever of the programming languages.

Using Perl6 as an argument on Perl5 it's like bashing the simple and clean ANSI C giving C++ as the example and its the crazy redundant features as a rant.

Re:Building a faster, smarter, Chromebook experience with th... by mkl on Thursday June 13, 2024 @05:53AM (#40667706)
Read the first two words of my comment again.

We're talking about the choice of Python for ML when CUDA came along, nearly 20 years ago. Upthread, alaties said:

> Around 2007, the main competitors in the scripting space had a lot of issues: [...]

> Perl [...] unstable

RadiozRadios replied:

> Huh? Please elaborate.

I did.

In 2007, Perl 6 was not Raku, it was intended to be the next major version of Perl. But it had been in development for ~7 years already, couldn't be relied on or predicted, and had become a bit of a joke. Since Perl 6 was still supposed to be the future of Perl, in 2007 Perl very much seemed unstable and unsuitable as a foundation for ML research.

Re:Building a faster, smarter, Chromebook experience with th... by anthk on Thursday June 13, 2024 @07:22AM (#40668238)
I agree on Perl's choice. But Perl5 was granted as an stable platform, kinda like AWK, pretty much unlike Perl6, which wasn't the future of the current Perl5 at all, except for the hype.
Re:Building a faster, smarter, Chromebook experience with th... by estebank on Thursday June 13, 2024 @11:45AM (#40671070)
Remember Perl 6?
Re:Building a faster, smarter, Chromebook experience with th... by bitwize on Wednesday June 12, 2024 @11:06PM (#40665520)
It's largely because Python had excellent numeric libraries, like NumPy and SciPy. You could script Fortran linear-algebra kernels to crunch your numbers fast in a high-level language, and that's a killer app in the ML space.