News for hackers. Stuff that matters.
Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @03:49AM (#24140949)
From 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 for a recent, very relevant discussion on that topic with multiple examples and a good rationale.

Re:Gitoxide: Pure Rust Implementation of Git by avasthe on Thursday August 13, 2020 @09:25AM (#24143067)
Yea no exceptions in C
Re:Gitoxide: Pure Rust Implementation of Git by dthul on Thursday August 13, 2020 @09:57AM (#24143365)
Neither in Rust ;)
Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @09:37AM (#24143183)
...have an upvote.
Re:Gitoxide: Pure Rust Implementation of Git by linkdd on Thursday August 13, 2020 @04:01AM (#24141021)
I 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!

Re:Gitoxide: Pure Rust Implementation of Git by rhn_mk1 on Thursday August 13, 2020 @04:08AM (#24141050)
The 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.

Re:Gitoxide: Pure Rust Implementation of Git by rsa25519 on Thursday August 13, 2020 @05:58AM (#24141642)
> 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.

Re:Gitoxide: Pure Rust Implementation of Git by gpm on Thursday August 13, 2020 @08:16AM (#24142549)
It'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".

Re:Gitoxide: Pure Rust Implementation of Git by rsa25519 on Monday August 17, 2020 @06:23PM (#24192951)
Agreed. Very well put, thank you.
Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @04:14AM (#24141080)
As a Lisp programmer, I don't dunk on everything that is not Rust; I instead dunk on everything that is C. The extensive use of this language has brought us countless pain via stack overflows, buffer overflows, memory corruption, and multiple other vulnerabilities that are literally baked into the language model. Dropping C for any sane alternative will be a massive boon.
Re:Gitoxide: Pure Rust Implementation of Git by jayp1418 on Thursday August 13, 2020 @04:59AM (#24141291)
I think ada can be good contender for C replacement
Re:Gitoxide: Pure Rust Implementation of Git by MaxBarraclough on Thursday August 13, 2020 @05:39AM (#24141521)
I think Ada's future is in safety-critical systems, where it makes sense to invest heavily in correctness, with the option of using SPARK and formal verification. Additionally, Ada has several mature compilers suitable for life-and-death applications.

For more ordinary software though, doesn't Rust make more sense? Its approach to memory management for instance, with a borrower-checker, seems much nicer than what Ada has to offer.

Disclaimer: I know neither language very well.

Re:Gitoxide: Pure Rust Implementation of Git by imtringued on Thursday August 13, 2020 @05:54AM (#24141616)
You need something with traction. How are you going to rally people to use ada? Where is the ada version of Gitoxide?
Re:Gitoxide: Pure Rust Implementation of Git by MaxBarraclough on Thursday August 13, 2020 @06:11AM (#24141715)
> You need something with traction

No language has traction, until it does.

It would be fair to point out though that Ada has had decades to catch on and replace C, but it hasn't done so, except in certain narrow areas of highly critical embedded software development in aviation and military applications. My understanding is that it's not easy to work with for 'general purpose' work (command-line applications on GNU/Linux), as it lacks mature bindings.

I think it's fair to say Ada failed to truly embrace Free and Open Source software. A pity, in my opinion.

Re:Gitoxide: Pure Rust Implementation of Git by jayp1418 on Thursday August 13, 2020 @10:03AM (#24143432)
Well they are trying to reach FOSS community. Recently they started survey asking community "Hello here, we (AdaCore) have some plan for the future of GNAT Community that we want to share and have your opinion on: https://forms.gle/Q34myTCQUXvrva5n7 " There is Ravenports very good port manager written in ada for FreeBSD so ada can be used for CLI apps and has good gtk binding too
Re:Gitoxide: Pure Rust Implementation of Git by MaxBarraclough on Thursday August 13, 2020 @11:28AM (#24144346)
A good sign, see also relevant discussion at [0]. I like the idea of a FORTH target that someone suggested.

Are the higher assurance-levels of SPARK going to remain unavailable to FOSS developers, as they apparently are now? [1]

[0] https://groups.google.com/forum/#!topic/comp.lang.ada/M3yS4S...

[1] https://www.adacore.com/sparkpro

Re:Gitoxide: Pure Rust Implementation of Git by erik_seaberg on Thursday August 13, 2020 @03:21PM (#24147220)
Doesn't Ada have the same explicit deallocation and use-after-free problems C does?
Re:Gitoxide: Pure Rust Implementation of Git by namKS on Thursday August 13, 2020 @06:25AM (#24141799)
Better do not use Lisp, since the interpreters have at least around 10% C.
Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @06:31AM (#24141835)
They're compilers, not interpreters - or at least SBCL, CCL, ABCL, ECL, Clasp, CLISP, ABCL, and LispWorks are. I'm not aware of any other alive contemporary Common Lisp implementations.

Lisp is a memory-safe language with automatic memory management, which removes all of the aforementioned classes of attacks that are available in C. In addition, the Lisp compilers are written in Lisp itself, not in C, which further decreases the attack vector.

Also, the currently-in-progress SICL project intends to do away with C completely, even for its garbage collection and OS-interfacing parts.

Re:Gitoxide: Pure Rust Implementation of Git by hmartins on Thursday August 13, 2020 @07:05AM (#24142025)
CCL:

Totals grouped by language (dominant language first):

  lisp:        336793 (84.60%)
  asm:          30410 (7.64%)
  ansic:        29862 (7.50%)
  sh:             718 (0.18%)
  objc:           299 (0.08%)
  java:             7 (0.00%)

> Lisp is a memory-safe language with automatic memory management, which removes all of the aforementioned classes of attacks that are available in C.

Yeah, right.

Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @08:17AM (#24142559)
> Yeah, right.

In Lisp, the programmer never frees memory themselves, so use-after-free and double-free are not triggerable by the user. Bound checks for all array types are in effect, so overflows are impossible. Strong typing and a lack of casting prevent type confusion.

Do you have any arguments other than the unsubstantial "yeah, right"?

Re:Gitoxide: Pure Rust Implementation of Git by kazinator on Thursday August 13, 2020 @09:11PM (#24152028)
Lisp implementations using C means that the implementations may have C-related vulnerabilities, not Lisp programs themselves. You're not facing the risk of creating new C-related vulnerabilities by writing new application code in Lisp, even if the Lisp you're using has substantial amounts of the run-time written in C.
Re:Gitoxide: Pure Rust Implementation of Git by csdreamer7 on Thursday August 13, 2020 @04:59AM (#24141289)
As others have said, the issue is with C style memory issues.

Rust not only gives you safety and correctness, but gives you often speed as a bonus over C. There is a real benefit towards rewriting everything written in C in a language/tool system like Rust.

There is still a place for other languages, especially ones that use a garbage collector. Rust would make that garbage collector a lot safer.

Re:Gitoxide: Pure Rust Implementation of Git by amelius on Thursday August 13, 2020 @05:35AM (#24141496)
I think garbage collected languages like Haskell actually provide better security than Rust, because the code is not littered with constructs dealing with memory management.

The only reason to use Rust is if you need the performance. But often, that's only an issue in your "inner loops", so you could write the rest of your code in a more suitable language.

Since in most cases these performance critical parts are only small in terms of lines of code, and hence easily verifiable by hand, you could even write them in C and still not have security issues.

Therefore, I think Rust serves only a very specific need, and isn't nearly as universally "the right tool" as everyone seems to believe.

They do have a nice packaging system, though.

Re:Gitoxide: Pure Rust Implementation of Git by roca on Thursday August 13, 2020 @06:18AM (#24141751)
For applications like Web browsers the "inner loops" approach to optimization isn't nearly enough. Execution of important benchmarks smears out over huge amounts of code. If executing straight-line code in your favourite language is just a bit slower than C++, or touches more memory than C++, it's a losing proposition.
Re:Gitoxide: Pure Rust Implementation of Git by amelius on Thursday August 13, 2020 @06:23AM (#24141786)
Yeah, but Web browsers are very much like OSes, and can be considered a special domain where Rust indeed can be useful.
Re:Gitoxide: Pure Rust Implementation of Git by roca on Friday August 14, 2020 @07:57PM (#24164650)
I think the same would be true of LibreOffice for example.
Re:Gitoxide: Pure Rust Implementation of Git by anshdgTHa on Thursday August 13, 2020 @05:19AM (#24141406)
Since the top subthread comment has been predictably flagged by the clique:

Rewriting is easier than doing original work. If you manage to get people to use "your" new Rust project, you get a huge payoff for comparatively little work with lots of plagiarizing.

Re:Gitoxide: Pure Rust Implementation of Git by oblio on Thursday August 13, 2020 @05:34AM (#24141491)
Someone should have told Linus to stop plagiarizing. Heck, someone should have told Stallman and GNU, too.

Your argument is quite flawed.

Re:Gitoxide: Pure Rust Implementation of Git by linkdd on Thursday August 13, 2020 @06:51AM (#24141935)
I just think there is more crucial project to rewrite than git, vim, etc...

At this point, it's just falling for the hype.

The same thing happenned with go, es6, etc...

"X is better than Y because it is written in Z" is not a valid argument.

A kernel in Rust? Yes please. A browser in rust? Can't wait. A fork of openssl in rust? Yes yes yes. A cli tool? Why? Is it really necessary?

And yes it is a genuine question, not some random rant.

Re:Gitoxide: Pure Rust Implementation of Git by Kaze404 on Thursday August 13, 2020 @08:32AM (#24142671)
I don't think every project has to be a crucial endeavor or a new thing. Let people do things for fun.

> A fork of openssl in rust? Yes yes yes.

https://github.com/ctz/rustls

Re:Gitoxide: Pure Rust Implementation of Git by linkdd on Thursday August 13, 2020 @09:55AM (#24143340)
I never implied you can't do stuff for fun.

Projects done for fun are not "marketed" as "a replacement for X"

Re:Gitoxide: Pure Rust Implementation of Git by Kaze404 on Thursday August 13, 2020 @10:46AM (#24143858)
I don't see this being marketed as a replacement for Git anywhere.
Re:Gitoxide: Pure Rust Implementation of Git by GoblinSlayer on Thursday August 13, 2020 @08:37AM (#24142709)
A git repo is often received from untrusted source in internet and there were associated bugs in git.
Re:Gitoxide: Pure Rust Implementation of Git by namKS on Thursday August 13, 2020 @06:23AM (#24141785)
Ok, so CPython is broken by default and by design. Yes Sir, understood sir, no exceptions, sir!
Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @06:32AM (#24141839)
Sure. Do you have any arguments why it isn't broken and go against the arguments linked in the related HN discussion? Is CPython in some way immune to overflows, use-after-free, double freeing, and so on? How much of CPython is actually implemented in C, and how much in itself and/or in Python?
Re:Gitoxide: Pure Rust Implementation of Git by ginsider_oaks on Thursday August 13, 2020 @09:23AM (#24143057)
is any rust code some way immune to unsafe blocks?
Re:Gitoxide: Pure Rust Implementation of Git by wizzwizz4 on Thursday August 13, 2020 @09:29AM (#24143116)
That's a little different. If you're running a C linter that statically guarantees safety, then it's comparable; otherwise, you're comparing mostly Safe Rust (with some Unsafe Rust in it) to Unsafe C.

Safe Rust is automatically immune to lots of these issues. Unsafe Rust isn't, but all of C is unsafe (unless you're using a safety-enforcing linter that only gives you access to a subset of the language).

Re:Gitoxide: Pure Rust Implementation of Git by hmartins on Thursday August 13, 2020 @07:04AM (#24142014)
Why should we care about arguments in a random HN discussion? We should care about arguments from people who have done substantial work.

Totals grouped by language (dominant language first):

  python:      578880 (54.33%)
  ansic:       475310 (44.61%)
  sh:            4073 (0.38%)
  cpp:           3847 (0.36%)
  asm:           1486 (0.14%)
  objc:           761 (0.07%)
  lisp:           502 (0.05%)
  pascal:         353 (0.03%)
  xml:            308 (0.03%)
  csh:             21 (0.00%)

Most of pure Python is in the stdlib.
Re:Gitoxide: Pure Rust Implementation of Git by phoe-krk on Thursday August 13, 2020 @08:22AM (#24142609)
> We should care about arguments from people who have done substantial work.

OK, we can drop the HN comments. Since Stefan Hajnoczi is a substantial QEMU contributor, how would you respond to the arguments linked in http://blog.vmsplice.net/2020/08/why-qemu-should-move-from-c...?