Mojo is a much better “Objective-C without the C” than Swift ever was
blog.metaobject.com
blog.metaobject.com
Anyway, never gonna try it, unless I'm absolutely forced. I hate their marketing strategy, it sounds too bad.
My access was approved within one hour.
It's really minor thing but a pet peeve of mine, I remember how twenty years ago every new language claimed to be as fast or faster than C, and every time the benchmark was some ultra-optimized non-idiomatic program in that new language against a naive C implementation, and the C version was usually still 20% faster and use 10% as much RAM with the right compile flags.
Are there even Mojo benchmark in the wild? The FAQ entry[1] just finds excuses for situations where it does not perform well...
I would say "faster than C if you want to keep your sanity and don't have infinite time". It doesn't roll off the tongue though :P
- Run on GPU
- Automatic loop parallelisation
- Microbenchmarks where C is slow due to pointer aliasing (this is why Ocaml is faster than C)
[1] https://www.modular.com/blog/the-worlds-fastest-unified-matr...
I kind of agree with the obnoxiousness of the marketing, but it pays to actually read a little of what they do before jumping to conclusions.
If only because its Chris Lattner behind it, obviously not someone who is your average "modern programmer".
It's impossible to say for sure, since you can't run the benchmark on your machine and god knows what's behind the playground. However, I compared my naive implementation to find min of a rolling mean using python with numba, pandas, polars, numpy and mojo version.
Mojo version was faster than polars and numpy, which in turn were faster than pandas and numba. That's my N=1 of course, and not a reliable benchmark. But still, I find it very impressive.
When making technical claims to a technical audience, and vs Lattner leveraging reputation,
the appropriate approach is clearly not this. It's to lead with conservatively stated claims, reproducible results, and all the rest of the apparatus that is collectively understood as how adults (from which I exclude bizdev) demonstrate a better mousetrap, into an environment within which the cost of switching mousetrap technology is very great indeed at every level.
Big asks deserve and require better.
They are VC funded and this is the pitch to the VCs in order to get money.
Obviously this is not convincing on a technical level yet. But it's also really interesting as a design.
And while the code isn't open source, I for one find it pretty fascinating to see the language being iterated on in public like this.
Edit: E.g. https://github.com/modularml/mojo/blob/main/proposals/lifeti...
or
https://github.com/modularml/mojo/blob/main/proposals/value-...
In my experience the new generation of devs haven't touched C and treat it like some kind of weird arcane language, a bit like what Fortran and COBOL were when I started coding around 2000.
I doubt their potential users would care so much, as long as it's significantly faster than Python and they don't need C or C++, except as an option and not as a necessity. That's been the point of various other alternative languages.
The claim to fame of various newer compiled languages, is not just being as fast as C, but that they are better alternatives to use, for their audiences. Being easier to use, read, or/and learn. This is where some of the drama comes from, because some will make it about speed, and ignore the other elements of what is "attractive".
[1] https://en.wikipedia.org/wiki/History_of_programming_languag...
This is a self-fulfilling prophesy.
"Please don't comment about the voting on comments. It never does any good, and it makes boring reading." https://news.ycombinator.com/newsguidelines.html
For performance, if the compiler backend performs enough optimization, the code is run natively without any VM, the performance can be same or better than C (as some language features may provide more optimization opportunities). At the end of the day, C programs are compiled into some IR code and optimized by the backend as well, so the frontend language is more about balancing limitation for optimization and expressiveness.
I do feel a bit uncomfortable about their marketing strategy, which compares a simple implementation against one with SIMD and parallelization... I think the real win here is simpler SIMD/parallel programming comparing with C/C++, instead of the language itself being faster.
"Faster than C" is a lot more plausible for Mojo than the claim of running arbitrary Python code eventually ;)
Indeed, I can see this from their emphasis on generic SIMD, which looks pretty nice. It is nice that there is now a language with first-class SIMD support, comparing with something implemented with a library or autovectorization which may not work.
> "Faster than C" is a lot more plausible for Mojo than the claim of running arbitrary Python code eventually ;)
Seems so. I don't recall reading the claim about running arbitrary Python code, and I think requiring rewriting Python code is reasonable as normal Python code may utilize runtime reflection/dynamic type and they are hard to implement efficiently, and probably require a GC for memory management.
The term superset of Python kind of implies this I think. Beyond the runtime reflection, Python also has eval.... :D
If the language is flexible enough (in particular, it has to support operator overloading), I don’t see any disadvantages to implementing that in a library.
See for example https://developer.apple.com/documentation/swift/simd
Except that it also claims to be a superset of Python. That is, you can use it to run any Python program without changes. So explain to me how it’s faster than C while also literally being Python. That’s more outrageous than V.
> what they've actually got at the moment is two languages glued together, where one of the languages will "unlock performance" and the other language is literally the CPython interpreter.
On the main page of the website, they claim it lets you "Write everything in one language" and "Unlock Python performance" – but what they've actually got at the moment is two languages glued together, where one of the languages will "unlock performance" and the other language is literally the CPython interpreter.
> Although not as outrageous as V...
Comes across as adding drama. Like arguing with one guy, then slapping another who wasn't involved, thinking it will be funny or because one might get away with it.
I know it was made for AI, but could it be a rival to rust/C++ in general? Seems like it could replace either of those.
Also, it is still WIP so I am not sure how things like type works in this language, whether or not it support parameterized lifetime, reference counted objects, union type, closure, etc. Currently, they seems to be focusing on numerical applications, targeting the AI crowd, so it is uncertain how things will go later.
This is very clearly explained on the website:
https://web.archive.org/web/20200629153446/https://vlang.io/
Can you point to that claim?
Here's 4 years ago:
https://web.archive.org/web/20190828170427/https://vlang.io/
> V manages memory at compilation time (like Rust). Right now only basic cases are handled. For others, manual memory management is required for now.
> V doesn't use garbage collection or reference counting. The compiler cleans everything up during compilation. If your V program compiles, it's guaranteed that it's going to be leak free.
This was later worded better. But I agree, the docs should have never had such wording.
People are also free to join the project or directly make helpful suggestions. That's part of the point of open-source.
(If I hear the randomly brought up, completely unrelated musk hype question again...)
He speaks slowly (listen on 2x for regular person speed) and he’s trite, but he interviews people and lets them talk.
That’s good enough. And it’s especially good enough in that he gets big names to come talk.
He doesn’t need to be a genius or to ask clever questions. Merely letting Chris Lattner geek out for 2 hours on audio about his project is a win.
His podcast is alright for people who aren't in any of the domains and therefore just want overviews. Anything else, and it's about as useful as listening to an actor repeat the summary for the movie they're promoting for the millionth time.
It's pretty clear he's playing up some kind of "rainman autistic AI savant" persona, and also, he exaggerates his credentials. On his website he describes himself as:
>AI researcher working on autonomous vehicles, human-robot interaction, and machine learning at MIT and beyond
Which could lead one to erroneously assume that he attended MIT, or even has a degree from MIT, when neither of which are true.
He had John Carmack on his show which piqued my interest, but he was asking questions like "what's the best programming language" and "what's the best IDE." Such a blown opportunity to be asking useless first year CS student questions like that when interviewing a great mind like Carmack.
It makes sense to get touchy-feely with Bert Kreischer, who’s basically an alcoholic gigantic third grader. Or with Michael Malice because they’re goofy best buds.
Still it’s nice when a serious guest kind of shrugs and sticks to the topic.
I can’t listen to Neil Degrasse Tyson talk because of that same kind of “the wonder of the poetry of the cosmic ballet” nonsense.
Fyi... CL said he likes being interviewed by Lex Fridman: https://news.ycombinator.com/item?id=24831157
So for your wish of someone else instead of Lex to be granted... (1) the hypothetical "more intelligent interviewer" you'd prefer has to ask CL to be interviewed -- and -- (2) in turn, CL has to say "yes" to the interviewer.
So far, Lex got (1) and (2) to happen. (Three times.) So here we are. Any suggestions on who else should interview CL and would CL grant the interview?
The More You Know...
[0] <https://lexfriedman.com/> [1] <https://en.wikipedia.org/wiki/Lex_Friedman> [2] <https://www.youtube.com/c/lexfriedman>
[3] <https://lexfridman.com/> [4] <https://en.wikipedia.org/wiki/Lex_Fridman> [5] <https://youtube.com/c/lexfridman>
https://www.crunchbase.com/organization/modular-ai
Andrew Kelley predicts the future:
I think their strategy makes quite a bit of sense. Superficially Python like, can use Python libraries, fast and safe like Rust, automatically determines where algorithms should run (to some extent).
One thing that comes to mind however, is library performance. I'm assuming it will be ~3X faster than Python (like basic Python code) but if you are coming from Rust or C, this could be an issue.
Lattner is an open source fan, I believe it will be open sourced eventually, but maybe the early Swift development was traumatizing. Just a guess.
(Actually IIRC I started learning it when they promised to open source it later that same year. So the actual moment of open-sourcing might have been slightly later.)
I meant when they actually opened the gates. My recollection is that they were overwhelmed by the feedback and community building.
> we expect that Mojo will be open-sourced. […] We don’t have an established plan for open-sourcing yet.
But I'm not trusting "don't be evil" tag lines anymore.
So we'll see when they actually make something open enough that we can entrust our programming stacks to it.
Also the team behind the project includes very smart people with a history of delivering other great projects (LLVM, Clang, MLIR and Swift).
I don't see how discouraging other people for trying to innovate is helpful. In the end this project could benefit all of us.
That's debatably where the trolling, misinformation, and other underhanded tactics come in. Maintaining the status quo and protecting one's interests, even to the detrimental of the whole, fairness, or the greater good.
I thought it was odd at first that they weren't letting me run it locally too, but if they control the compute environment then they can force push interpreter(?)/compiler updates and eliminate a lot of bug reports from folks that are just using an out of date build. Seems pretty reasonable to me for something that's so early in development.
There appears to be confusion here. Mojo is trying to align itself with and be a kind of superset of Python, like C++ was to C. It's also an alternative for Python users, to use it, instead of reaching for C++ or C when they need speed or going lower level. From their website, that's not what V devs ever claimed nor is it their angle for users. V is a different programming language (and compiled), which provides benefits such as greater speed, type safety, etc... in comparison to Python. It would be a switch over, not a superset.
V is more of an alternative to Go and then C (in terms of ease of use and greater safety). Mojo and V are mostly in different lanes, where they appeal to different audiences, and how they are marketing themselves has nothing to do with the other.
> Anyway, never gonna try it, unless I'm absolutely forced. I hate their marketing strategy, it sounds too bad
This comes across as weird, to claim one will never use or gives the impression to never have used the programming languages they are talking down on. If not using Mojo or V, why be so preoccupied? Just skip over to what one does like and not be worried.
> ...hate their marketing strategy
Just about all programming languages attempt to sell themselves to the public. If they don't, people don't hear about them, and they die in obscurity.
And a lot of times, people are allowing themselves to be brainwashed by what big corporations have to sell, because they have big budgets for marketing. People often like, what big companies told them to, because of their infomercials and marketing campaigns. Sometimes, it can be good or at least fair to give alternatives a shot.
On the front page of their website, they claim to have full compatibility with python code, an ownership model and a borrow checker, and being as fast or faster than C++. These are just some of the first things I noticed!
Apparently one of the people involved with the creation of this language have some credibility which is pretty confusing. They are the CEO of the company behind "mojo" as well.
I think this is going to be another V-lang situation personally, despite the credibility of Lattner. I think this is just someone seeing an opportunity to cash in on the "AI hype" situation that exists currently.
Even reputable people can be influenced to do shady things when lots of money is involved!
This is of course just my opinion and I wouldn't mind being proven wrong, but I'm definitely very skeptical right now!
Mojo is not only directed at AI, but at Python users as an alternative and superset. The use of it for AI, is partially based on the use case of Python. Insinuating that Mojo is trying to "cash in" on "AI hype", is odd in the context of all the others who clearly do so, but where is the "cash in" at? Mojo and Vlang are free.
Vlang (V-lang) has made no such marketing claims in regards to AI, so pairing the languages together comes across as odd. If the argument is about "cashing in", that looks even weirder. The users of both languages can get it for free. As with any programming language, there can be donations and sponsors. Why would it be a problem for Mojo or Vlang to have sponsors, but somehow not so for other competing languages, in regards to their claims? This comes across as at least one is fine with their favorite language getting sponsors or donations, but not others. Or maybe hoping to cut the funding sources of new languages, so there will be less competition.
> Even reputable people can be influenced to do shady things when lots of money is involved!
The accusation or insinuation is being made that Lattner is "shady" for money, while a backhand is being thrown at Vlang too. Outside of throwing smears, there is no proof of them being in it for hustling money or doing anything that different from what competing programming language creators have and are doing. And that's without talking about the corporate created languages, where obviously money and market share are major driving forces for them.
1) Will Mojo provide seamless interop with C like objective-c?
2) Will Mojo provide seamless interop with C++ like objective-c? All I have to do is changing file extension from '.m' to '.mm' and can use all C++ features
3) Will Mojo be available to be compiled for iOS and Android?
Swift doesn't have good interop with C but at least have decent interop with Objective-C (works most of the time but if you have some more complex code with Swift using Obj-C and Obj-C using Swift things can be nasty to figure out why it suddenly doesn't automagically work.
In upcomming iOS 17 Swift have some interop with C++ but haven't tested the details yet how smooth it is.
I would happily use Mojo if:
1) Can be compiled for iOS/Android
2) Has seamless interop with C/C++/Objective-C and maybe even Rust
That would be enough killer features for me
Dealbreaker for me with Python is not really good support for mobile apps even if you just want to use it for prototyping instead of production code. Most native pip modules are not supporting mobile architectures out of the box and don't have many wheels.
It compiles to llvm. This means the python environment headaches will disappear.
It might become that (personally I doubt it, but that's the stated goal). It isn't now. Not really close even. No kwargs, no python classes for example.
> It compiles to llvm. This means the python environment headaches will disappear.
Weeeeell. Not if you want to use any Python library. Because then it just calls into CPython. And that's a huge part of why Mojo is interesting in the first place. So I would say no.
Huh? Swift interop with C is basically painless (it has to be, because all C code is ObjC code, so without C interop there is no ObjC interop).
"without the C"... ;-)
And of course it's not really "seamless inter with C", because Objective-C just is C, or more specifically a superset of C. It's sort of "interop with yourself". Of course, most Objective-C programmers do treat C as a distinct language, and one that they won't touch. Which is interesting.
And you are right, the article wasn't really about whether it is a better language overall, particularly not from the grass root user perspective.
It was about the specific aspect of being an "Objective-C without the C".
Which, of course, is just Smalltalk when taken literally. But if you just use Smalltalk, you lose Objective-C's capability of going really fast as well (and the interop).
Of course using Python instead of Smalltalk as the base is sad, but it is understandable given the market that they're going for.
“Mojo […] doesn't repeat Objective-C's mistake of using the component language as the base (which, inexplicably, Swift didn't just repeat, but actually doubled down on by largely deprecating objects).”
What does “largely deprecating objects” mean, and why would it imply “using the component language as the base”?
and
“it turns out that the connection language is actually the more general one, the component language is a specialisation of the connection language.”
I don’t understand that at all. You have a “blue collar” layer where bytes and bits get shuffled around and hands get dirty and a “white collar” layer where programmers pretend the world is made of legos and there’s no need to get your hands dirty to write programs.
A language can decide to only support the white collar layer, but if so, you still need a blue collar one in your interpreter/compiler/runtime (or, potentially, hardware)
You can, however, decide to only support the blue collar layer. C without the standard library does that, for example.
RE objects, I guess they are referring to Smalltalk-style objects. Objective-C has them while Swift has a somewhat different flavor of objects. This author seems to consider that a regression of sorts.
RE the connection and component languages — your “white collar” and “blue collar” languages (BTW, I like your terminology, so I’ll use it), I think they are making the point that Objective-C started with a blue collar language, C, and extended it with while collar language features (derived from smalltalk), while Mojo started with a white collar language, Python, and are extending it with blue collar features. The author likes the Mojo approach, though doesn’t really explain that. I think they are claiming Swift is somehow more aligned with the blue collar side than Objective-C and feel that’s bad, but it’s too vague to really mean anything.
(I think the idea with Swift and some other newer languages is that you can have a single language that is good at both white collar and blue collar things and “native” to both. I don’t think Swift has quite pulled it off, but it’s still evolving, so we’ll see.)
The latter has silently won the war and any use of Swift as a systems programming lang/env is left as a "isn't it nice than you can" rather than a P1 design goal for the language (or even P2 for that matter)
After 10 years and exposure to dozens of languages, I find Swift to be utterly delightful to write anything with, and wish that it did have the drive behind it to become a more generalized and cross platform. language, but I'm under no illusions that it will while pre-WWDC and pre-product-unveiling narratives are driving the direction of the language from the back seat of the car.
It is improving, albeit slowly because it's an effort driven more by the community than by Apple.
IMO, top-end blue collar educations such as engineering or medical degrees certainly don’t take less time than white-collar ones such as law school or an MBA.
With Objective-C, they started with the "blue collar" language (C) as the base language, and added in "white collar" language features (Smalltalk), to achieve a language where you could switch between blue collar and white collar programming without switching languages.
Mojo starts with the white collar language (Python) and adds blue collar language features to it (the Mojo additions that allow you to control the memory layout and execution at a lower level).
That's really all the article is saying.
Yes, it was presented as being a systems language, too, but that convinced very few (and still doesn’t convince many, I think. The language is moving there, but it will be a while before it gets there, if ever)
So, why claim Swift more than repeated “Objective-C's mistake of using the component language as the base”?
If C isn't blue collar enough for you, nothing is, beyond assembly.
Nope.
The analogy you came up with is interesting, but although there is some overlap, it doesn't really capture the distinction and is the reason why you're not understanding the bit I wrote about connection languages and component languages.
You can have a component language that is just as "white collar" as the connection language. And you can (probably) have a connection language that is quite blue collar, although that might be a bit harder.
The reason I find your analogy interesting is that despite actually not capturing what is there, it does seem to capture how many people (erroneously) view and use the distinction between connection and component languages.
Objective-C added Smalltalk as a connection language, a language for plugging together the Software ICs you would write in C. See, for example https://blog.metaobject.com/2019/01/swifter-sieving-of-prime... It did not add Smalltalk as a "white collar" language that didn't need to get its hands dirty, and it didn't have the facilities to do that. Over time, people discovered that the connection language was in many ways more convenient to use, and so did what you describe, use it as a "higher level", more "white collar" language. But once again, that was an abuse of the language, it wasn't made for that and, due to not being made for it, it wasn't very good at it. Even after they added some facilities to make that use-case more possible.
I agree, though. I don’t see much basis for comparison.
To be clear, I didn't spend too much time examining this, so I might be way off. Grafting types onto a language doesn't interest me.
At least, clicking on "Get started with Mojo" on their website seems to lead to a form to fill out instead of to an easy download. I haven't filled it out so I don't know if you need to wait for approval or what.
But, given how little I've seen about it in terms of availability and source availability, I guess I'm having a hard time understanding why people seem to be so hyped about it. No matter how nice it is, unless it gives some major advantages over Python and some system like PyTorch or Jax, I wouldn't port my entire machine learning pipeline over to a propriety language for which only one implementation exists that I can't even download without filling out a form.
So it makes sense that it's not open, and you can only use it via their notebook. It probably doesn't work on normal hardware + Linux. That's the monetization strategy. You have to run their system and pay for it.
I use Python for application programming, scripting and basic ML, so I think many of the Mojo features are not for me...
On the other hand, I love types and I think they're one of Python's weakest points. I use mypy and native typing but they feel like a weak scaffold compared to a strongly-typed language or even something like TypeScript.
Do you guys think there will be a case for Mojo as a general-purpose programming language "for the rest of us"?
At the end of the day, mojo is very very early, not even open source yet.
Furthermore, mojos success will be largely bound to modulars success, which is a VC backed company. A decent looking one but still that means it's more likely to fail fast than succeed slowly.
> Mojo is a general purpose language and can be used to replace C use cases like Rust does etc, but that isn't where we're focusing initial development. That doesn't mean we're excluding it, just that the libraries etc aren't the focus for us to build. We hope the community will be interested in filling that in and building out the use cases in time though.
https://github.com/modularml/mojo/discussions/302#discussion...
Maybe it's true, maybe it isn't. But who do you think has a vested interest in that meme being repeated? Mojo is a commercial, closed source language implementation backed by $30M of investor cash looking to turn a profit.
I wish them luck and watch with interest. Like a lot of people I've had "write a very fast Python and ??? and profit" on my todo list for a while (it remains below "job to pay the bills" though) because there's been obvious user interest for some years, although it's not clear if that translates to much commercial demand. I think if they are successful and if they remain closed source, an open source clone will appear soon after, and within a year or two will match or outperform them on reported performance, but they will still have a business for the same sorts of reasons Red Hat remains profitable.
Whether it is or not, that was Apple’s own language when they announced it.
Still I do like the idea of "scalable" languages. Nim accomplishes this largely by making programming the "low level" mostly as simple as programming in the large. To be fair Nim doesn't offer too much special for "component programming" like Obj-C's aside from basic objects. Though one could argue making good DSL's is certainly a superpower and benefits component programming.
The main point is that computing in the age of LLM and gpu/tpus and the semi-dead Moore's law is hitting a wall.
Climbing over that wall will take bold vision and skillful execution. There may be alternative ways to get to that next phase. The modular/mojo team is basically throwing down the gauntlet.
Mojo is aiming to be a state of the art systems language that has Python embedded seemlessly. It's exactly the other way around from numba/Cython which embedd compiled C in performance silos inside Python.
I used to do heavy numba work and this has no relationship to that. Just look at what the devs are actually targeting/implementing right now: Better lifetime/ownership semantics and ergonomics.
This is not in the same universe as numba (or even Julia).
I think it's far too early to tell whether it will be good, but I haven't seen any other approach that resembles it.
That being said, I wouldn't describe it as 'open' at the moment. It's more just that you can verify any claims they make.
I don't see how that has any relation to Mojo which seems to be a compiled, lowish-level language on the same vein as Rust/C++/Swift?
Maybe because it has a Python "fallback"? I don't find Python particularly "smalltalky" beyond its dynamism.
if you took the c out of objective-c you basically have smalltalk but you still might need c-ish level expressions to get better performance
the expectation from swift then, was that you'd start out with that high-level paradigm and then provide lower level constructs only when needed for performance or other reasons, but the reality is you start off closer to a really well-designed and clean c++ (structs, classes, enums, generics) that adds higher level features (actors, async, etc) when you need it than something that starts off high-level as smalltalk or python from the get-go
the reason the author likes mojo more in that respect then is because it starts with the high-level constructs (python) as the substrate and allows for tuning where needed... the presupposition i think is that will lead to higher productivity and simpler code in the long run (this is my interpretation)
But by the time you add all these features, don't they already exist in other languages? What is this one doing that will be enough of a leap to justify 30m investment?
Seems more like a Python Transpiler with types.
If it's a marketing/VC move to become some kind of spiritual version of MongoDB but for "AI langs", no thanks I'm good.