Live data from Hacker News

Cross-platform Rust rewrite of the GNU coreutils

github.com

281–290 of 498 posts

Re: Cross-platform Rust rewrite of the GNU coreutils

#281
post #103

Earlier quoted context omitted.

The quality of tooling, and the ability of experts to verify the output of machine code is a really important point. I think I'd agree, rust at this point would hold back an elite developer like Richard Hipp. The promise of rust, which may or may not be realized is pushing some very common problems down to the compiler. All code has bugs, so the compiler probably does things wrong in some cases. As the tools mature,…

> C requires you to be really smart all the time, or at least be aware of when you're not smart enough to get a chunk of code right. It's not so much that it requires smarts. It's that is requires you to be ever-vigilant and to never make any mistakes. (That's why UB and bounds overflows are so devastating to software security. Almost any slip-up by the developers can be exploited.) Incidentally, the ever-vigilant bi…

> good at being ever-vigilant

There goes the price of freedom. Drats.

Re: Cross-platform Rust rewrite of the GNU coreutils

#282
post #4

Rewriting coreutils is neat, but a project I'd really look forward would be a strict POSIX base expanded with warnings or errors on valid but risky constructs e.g. echo -n. Even more so if it included a shell (with static analysis of useless uses and dangerous patterns). That would make writing cross-shell scripts much easier.

If you want to suppress non-complaint behavior, set the POSIXLY_CORRECT environment variable. You can also specify the version of POSIX to comply with, because the standards aren't always standard.

https://www.gnu.org/software/coreutils/manual/html_node/Stan... https://www.gnu.org/software/coreutils/faq/coreutils-faq.htm...

I would hope your cross-shell scripts are also conforming to a certain shell script language, and are also resetting all environment factors which change the function of various commands. Not that endianness is ever a worry with a shell script ............

(Also note that POSIX supports printf, which you can use to insert any character string you like, basically)

Re: Cross-platform Rust rewrite of the GNU coreutils

#283
post #269

Earlier quoted context omitted.

> We're fast-moving because our foundation is solid and not changing (ie. CoreUtils and gang). That isn't a definition of "fast moving" that I would use. It sounds like slow moving. Why is innovation in the core layers of the system less legitimate than innovation in social media apps? Boeing has no problem upgrading their engines every few years for better fuel efficiency. Why can they do that, whereas can't we do t…

> That isn't a definition of "fast moving" that I would use. It sounds like slow moving. Perhaps I didn't word it correctly. When you want to write the next WhatsApp, you don't have to start from scratch. The OS has been taken care of for you, and you can expect it to "just work". This solid foundation allows innovation to build on-top, at a rapid pace. If your foundation was constantly changing, you'd have to accoun…

> At the time, a lot of systems were written in pure assembler, and it took a long time to convince those guys that C was ready as a replacement for most tasks (and C changed dramatically in that time period).

Operating systems written in higher level languages go back all the way to the 60's, like Burroughs written in Extended Algol in 1961.

There were multiple other OSes written in variants of Algol and PL/I, before C was even an idea on its designers.

Only home micros were fully written in Assembly by the time C was getting used outside AT&T.

It is an urban myth spread by AT&T fanboys that C is the first system programming language.

Anyone that bothers to research the history of mainframes and operating systems will easily find documents of those systems, most of them written in higher level languages with more memory safe features than C has ever had.

Re: Cross-platform Rust rewrite of the GNU coreutils

#284

Earlier quoted context omitted.

> This is because, should it ever come down to it, we want to be able to ascertain that our implementation is completely original I appreciate that this is how it works today, but isn't that a completely outrageous idea? A well read, well travelled person will have seen countless things that will influence their future behaviours. It is not uncommon to completely forget a particular source of inspiration (sometimes w…

Yes, it is. This is an excessive level of caution which does not reflect the permissiveness of actual copyright law. However, there is the concept of "unintentional copying", which is effectively what you're describing, and which is still considered an infringement under copyright law, however it's very, very unlikely that such an argument would be used in court with regards to software, and even more unlikely that a…

A further complication for us is that the Mathworks is rich and amoral while GNU Octave is tiny and idealistic. If we ever become large enough for them to notice us, we have to make sure that we never give them the slightest argument in their favour. Should our code ever end up looking similar (similar variable names, similar structure), we have to be able to say that it's purely coincidental.

Re: Cross-platform Rust rewrite of the GNU coreutils

#285

Earlier quoted context omitted.

This is very very weak grounds for any sort of lawsuit. But if having glanced at GPL source code prevents implementing similar functionalities in an entirely different language, that's a pretty darn strong argument for me to never look at GPL code again.

> This is very very weak grounds for any sort of lawsuit. Not according to the lawyers who have advised us GNU Octave developers to never read Matlab source code.

Your lawyers are peddling FUD because they make money that way. "Hey, it looks like you need another legal agreement, can't be too safe!" The reality is that an "unintentional copying" claim against source code makes for a very weak lawsuit and it's close to unimaginable that such a case would even make it into a court room.

You're free to read whatever you like. Don't let anybody tell you otherwise.

Re: Cross-platform Rust rewrite of the GNU coreutils

#286

