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
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.
GUI is painful because there are no libraries yet?
No libraries and no way to automatically make bindings to C libraries.
You have to hand-write the bindings.
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++.
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.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.
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.
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.
Congrats @0x4a61636f62, you just advanced to level 1!
CPython can be used as a library.
The python will be garbage collected, yes.
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.
Mojo also has much better GPU support than Zig does.
Yes, that's more important actually.
For big analysis jobs cudf (a cuda dataframe library) will run circles around even polars.
By the way, how does Mojo treat introspection and generic programming? Is it similar to Rust or Zig?
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.
I fully agree.
Do you think it will happen? I heard Chris Lattner is a contributor to Rust.
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.
Is it using LLVM or is that being built from ground up too?
If you're asking if the person who built LLVM is using LLVM for their new language, the answer is yes.
I just looked at one interview with Chris and he claimed he might be the biggest contributor to Rust π
That's from LLVM.
π
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.
Interesting
This is why
--release
is important. It asks LLVM to clean up Rust's colossal mess.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.
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".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.
Congrats @0x4a61636f62, you just advanced to level 2!
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.
That's very interesting. It must be a huge undertaking.
LLVM is probably the largest collaborative effort in compilers, by quite a bit.
It seems it is not possible to install Mojo on Arch Linux.
Let me check if I can do it with Docker or Flatpack
It should work with Magic.
Looks like @Ket is using Mojo with arch just fine , can maybe share advice
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
Congrats @Ket, you just advanced to level 7!
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
@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.
Well, actually the documentation only mentions Mac and Ubuntu is supported.
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).
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:
I did not have time to debug but I will try again tomorrow.try killing the process and doing
magic telemetry --disable
. Lots of issues with the telemetry servers getting blocked.magic telemtry --disable
starts a new process that does not terminate π
Sorry, I have to go for now.