Mojo for Building Applications or mostly Data Science?

Is Mojo suitable for building desktop apps with a GUI or is it first and foremost made for data science work? How should one think of Mojo compared to Rust and Zig? Can I do everything I can in Mojo in Rust and Zig? I am considering using Mojo to build an app with GUI for data scientists. Would it be a suitable choice?
45 Replies
Darkmatter
Darkmatterβ€’4d ago
Mojo is a fully capable systems language, the same as Rust and Zig, but it is one early in its life. Some of the niceties of Rust are missing, and the easy C interop of Zig is also missing. GUI is going to be very painful right now. The easiest way to do it would be to make a locally hosted web app.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
GUI is painful because there are no libraries yet?
Darkmatter
Darkmatterβ€’4d ago
No libraries and no way to automatically make bindings to C libraries. You have to hand-write the bindings.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
It sounds like a promising language. The reason I was considering it is another assumption I make that I should ask about: Does it have nice integration with Python? E.g., if a data scientist uses my application and wants to add Python code, and I want to integrate that Python code in my running application. Is that an advantage of Mojo, or is Mojo completely new language without any technical relationship with Python (only syntax looks the same)? Bascially, my app is going to be a bit like Unity Game Engine but for data scientists, wherein Unity, developers write code in C# while Unity itself is written in C++.
Darkmatter
Darkmatterβ€’4d ago
Mojo can use python libraries, but right now there isn't a great way to call Mojo from Python. So, the main function needs to be Mojo.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
I think it will get there eventually, and the GUI will be the last thing I do anyways, so hopefully within a year or so there will be GUI libraries for Mojo.
Darkmatter
Darkmatterβ€’4d ago
And the way it uses them is much closer to how you would use a python lib from C++ or Rust. You are staring at the underside of CPython.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
I think that's okay for my use case. How will the Python code be executed during runtime? I suppose it will still be garbage collected? I mean if I import a Python library and want to run it in Mojo.
ModularBot
ModularBotβ€’4d ago
Congrats @0x4a61636f62, you just advanced to level 1!
Darkmatter
Darkmatterβ€’4d ago
CPython can be used as a library. The python will be garbage collected, yes.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
Got it! I wonder if Zig, with its C interoperability, has the same ability to use CPython. In that case, it might not matter for my use case since users will never see the implementation anyway, just like with Unity Game Engine. But I imagine that Mojo gives Python developers that use my application the ability to learn and write Mojo too, which might be useful. So they can choose to write libraries in Python or Mojo.
Darkmatter
Darkmatterβ€’4d ago
Mojo also has much better GPU support than Zig does.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
Yes, that's more important actually.
Darkmatter
Darkmatterβ€’4d ago
For big analysis jobs cudf (a cuda dataframe library) will run circles around even polars.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
By the way, how does Mojo treat introspection and generic programming? Is it similar to Rust or Zig?
Darkmatter
Darkmatterβ€’4d ago
Full support for const generics, better than what Rust has. It's much more rust-sided, but I've been advocating taking Zig's comptime as inspiration for the eventual reflection API. Zig has a fantastic reflection API, but sometimes you just want to be generic over a List of T.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
I fully agree. Do you think it will happen? I heard Chris Lattner is a contributor to Rust.
Darkmatter
Darkmatterβ€’4d ago
I think if it's at all doable in the compiler it will happen. I'm not sure if Chris contributed to Rust, but Swift inspired Rust and he did work on that.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
Is it using LLVM or is that being built from ground up too?
Darkmatter
Darkmatterβ€’4d ago
If you're asking if the person who built LLVM is using LLVM for their new language, the answer is yes.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
I just looked at one interview with Chris and he claimed he might be the biggest contributor to Rust πŸ™‚
Darkmatter
Darkmatterβ€’4d ago
That's from LLVM.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
πŸ™‚
Darkmatter
Darkmatterβ€’4d ago
Most of Rust's performance can be attributed to torturing LLVM. It essentially provides all of the information it can, which is far more than C++ can even with very carefully written code.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
Interesting
Darkmatter
Darkmatterβ€’4d ago
This is why --release is important. It asks LLVM to clean up Rust's colossal mess.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
I heard Zig is working on ditching LLVM, but I am not sure. I wonder how that is even possible. Haha, thanks for sharing that. I had no idea that Rust had such an impact on LLVM. I guess it makes sense since it is the most influential language recently since LLVM was originally created. It also explains why Chris Lattner is a big contributor to Rust, as you said.
Darkmatter
Darkmatterβ€’4d ago
Rust has forced LLVM to fix a lot of optimizations that didn't actually work properly, because things like noalias it went from 10-20 uses per program to "every single reference".
0x4a61636f62
0x4a61636f62OPβ€’4d ago
This makes me even more curious why Zig might want to move away from LLVM given there are so much resources going into improving it.
ModularBot
ModularBotβ€’4d ago
Congrats @0x4a61636f62, you just advanced to level 2!
Darkmatter
Darkmatterβ€’4d ago
Zig needs to compile very, very quickly because the Zig generic model is basically impossible to do LSP things with. Outside of running the compiler. That, and LLVM has a lot of C++-isms in it. And lots of stuff is "whatever the C++ standard says to do", which is chained to C++'s legacy.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
That's very interesting. It must be a huge undertaking.
Darkmatter
Darkmatterβ€’4d ago
LLVM is probably the largest collaborative effort in compilers, by quite a bit.
0x4a61636f62
0x4a61636f62OPβ€’4d ago
It seems it is not possible to install Mojo on Arch Linux. Let me check if I can do it with Docker or Flatpack
Darkmatter
Darkmatterβ€’4d ago
It should work with Magic.
a2svior
a2sviorβ€’4d ago
Looks like @Ket is using Mojo with arch just fine , can maybe share advice
Ket
Ketβ€’3d ago
Flatpak is for gui apps. Unsure if there is a docker container Can you please describe the issue? Make sure you pipe the install script into the bash shell And your locales may be misconfigured @0x4a61636f62 Pls send the error. Make sure to ping me Checked the chat, can't find the issue mentioned by you
ModularBot
ModularBotβ€’3d ago
Congrats @Ket, you just advanced to level 7!
Ket
Ketβ€’3d ago
It's a turing-complete language that can make external calls You can make it use a c library for graphics. If you are feeling spicy, try opengl stuff in mojo, would be a huge amount of work, but a big contribution
0x4a61636f62
0x4a61636f62OPβ€’19h ago
@Ket I tried to find a package on the Arch repos for Mojo and then stumbled upon https://github.com/Sharktheone/arch-mojo. There, they say that the version of ncurses on Arch Linux does not work with Mojo. At that point, I asked if Mojo does not run on Arch. But you seem to have it running so I should try and try to install it manually. I'll let you know how it goes in a bit.
GitHub
GitHub - Sharktheone/arch-mojo: Install Mojo on Arch
Install Mojo on Arch. Contribute to Sharktheone/arch-mojo development by creating an account on GitHub.
0x4a61636f62
0x4a61636f62OPβ€’19h ago
Well, actually the documentation only mentions Mac and Ubuntu is supported.
Darkmatter
Darkmatterβ€’19h ago
Magic sets up a conda environment with the required packages. Magic means general support for Linux, since it’s a virtual environment with its own packages (think a docker container minus docker).
0x4a61636f62
0x4a61636f62OPβ€’18h ago
Thank you @Owen Hilyard. Let me give Magic a try now. Installing Magic worked, but when I run magic init life --format mojoproject, it starts a process that does not terminate:
┏─────┬────────┬────────┬───────────────────────────────────────┬────────────┬────────┬──────────┬──────────┓
β”‚ # β”‚ pid β”‚ ppid β”‚ name β”‚ status β”‚ cpu β”‚ mem β”‚ virtual β”‚
β”‚ 372 β”‚ 689871 β”‚ 655651 β”‚ magic β”‚ Running β”‚ 103.45 β”‚ 12.5 MB β”‚ 71.9 MB β”‚
┗─────┴────────┴────────┴───────────────────────────────────────┴────────────┴────────┴──────────┴──────────┛
┏─────┬────────┬────────┬───────────────────────────────────────┬────────────┬────────┬──────────┬──────────┓
β”‚ # β”‚ pid β”‚ ppid β”‚ name β”‚ status β”‚ cpu β”‚ mem β”‚ virtual β”‚
β”‚ 372 β”‚ 689871 β”‚ 655651 β”‚ magic β”‚ Running β”‚ 103.45 β”‚ 12.5 MB β”‚ 71.9 MB β”‚
┗─────┴────────┴────────┴───────────────────────────────────────┴────────────┴────────┴──────────┴──────────┛
I did not have time to debug but I will try again tomorrow.
Darkmatter
Darkmatterβ€’18h ago
try killing the process and doing magic telemetry --disable. Lots of issues with the telemetry servers getting blocked.
0x4a61636f62
0x4a61636f62OPβ€’18h ago
magic telemtry --disable starts a new process that does not terminate πŸ˜„ Sorry, I have to go for now.

Did you find this page helpful?