25 ms·
Gitoxide: Pure Rust Implementation of Git
- demarq 6y agoThis was bound to happen at some point
- abdusco 6y agoIs there a Rust version of Atwood's Law? --- 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.” [0]: https://www.wikiwand.com/en/Jeff_Atwood https://www.wikiwand.com/en/Jeff_Atwood
- Kinrany 6y agoAtwood's Law 2.0 should probably be about WASM
- nindalf 6y agoAnd there is a language that's pretty good at compiling to wasm.
- seanhunter 6y agoThis goes nicely with the old concept that "A sufficiently competent FORTRAN programmer can write FORTRAN code in any language".
- linkdd 6y agoWhy do people feel the need to reimplement everything in Rust ? If it's not broken, don't fix it...
- atoav 6y agoBecause it is a interesting excercise to reimplement something great in a new interesting language you wanna test drive? Why are people writing new programming languages? After all we already have some. Sometimes you do it for fun and frivolity, sometimes because you think you can do better, sometimes because you are addressing real tangible issues with the old way of doing things and often a combination of the three.
- dragonsh 6y agoReimplementation relying on unsafe ‘C/C++’ code (as most of the core infrastructure is written in them) is done more for marketing especially among language aficionados. Hope someone from Rust community can write something which can match some of the core software written in Go language, which has already proven its usefulness and quality in writing systems programs in networking and system infrastructure areas. C/C++ replacement at this time is just a wishful thinking given Rust cannot work without C/C++ today, most useful crates will break if underlying C/C++ code is not maintained or updated.
- imtringued 6y agoReplacing the underlying C/C++ code (including the kernel) is a work in progress. Not everything happens all at once. I'm not talking about this project in particular. More about what will happen to the general C ecosystem.
- atoav 6y ago> Reimplementation relying on unsafe ‘C/C++’ code (as most of the core infrastructure is written in them) is done more for marketing especially among language aficionados. Let's read the page we are talking about to check your judgment: "Project Goals: a pure-rust implementation of git including transport, object database, references, cli and tui" and "Non-Goals: replicate git command functionality perfectly" Doesn't sound like they are relying on unsafe C/C++ code at all – and sounds like they are just doing it out of curiosity. Unless you mean that parts of the git infrastructure (beyond this project) use C/C++ and therefore as long as you don't rewrite everything at once, their effort remains meaningless, which would be quite a dire world view, so I am assuming you mean something different which I don't get atm.
- phoe-krk 6y agoFrom the security perspective, if it is written in C, then it is broken by default and by design - no exceptions. See https://news.ycombinator.com/item?id=24133128 https://news.ycombinator.com/item?id=24133128 for a recent, very relevant discussion on that topic with multiple examples and a good rationale.
- linkdd 6y agoI really don't understand the hate towards every language that is not Rust. Rust provide you tools to avoid many security issues. But that does not mean everything that hasn't been written in Rust is broken by default. You still have "unsafe" in Rust, so is it broken by default and design and we should throw away the language ? Obviously not!
- rhn_mk1 6y agoThe hate is not towards every language that is Rust, it's against C, at least in this thread. I haven't seen anyone arguing against Python or Java in a Rust thread. Memory-managed languages are already at the memory safety levels comparable to Rust's borrow checker.
- rsa25519 6y ago> it's against C More specifically, I hope, C++. I like to think of asm, C, and Rust as a trio. C isn't "better" than asm; it just doesn't make sense to use asm when C does the job. And it doesn't make sense to use C when Rust does the job. C++ is where, in almost all scenarios, I draw the line and say, this would be probably be better if new code is written in Rust.
- gpm 6y agoIt's generally against both C and C++, because the reason applies to both of them. That reason being that using these languages expose users and the world to huge negative externalities in the form of security vulnerabilities, or alternatively (but resulting in the same conclusion) that the speaker just likes writing correct code. > And it doesn't make sense to use C when Rust does the job. There are few jobs left where C can do it and Rust can't, those jobs are generally "well there exists a C compiler for this architecture and not a rust/llvm backend". Rust is generally just as capable as C is at writing low level code. If you're willing to put up with translating macros by hand (or using wrapper functions), it's even capable of integrating with existing C code bases. Lots of people still prefer C over Rust in various situations where you could use Rust, so I don't think it's a generally accepted fact that "it doesn't make sense to use C when Rust does the job".
- renewiltord 6y agoPerhaps because it brings them pleasure. That hardly seems a sin. And then they share it with others, for whom seeing the work is a pleasure and perhaps an inspiration. That seems just as little of a crime.
- linkdd 6y agoI quote the README, in the goal section: > become the foundation for a free distributed alternative to github. > be the best performing implementation This seems ambitious, and not something done for fun
- renewiltord 6y agoSurely ambition and pleasure do not preclude each other.
- MCOfficer 6y agoI tried to interact with Git from rust code once. The only option for any language is libgit2 or its bindings, and let me tell you, it's terrible. I was this close to just calling git from the shell when i eventually just gave up.
- linkdd 6y agoI used libgit2 a lot, the only thing I disliked about it was the lack of documentation (well, the source code is the ultimate documentation?).
- kanobo 6y agoI don't think the author thinks git is broken, most likely the opposite. I often reimplement things I admire or want to learn how they work. I would guess that is one of the motivations of this project.
- Ygg2 6y agoOne reason is to avoid the nasty include C libs, that don't work everywhere. Second reason, for fun. Third reason, didn't you note all the parallelization gains?
- guerrilla 6y agoI imagine there are different motivations for different people. Some people may just want to use rust to re-implement something that exists in order to hone their skills or just for fun. Having a reference implementation makes that more productive. Other people may think that it would simply be better if the project were implemented in rust. This is the case for some C projects, where a lot of control is still necessary but the project would benefit from the safety and productivity gains of rust. See the example of QEMU yesterday. It is an absolute pain in the ass to do things well in C. Correct programs end up being heaps of boilerplate and tests. I'd love to escape C but haven't been able to until Rust. Maybe some people just want to showcase that Rust can do the thing. I think that's fine. It might help in adoption. It might cause better libraries to be created that are actually used. For me, rust is the first real competitor in the systems programming market. There are hundreds of languages for application programming. I prefer Haskell, Java and JS for those but I've never found a replacement for C in the low-level domain. C++ just never cut it for me and the alternatives never really caught on. For me, Rust brings a lot of what we learned from Haskell and ML to C without sacrificing the low-level control. If I wanted to get better at Rust, I'd probably also implement something that exists just so I could check my work. If I was to re-implement some of the low-level projects that I've worked on, I'd also probably do that in Rust. I'm getting really tired of comments like this though. Why does it bother you so much? Are you trying to communicate that you'd prefer this person be doing something else with their time? What does that even mean?
- linkdd 6y agoIf you do it for fun, or to learn, that is more than fine. But seeing almost every day a new tech "implemented in Rust because X sucks and is not secure" is becoming annoying.
- DougBTX 6y agoKeep in mind that the person who posed this appears to have nothing to do with the project, they're just someone who's seen something that interests them and shared it here, the same as the people voting it up.
- 6y ago
- pgt 6y agoSafety & performance.
- kanobo 6y agoIf you're interested in a step-by-step guide on how to build your own git from scratch, this book is excellent and incredibly educational: https://shop.jcoglan.com/building-git/ https://shop.jcoglan.com/building-git/
- NetOpWibby 6y agoFor the curious, this guide uses Ruby as the building language.
- jamesmunns 6y agoI've also seen a number of people following along in this book in other languages, including Rust. It really is a well written guide, even if you're not fluent in Ruby.
- pankajdoharey 6y agoTrust me its way easier than you think and there are tons of free resource available you dont need a $36 book to build git.
- stdbrouw 6y agoYou probably misunderstood: they're not talking about building from source (which is easy), but rather about recreating Git from scratch in another programming language (which is hard).
- pankajdoharey 6y agoNo I understood, and it is still easy. https://news.ycombinator.com/item?id=19386141 https://news.ycombinator.com/item?id=19386141 https://youtu.be/MYP56QJpDr4 https://youtu.be/MYP56QJpDr4
- kanobo 6y agoI didn't watch the video but I've gone through that guide you linked, it's excellent but I don't think it's a great comparison. It only implements a handful of commands and doesn't go into the same amount detail. The Building Git book goes way more into the interesting bits.
- renewiltord 6y agoFascinating, this doesn't use `libgit2` anywhere. I didn't expect that. Very cool.
- EE84M3i 6y agoWhat did you expect instead from "pure rust"?
- renewiltord 6y agoI must have forgotten that libgit2 is a Rust wrapper.
- dragonsh 6y agoNot sure what is meant by pure, probably another way of marketing to Rust aficionados. It uses crates which still rely on unsafe ‘C’ code to interact with operating system for interacting with files and file related OS calls. 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.
- nindalf 6y ago> if Rust can fulfils it’s primary objective to write Firefox in Rust 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.
- geofft 6y agoDo you also object to the term "pure Python" because the Python interpreter is written in C? Or "pure JavaScript" because there's a whole browser underneath?
- ncmncm 6y agoAs I have understood it, the major coding flaws in Git involve failure to handle OS and file system errors responsibly. (The SQLite people are very persuasive on the topic.) Rust does not seem to bring anything new to this particular table. Any improvement in this area would need to inhere in library-level facilities constructed for the purpose. What are they?
- MaxBarraclough 6y agoHow much use of unsafe is there? '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.
- est31 6y agorg "unsafe " | wc -l tells me there are 19 occurences, for about 13.7k lines of Rust in total. So it's not a lot.
- MaxBarraclough 6y agoGood to hear. It's important to ask though. 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.
- nindalf 6y ago> to the point it may as well have been written in C 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.
- est31 6y agoIn principle I agree, but note that such projects are not created in a vacuum. Someone who goes out of their way to put that much unsafe into the codebase is more likely to commit mistakes that lead to ub than someone who just writes C stuff.
- rich_sasha 6y agoDoes this address the cryptic-ness of git commands? E.g. are the various commands we all know and love like `git reset HEAD`, `git co --track origin/branch` etc. made clearer? Even after years of using git, this is for me a major pain point.
- ByronBates 6y agoAs this is part of the every-day workflow, I will think long and hard on how to make it as painless and user-friendly as possible. Having a more user-friendly experience on the command-line is one of the project goals, and it will also be me benefiting from it so the motivation will be high to achieve it. By then, that thinking process will hopefully be public enough to allow more people to chime in and get a better result that way. And yes, I think a lot is possible, and I can't wait to test some ideas of mine :)
- rich_sasha 6y agoI'm totally looking forward to that then! :)
- letmeinhere 6y agoA stated goal is > 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.
- Communitivity 6y agoGit achieves that stated goal, to a degree, via git alias. You can define your own simple versions of the commands or shortcuts. 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.
- ByronBates 6y agoI am the author, and will be here for a few hours in case there are any questions. (proof: https://keybase.io/byronbates https://keybase.io/byronbates)
- robert_foss 6y agoHow does gitoxide perform compared to c-git? A slow operation I often encounter is `git log --graph` for example.
- ByronBates 6y agoUnfortunately I can't yet tell, as the corresponding code does not yet exist. Object and pack lookup is competitively fast so I would hope that translates well to everyday operations like that. Actual numbers for what's there, pack access and traversal, can be found here: https://github.com/Byron/gitoxide/issues/1 https://github.com/Byron/gitoxide/issues/1 and here: https://github.com/Byron/gitoxide/issues/5 https://github.com/Byron/gitoxide/issues/5
- stolee 6y agoThat operation is much faster in recent versions of Git, especially after a GC or “git commit-graph write” command.
- capitol_ 6y agoI'm currently using https://github.com/rust-lang/git2-rs https://github.com/rust-lang/git2-rs to interact with git in my software. Are you aiming to have a stable api that could act as a pure-rust replacement for that at some point in the future?
- ByronBates 6y agoAbsolutely! My plan is to proclaim a version 1.0 once the basic workflow of clone-commit-push can be performed, which should be enough for many to start using it. From that point on, the API should remain stable, following semantic versioning as usual. 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.
- deleted 6y ago[deleted]
- dhbradshaw 6y agoThere are several comments on the value of having this project be "pure rust". 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!
- amelius 6y agoI think that ANSI-C is a lot more portable than Rust, to be honest.
- steveklabnik 6y agoIt depends on what exactly you mean by "portable." This is an extremely complicated space with a ton of interlocking dependencies, but here are two axes on which you could make opposite claims, and be correct: * 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.)
- kazinator 6y agoNo, no, ... Turbo Pascal is what is more portable than C. 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.
- 6y ago
- deleted 6y ago[deleted]
- dang 6y agoAll: Rust has clearly reached the now-it's-a-flamewar-trigger stage of the hype cycle. Nobody wants that. If you're posting to HN, please stick to interesting specific things, not boring generic ones. Programming language flamewar is not interesting, so please don't do it here. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- pdimitar 6y agoThis is really saddening to hear. 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. :(