5 ms·
Didn't learn much from article why Mojo supposed to be better than Swift from a grass root user perspective: 1) Will Mojo provide seamless interop with C like
by pzo 3y ago
Didn't learn much from article why Mojo supposed to be better than Swift from a grass root user perspective:
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.
- twobitshifter 3y agoIt is Python with the ability to write high performance code within specified functions, eliminating the need to link in C code. However the interop with C will be the same as Python, which is already very good, Mojo is just going beyond that. It compiles to llvm. This means the python environment headaches will disappear.
- boxed 3y ago> It is Python with the ability to write high performance code within specified functions 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.
- mr_00ff00 3y agoSo is it a systems language?
- twobitshifter 3y agoYes, in the benchmarks it’s competitive and compiled programs stay tiny unlike Python which packages the interpreter. According to the story being told, it could end up a sort of one-language-to-rule-them-all. Python was chosen by Chris Lattner specifically for his wide spread adoption and Mojo is sometimes called Python++.
- stephencanon 3y ago> Swift doesn't have good interop with C 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).
- deleted 3y ago[deleted]
- pzo 3y agoSome pointer aritmetic in Swift i found it painful to do when calling some C library - it was much easier to create some wrapper in ObjC and do low lever pointer manipulation there. This is what I call it seamless - if I have to do some low level image/texture preprocessing it's still easier to do it in ObjC
- mpweiher 3y ago> seamless interop with C like objective-c "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.