Live data from Hacker News

Mojo – a new programming language for AI developers

modular.com

31–40 of 272 posts

Re: Mojo – a new programming language for AI developers

#31
post #5

Seems like it could be interesting ... Initial impression is that the animation of Mojo code vs. Python code has a bad UX. Why not just show the code side-by-side instead of animating it and making me click? Another obvious question is how is it different than Numba and so forth? https://docs.modular.com/mojo/why-mojo.html The Mojo language has lofty goals - we want full compatibility with the Python ecosystem, we wo…

> A major goal of Clang was to be a “compatible replacement” for GCC, MSVC and other existing compilers. It is hard to make a direct comparison, but the complexity of the Clang problem appears to be an order of magnitude bigger than implementing a compatible replacement for Python. The journey there gives good confidence we can do this right for the Python community

Is it though? For Mojo to be a compatible replacement for Python, it would need to match the Python C ABI and the greater set of the standard library in a bug-for-bug compatible way.

The real question is whether it's bug-for-bug compatible or whether it's not. Numerical functions have a lot of nuances that effect that performance quite a bit. Are they constrained so that Python numpy log(x) gives the same as Mojo log(x)? Will C bindings act the same way as in CPython? Whole list of related questions. If there is a no to any of these questions, then code acts subtly differently in a way that is sometimes hard to detect. These differences are of course what have held back "standard code" from being numba/pypy/etc. compatible in many instances.

That said, if the answer isn't yes to anything, then it is very difficult to make optimizations. Not allowing hard to optimize Python behavior is precisely what has allowed Numba, Julia, etc. to achieve accelerations. There were some attempts at that kind of thing with R, which Jan Vitek gives some very interesting talks about (https://www.youtube.com/watch?v=VdD0nHbcyk4).

What I would find worrisome too is that this approach sounds like compile time city. A lot of the recent advancements in Julia have been by sending less to LLVM: optimizations are done in Julia and dead code is eliminated, calls are found to be the same and check caches, and then with v1.9 those caches use precompiled binaries to avoid having to call LLVM again. And the timeline of improvements shows that making LLVM be in the picture as little as possible has lead to some dramatic improvements in Julia's latency (https://viralinstruction.com/posts/latency/). Given what was seen from that, I'm weary of an approach that does everything in LLVM (via MLIR) on an even more dynamic representation (i.e. Python). My guess is that only things with explicit types will compile, and the rest is probably hitting some Python interpreter to avoid this issue.

[If part is using Python/GC through an interpreter though, wouldn't that part be harder to target to accelerators since it wouldn't compile through LLVM? That would mean only the code that is explicitly typed gets the nice new features, but not the Python parts?]

But hey, if this gets Chris Lattner and crew a reason to start taking LLVM compile times more seriously, then it's a win for Julia as well. I'm excited to see how the communities can benefit from one another, especially if Mojo is open source then it can be a win for all (which was definitely not clear in the presentation). And I do think that some of the ideas of lower level memory control are cool and should be added similarly to languages like Julia and Numba.

Re: Mojo – a new programming language for AI developers

#34
post #18

So is this actually Python or not? I’m a bit confused.

It's a superset of Python. What you call "Python" is actually CPython, a C implementation of the Python language. Many other Python implementations exist, though they typically don't support all packages well (for example lack of support of native Python extensions like what Numpy relies on). It looks like Mojo has its own runtime (so not CPython) but also packages CPython for compatibility?

Re: Mojo – a new programming language for AI developers

#35

There are a bunch of questions about Julia, so I'll do my best to give a short answer to a very long and complicated topic. Up front, Julia is a wonderful language and a wonderful community, I am a super fan. That said, Mojo is a completely different thing. It is aligned with the Python community to solve specific problems outlined here: https://docs.modular.com/mojo/why-mojo.html Mojo also has a bunch of technical a…

I notice that Mojo still seems to use numpy or something that looks "numpyish" for compatibility. Will Mojo also have an alternative syntax for doing things like matrix multiplication that looks more native like Julia's?

Mojo fully supports arbitrary library designed types, check out the note books for examples that define custom matrix operations of various types.

Re: Mojo – a new programming language for AI developers

#36
post #8

This looks quite interesting with big names behind it. I'd love to see a comparison vs Julia though, which I think tried to tackle some of the same problems.

It is a little disappointing that they're setting the bar against vanilla Python in their comparisons. While I'm sure they have put massive engineering effort into their ML compiler, the demos they showed of matmul are not that impressive in an absolute sense; with the analogous Julia code, making use of [LoopVectorization.jl]( https://github.com/JuliaSIMD/LoopVectorization.jl ) to automatically choose good defaults…

Yeah I think no one will likely have any edge for a simple thing like a matrix multiplication since all the right abstractions are supported in both languages and they end up in the LLVM code gen. Having Python 3 backwards compatibility and easily deploying your code to, say, phones via a C++ API is quite big though.

Re: Mojo – a new programming language for AI developers

#39
post #5

Seems like it could be interesting ... Initial impression is that the animation of Mojo code vs. Python code has a bad UX. Why not just show the code side-by-side instead of animating it and making me click? Another obvious question is how is it different than Numba and so forth? https://docs.modular.com/mojo/why-mojo.html The Mojo language has lofty goals - we want full compatibility with the Python ecosystem, we wo…

> A major goal of Clang was to be a “compatible replacement” for GCC, MSVC and other existing compilers. It is hard to make a direct comparison, but the complexity of the Clang problem appears to be an order of magnitude bigger than implementing a compatible replacement for Python. The journey there gives good confidence we can do this right for the Python community Is it though? For Mojo to be a compatible replaceme…

Thanks for your interest, I'm pretty confident we can do this. I've been working on compilers and languages for awhile. :)

Your point about LLVM compile time is great one. Mojo is architected from the beginning for fast compile times, including deeply integrated caching and distributed compilation. LLVM "isn't slow" if you don't keep asking it to do the same thing over and over again.

-Chris

Post reply on HN