259 points · by todsacerdoti · 6y ago · 188 comments
Programming language flamewar is not interesting, so please don't do it here.
I am one of the devs who got attracted to Rust's advantages over C/C++ (no double free or use after free, guaranteed memory ownership, relatively fearless concurrency) and have been using it increasingly to the point of now professionally working with it.
But I never felt the need to degrade others for not using it. I do have my strong opinions about when and where it should be used but I almost never escalate them to flaming (sadly it occasionally happens even to the best humans).
I'd hate it if such an excellent technology's well-deserved adoption is held back because its core user base is viewed as zealots.
:(
(proof: https://keybase.io/byronbates)
It is my hope that the quality and stability will be high enough to convince people [in the Rust ecosystem] to move away from libgit2 and instead contribute to the maintenance and development of gitoxide, rewarding everyone with better performance and improved usability.
I haven't looked at the internals of Git much, but performance becomes an issue with it in this context (we currently use a different vcs), and switching seems impractical at the moment. Issues from local performance (30 seconds or so for git status, git checkout, etc) and clone/fetch speeds.
I'm curious, given your experience on porting, have you noticed areas where we might be able to make improvements that might be easier based on Rust's safety improvements? Such as more threading or other areas that could improve Git for use with very large code bases?
(I plan to review the project as this would be an exciting area to work in to help with productivity in this space)
The same applies when checking for changes on disk - right now git does not do that in parallel. These are low hanging fruit that I plan to pick for my own sake.
There is another contributor who is very interested in increasing pack performance, which will directly impact fetch and pull speeds. Judging from my experience with packs thus far, I believe a lot of options are still to be tapped in that field as well. Rust will open it up for contributions and experiments to a greater audience, so I would hope that this will go way beyond of what I can do.
Even though this project is not very contributor friendly right now, I will be working on improving this so more people can join in (see https://github.com/Byron/gitoxide/issues/8).
Actual numbers for what's there, pack access and traversal, can be found here: https://github.com/Byron/gitoxide/issues/1 and here: https://github.com/Byron/gitoxide/issues/5
What in your opinion would be a good place for someone to start contributing to this?
My 2 cents. I think rust-analyzer offers a great new dev onboarding experience. issues labelled with has-instructions usually have a a link to the relevant snippet of code in the repo and sometimes even the stub of a failing unit test. While it might be obvious to you, the author, how and where to find the necessary code, it enables a great many people to send patches.
Witness the number of contributors with <10 commits https://github.com/rust-analyzer/rust-analyzer/graphs/contri...
If you want to increase adoption, please borrow as many dev experience tricks from rust-analyzer as possible
Based on my experience, the main value is that it makes this code easily portable.
Meaning, if you can compile rust on your device, you can just run this code without worrying about also installing and appropriately linking the correct version of some C library. It's a huge convenience.
Of course, this only works if all dependencies are also pure Rust. I haven't verified that this is the case here. Here's hoping!
* C is more portable than Rust because there are C compilers available for more platforms than there are Rust compilers for Rust platforms.
* Rust is more portable than C because Rust programs tend to be written in a more platform agnostic way, and are therefore more likely to be able to work on platforms that they weren't originally intended for.
(To make the second point more concrete, as a Windows user, pure Rust programs almost always Just Work for me, but as soon as we get into C dependencies, it becomes way, way way worse.)
Proof: just look at graphics. You just write your graphics code in a platform-independent way and use the correct .BGI file for your graphics hardware.
And it's safe: no pointer arithmetic or void; real array passing. Module system for dependencies. No makefiles needed. No problem of linking a stale object file that didn't get rebuilt due to a missing dependency rule.
Turbo Pascal is the golden future, my friends.
If it's pure rust, then I don't have to worry about dynamic or even static linking. I just compile the code for the target and I'm done. Cross compiling becomes simple. Installing becomes simple.
I'm repeating myself a bit here but just to clarify: there's no question that pure C is awesome for portability. And like with Rust it becomes less fun once dynamic linking gets involved.
Now certainly there are platform-specific things with Rust as well, but the defaults are structured in such a way that exposed APIs are more likely than not to be platform independent--you have to go out of your way to break compatibility, rather than it being the default.
And once you get your binary to compile, the static linking means there isn't runtime dependencies that might break either.
The net result is that given a piece of rust code, it is far more likely than its C equivalent to compile on a new platform. And once it does compile, it can be run in any context without concern for differences in the runtime environment. The Rust compiler may target fewer platforms, and therefore be "less portable" in that sense, but if it is a supported backend then it is going to be easier to get the code working.
If you’re talking about code portability of pure C, no dependencies, then I agree. Once you start depending on platform features, in my experience, the portability of Rust is superior.
Where is the Rust compiler for a Motorola 68K?
How about PIC24? And if there is ever a Rust compiler for PIC24, what will happen to all that run-time support? How much of it will work? How will you detect what of it works and what doesn't, in order to work around for it in your program?
Take a random, non-trivial C program or library and try to compile it for something that's not a Unix (edit: or cross-compile it). How hard is it to do? Now, do the same with a random Rust crate. It's probably a lot easier.
I think there are two key differences. First, Rust has a standard build system (Cargo) that is dominant, while there are many competing build systems for C. Second, the Rust standard library was designed much more recently, and covers far more of the functionality in today's platforms than the C standard library does. (For example, contrast Rust's OsStr and Path types with the pain of supporting Unicode filenames on both Unix and Windows in C.)
I would guess this will slowly change as LLVM gets more backends, but that's pretty hand-wavy. The other option is we move more towards platform monoculture, which is probably more likely? Not sure.
cough cough Windows cough
Even after years of using git, this is for me a major pain point.
> a simple command-line interface is provided for the most common git operations, optimized for user experience. A simple-git if you so will.
But an explicit non-goal is
> replicate git command functionality perfectly git is git, and there is no reason to not use it. Our path is the one of simplicity to make getting started with git easy. a simple command-line interface is provided for the most common git operations, optimized for user experience. A simple-git if you so will.
So it depends. They may refine some parts of the UX, others may be identical, and other still will be left unimplemented because git still exists.
What you've done is awesome!
What I would love to see is a pure-Rust reproduction of the git commands we know, some simple-git flavor commands, a Git API we can call from Rust, and the ability to add new Rust written git commands. I would love to put my money where my mouth is and volunteer to help, but my job right now is consuming all of my time not spent on family.
Furthermore, git aliases work on your machine. Then you ssh to a server and suddenly `git please-do-my-command-without-many-weird-options` don't work. Yes you can sync them, but not super-easily. Whereas a complete tool you can just distribute onto the machines you work on. Not entirely different, but not the same either.
Please note that everything I name can certainly be fixed by some tool that already exists, and that's great. It's just that I would like to have 'this one tool' that gets most things right and be happy with it alone.
That said, here is my list:
* adding individual files to the staging area/index
* looking at the commit history and copying individual commit hashes
* pulling while assuring no merge commit is created, or: simplified trunk-based development
* resumable clones
* seeing what's going on during all remote operations - here in China GitHub is incredibly slow most of the time and connections can be flaky
The third one is a bit unclear to me:
> looking at the commit history and copying individual commit hashes
What do you mean exactly by that?
It will be nice instead of proclaiming Rust as “C” replacement it should have positioned as “A language complementing C/C++ to write safe code”.
Recently Servo project is abandoned by Mozilla for which Rust is a primary language.
Now need to see, if Rust can fulfils it’s primary objective to write Firefox in Rust, it looks more remote now. So it will take much longer for Rust to become as ubiquitous and important as Go language for systems programming. Probably Microsoft and others might pick to write some core new systems in Rust, instead of just rewriting same working C/C++ code in Rust for marketing purposes.
"Pure" is not some Rust marketing ploy :-)
It's a pretty established term meaning "written only with". I've seen pure Python, pure PHP, pure JavaScript, etc libraries and apps.
It generally means you don't need another compiler to build or you don't need to know another language to contribute or fix things for yourself.
This was what Mozilla hoped to do with it. But the teams at Google, Facebook, Amazon, Microsoft, Dropbox, Cloudlfare, fastly and others using Rust have different objectives. At this point, Firefox's success and Rust's success are decoupled.
'Pure Rust' counts for little if the code overuses Rust's unsafe features.
edit This was a sincere question. I'm glad the answer turned out to be that there's very little of it.
There was an HN discussion a few months back on a Rust program that overused the unsafe features, to the point it may as well have been written in C. Sure enough, it turned out to be full of nasty bugs.
Mildly disagree. Even if half the code base is unsafe, that's better than a code base where everything is unsafe. Now I only have to audit half the code base for crazy shit, which is about half the effort. A stronger type system means that even in unsafe land, we can still encode some invariants better.
I disagree with this notion that "if you're going to have bugs anyway, what's the point of Rust". Our goal isn't to eliminate every bug in the world, it's to have fewer bugs today than we did yesterday. Rust, even Rust with several unsafes thrown in, helps us achieve that goal.
Such a downvote heavy community. Plaudits to all involved.
There are reasons to prefer a pure-rust code, even if the whole crate was unsafe.
Again, plaudits to all involved.
A program can qualify as pure Rust without making use of the safety advantages of the Rust language. It's not unreasonable to wonder how much unsafe code there is in a Rust codebase. It matters.
Rust is better for having unsafe features, but it opens the door to their overuse, and this shouldn't be ignored.
In the SPARK Ada world, there are 'assurance levels' that offer different levels of guarantees. [0] At the 'Silver' level and above, there is a guaranteed absence of runtime errors (such as divide-by-zero, or out-of-bounds array access). Rust doesn't have such a scheme. It seems reasonable to wonder about overuse of unsafe features (as fuzzy as that is), as a very rough approximation.
[0] https://blog.adacore.com/from-ada-to-platinum-spark-a-case-s...
---
FTI [0]:
> In 2007, Jeff Atwood made the quote that was popularly referred to as Atwood’s Law:[5] >> “Any application that can be written in JavaScript, will eventually be written in JavaScript.”
Any improvement in this area would need to inhere in library-level facilities constructed for the purpose. What are they?
You can still swallow errors if you want to but you have to manually write unwrap() so it's much more visible.