Mojo: Ownership and lifetime checks deep dive with Chris Lattner [video]
youtube.com
youtube.com
Any technological advancement that gets them more efficiency and leverage without the bottleneck of working with a software engineer would both empower scientists and free up software engineers for other problems.
It remains to be seen whether it will actually deliver on this potential. I think a lot has been promised before it's been proven. But I do think something like this is worth attempting and thoughtful work is being applied to the attempt.
I don't have the exact quote on hand, but in the Mojo Discord, Chris Latner explicitly said he wants no "compiler magic" in Mojo. With that idea in mind, Mojo makes it a lot easier to do optimizations like SIMD vectorization by hand, but you will still have to do it manually. My guess is that many scientists who don't like programming would find it annoying to hand-write those kinds of optimizations. If you want a language that gives you nice, performant code on your first attempt, Julia is always a decent option.
These are the docs for some of Mojo's higher order functions that implement vectorization, parallelization, tiling, loop switching, etc. https://docs.modular.com/mojo/stdlib/algorithm/functional
I do think they are a good idea and relatively easy to use; I'm just not convinced that the non-programmer scientist will like them.
If Julia hasn't taken off yet (which I am very sad about), I'm not sure why Mojo would. I'd rather have more resources invested into Julia.
Still an enormous uphill battle, but slightly more tractable. Regardless, it is a rough place to be - for a staggering number of uses, Python is fast enough. The organizations who absolutely require top tier performance already have the ability to use FFI. Instagram runs on Django and I believe is still used for YouTube.
Mojo has a good chance to target Python programmers who would have gone for Go or Java for better performance, and C++ programmers who need something like Rust, but simpler.
https://info.juliahub.com/case-studies
Any language designer would be crying of joy if their language had so few users as Julia is currently having.
Compiler magic means the implementation doing things that the application can't. It reflects limitations or constraints on the target language. If the language is expressive enough you can do everything through library code.
This would mean you're able to do simd vectorisation by hand, but you're also able to run a compile time transform that vectorises your code without needing to bind that transform into the implementation of the compiler.
Thus the non-programmer scientist can use libraries written by someone more on the boundary that do autovec etc, without needing to wait for the core mojo implementation to do it.
Of those languages I can say Mojo and Chapel were the most impressive. But Mojo is just so fun to write, I've ported a bunch of my "hobby numerical code" to Mojo. I am practically all in on Mojo since it'll give me access to MLIR.
I have always wondered though, why does Chapel get no love online???
As CERN alumni, and language nerd, I find Chapel quite cool.
In 2024 why should I be interested in a language that is not open source ? Perhaps I'm missing something ?
We'll be opening up more over time - stay tuned!
I was really really close to trying to spin up something at work using the Max Engine. However, I see that it collects telemetry [1], and we can't really allow that. Do you know if there are plans to be able to turn this entirely off at some point?
It's nice to know if I should keep it on my radar, or if I can't consider it without changing jobs :)
[1]: https://docs.modular.com/engine/faq#does-the-max-sdk-collect...
(Then comes Meta c.s. and everyone rightly distrusts anything reported back from their computer)
This just to say, that yes, the majority of companies cannot be trusted, but there’s still good guys out there collecting useful metrics completely devoid of secondary malicious purposes.
This is encouraging, and it seems that at least the core of the language is now open: https://github.com/modularml/mojo
I haven't tried it and I don't have a sense of how open Mojo really is today, or what's left that isn't open. I tend to agree that we should take the open source claim with skepticism until we see it in action.
The goals for the project are promising: something like the expressiveness of Python combined with the speed and safety of Rust. If they can pull it off, and it's open source, that will be very impressive.
Isn't that problem already solved? We already have Nim[0] that is memory-safe language with Python-esque syntax and performance of C. Yeah, it's not an extension of Python as Mojo claims to be; but I'd pick a mature language with proven design for my projects over something that's not even out yet.
[0]- http://nim-lang.org
The narrator (rather than Chris) shows that Mojo makes this fairly easy - we were never promising only to mutate the container, so if we replace it instead that's fine. And they (presumably correctly, I am not a Python expert) say that Python just can't do this.
But they also claim Rust can't do it either, and propose a fairly serious surgery to adjust the function signature instead to write a function which takes and returns ownership.
But you don't need to do that in Rust. We have a mutable reference, Rust doesn't mind us changing what it refers to, it's mutable after all, we just can't move it because it's not ours to move. This is where core::mem::swap, core::mem::take and core::mem::replace enter the picture, they allow us to easily use this capability.
For the example they're explaining you can just core::mem::replace(v, vec![8, 8]); and you're done, the signature doesn't change at all.
Why does AI and heterogeneous compute need ownership and lifetime checks again?
These are really needed for low level pointer heavy code.