Though I like ideas behind Rust but the code is awful. If you look at the code you'll see a lot of misterious symbols (as in Perl) and strange constructs like wrap, unwrap, Arc etc. They make the code less readable. Also Rust doesn't have exceptions so you have to wrap almost any function call with let/match/Ok/Err. Ugly. I looked at one random file which turned out to be a `du' command implementation: https://github…

Just wrt the let/match/Ok/Err == ugly comment: I don't know Rust very well and I haven't looked very closely at the code in question, but why would Rust force you to wrap almost any function call with let/match/Ok/Err, though? I am assuming the issue at hand here is when you call function that returns a Result (if that's the name of the parent of Ok/Err)? Couldn't one let the return values 'flow up'? For example: if a function starts returning Results and you don't handle it on the level above, you start returning Results too... Also, I suppose there's ways of flattening results to avoid having nested Results (I would guess and_then does that based on its signature?)? In this scenario, you could argue that one now replaces match with map at every function call where you do not actually handle the Err and that this is ugly too, but the alternative is hoping that the caller happens to have read your source code (or have checked exceptions), which is, arguably (to be diplomatic), the case for unchecked-exceptions. Then what happens if you change the code and so on and so on...

This way lets you achieve something similar to checked-exceptions, and in addition to gain composability of Err (and the like), without adding another language construct (which a language without exceptions would have to do). Got a great deal of experience in other languages that does this, and it's worked out pretty good so far for at least for me once you get the hang of it (i.e. functional coding).

Where I am sitting, that would be a wise choice for Rust, at least if I am understanding it correctly, as it tries to be a safer alternative to other system languages. However, arguably (:), it is OK in dynamic languages or similar that aims trades in correctness for conciseness and, arguable (again :), speed of development to simply have unchecked-exceptions.

Also, it is possible I misunderstood your comment and/or how that code was ugly, in which case I hope the downvotes/replies won't be too harsh :)

EDIT: typo/clarity

Re: Cross-platform Rust rewrite of the GNU coreutils

#288

Earlier quoted context omitted.

Not sure why you're being downvoted. I don't see why we shouldn't be moving to languages like Rust given the chance, as C makes it far more difficult to write safe and correct code.

I expect it's because because the first part is essentially preaching to the choir, and because Richard Hipp very much disagrees with the second part[0] > Rewriting SQLite in Rust, or some other trendy “safe” language, would not help. In fact it might hurt. (see link for expansion on that matter, which is a question of tooling and testing) [0] http://blog.regehr.org/archives/1292#comment-18452

Frankly, SQLite is the exception that proves the rule.

For all the complexity of the SQL Language, and efficiency constraints SQLite needs to have, plus all the algorithms it has to implement, it still got a pretty well-defined task. It is not easy to transfer that experience to other systems. Say, your company's backend API. Completely different constraints.

It could still be the case that, had Rust existed when SQLite was being created, that it would have taken much less engineering effort. Which is the metric that matters, as given infinite manpower, you can write anything in any language.

I do agree that rewriting SQLite now, which is a very battle-tested piece of software, would probably do more harm than good. I bet people will still try, for fun if nothing else.

Re: Cross-platform Rust rewrite of the GNU coreutils

#289

Earlier quoted context omitted.

'Saying "well, Rust doesn't eliminate all bugs" is attacking a straw man.' This is itself a straw man. Follow the link to Mr. Hipp's comments and read them. He did not say this. That a programmer who has produced such high-quality and rigorously tested software as sqlite should be portrayed as either cavalier or naive about software quality is something I find profoundly mis-guided.

> This is itself a straw man. Follow the link to Mr. Hipp's comments and read them. He did not say this. "Rust doesn't eliminate all bugs" is a rephrased version of "Some well-formed rust programs will generate machine code that behaves differently from what the programmer expected." > That a programmer who has produced such high-quality and rigorously tested software as sqlite should be portrayed as either cavalier…

I was not aware of kcov or its basis bcov. Thanks for pointing those out.

However, a quick glance at the bcov source code leads me to believe that it only does source-line coverage, not branch coverage. So, unless my quick reading of bcov sources is mistaken, I couldn't test a Rust SQLite as well as I can test the existing SQLite because kcov/bcov is missing the ability to measure coverage of individual machine-code branch instructions, and the value I get from static analysis is much less than the value I get from branch-coverage testing tools.

That's not being pedantic, btw. The difference between source-line coverage and machine-code branch coverage is huge. The latter really is necessary.

Re: Cross-platform Rust rewrite of the GNU coreutils

#290

Earlier quoted context omitted.

> This is very very weak grounds for any sort of lawsuit. Not according to the lawyers who have advised us GNU Octave developers to never read Matlab source code.

Your lawyers are peddling FUD because they make money that way. "Hey, it looks like you need another legal agreement, can't be too safe!" The reality is that an "unintentional copying" claim against source code makes for a very weak lawsuit and it's close to unimaginable that such a case would even make it into a court room. You're free to read whatever you like. Don't let anybody tell you otherwise.

> Your lawyers are peddling FUD because they make money that way.

No, the SFLC works pro-bono.

> You're free to read whatever you like.

I wish that were true, but many current laws say otherwise. You do not sound like you are aware of those laws, so I take it you're not a lawyer. You're just hoping the world is as free as you say it is. I wish it were too, but we have to be pragmatic and work in the world we have while we strive for the world we want.

Post reply on HN