Live data from Hacker News

Rewrite Everything in Rust

robert.ocallahan.org

211–220 of 242 posts

Re: Rewrite Everything in Rust

#211
post #201

Earlier quoted context omitted.

The most recent one off the top of my head is the ? syntax RFC, which should reduce the amount of error-handling boilerplate. The big ones though are: * Specialization. This will allow you to write ultra-performent generic code by special-casing when you have the knowledge. It also will be a building block for the next few features. * The bag of features colloquially known as "inheritance", though that's not really a…

Great. They all look great. The ones like higher kinded types are the ones that I am highly suspicious of. The typical C programmer who pokes around hardware data sheets and writes drivers and stuff will likely not pay much attention to Rust if such complex features are added. Also features like that makes me wonder if you folks are really targeting C/System programmers. Sorry if I sound negative, that isn't my inten…

Systems programming does not preclude a language from having a good type system or higher level abstractions.

A good example is Phil's OS. http://os.phil-opp.com/. He's designing an operating system in Rust, and it has surprisingly few "unsafe" parts. The rest of it is made safe using some neat zero-cost abstractions.

Higher kinded types isn't going to happen anytime soon. It's something that crops up often in discussions when people want to model something complicated with the type system; but it's a very nontrivial feature that would probably need to wait for Rust 2.0, if ever. Even if it would exist, you can just not use it. Like most of the other features being added.

Re: Rewrite Everything in Rust

#212
post #91

Earlier quoted context omitted.

For most applications, moving to modern C++ is going to be a better option than rewriting in Rust. I wouldn't bet on that. Companies which go with a language like C++ don't do it for "safety" or "performance" or reasons like that (at least, most of the time they don't). They go with it because they can get something written once, then run it for the next half-century and only have to spend engineering time on new fea…

Who rewrote in Lua instead of Python?

Judging from comments I've seen here in discussions about Python 3, mostly companies who bet on a "write once, run forever" strategy and thought Python would never change.

Re: Rewrite Everything in Rust

#213
post #91

Earlier quoted context omitted.

Who rewrote in Lua instead of Python?

Judging from comments I've seen here in discussions about Python 3, mostly companies who bet on a "write once, run forever" strategy and thought Python would never change.

Should have used C++ if they wanted that :D

Re: Rewrite Everything in Rust

#214

Earlier quoted context omitted.

I think what GP is saying that you'll have problems in logic or other typical programming problems and that it isn't a lack of language features/safety but rather time/money being thrown at these libraries I imagine the top two reasons unsafe memory access happen is: 1) other complicated logic seeped into the memory sensitive area or causes programmer fatigue 2) memory management is hard Rust helps with #2 but let's…

Re: amount of low level code needing unsafe blocks, its worth checking out this series that documents creating a bare metal kernel in rust that has lots of type safety and uses shockingly little assembly or unsafe: http://os.phil-opp.com/

C created this wrong perception that you need lots unsafe code, due to how it does strings and vectors.

In all safe alternatives to C, just like Rust sure you need unsafe at the Assembly FFI level and hardware integration like IO ports and interrupt handling.

But everything else can be just plain safe code.

Re: Rewrite Everything in Rust

#215
post #70

Earlier quoted context omitted.

Iteration is not bad. Iteration without progress is bad. Which one do you think would happen?

I am suggesting that the problem is elsewhere - and more philosophical. I understand for many very young kids learning JavaScript was the only accessible way to do programming. Yet they are producing way worse stuff than previous generations unfortunately (remember Scandinavian demos in the 90s?), as their platform of choice is seriously limited. Now the article mentions horrible things in code developed over decades…

"But maybe we need completely different approach to get out of local optima technology seems to be right now."

So your problem is not that a Rust rewrite would be too much of a change. It's that it would be too little? ;)

If there is any popular low-level language that is a "completely different approach", I'd say that language is Rust.

Re: Rewrite Everything in Rust

#216

Earlier quoted context omitted.

Part of what makes Rust awesome is it forces correct ownership and architecture.

> Part of what makes Rust awesome is it forces correct...architecture. If you believe that, and follow it, then you will end up with a lousy architecture. A correct architecture cannot be designed without knowledge of the problem domain. That's the problem with security too: if you believe the language will keep you safe, and stop thinking about security, your software will be less secure than before. There's plenty…

> That's the problem with security too: if you believe the language will keep you safe, and stop thinking about security, your software will be less secure than before.

And if you use "it won't be perfectly secure under X mitigation strategy" as an excuse to avoid doing X, your software will also be less secure.

Re: Rewrite Everything in Rust

#217
post #70

Earlier quoted context omitted.

I am suggesting that the problem is elsewhere - and more philosophical. I understand for many very young kids learning JavaScript was the only accessible way to do programming. Yet they are producing way worse stuff than previous generations unfortunately (remember Scandinavian demos in the 90s?), as their platform of choice is seriously limited. Now the article mentions horrible things in code developed over decades…

"But maybe we need completely different approach to get out of local optima technology seems to be right now." So your problem is not that a Rust rewrite would be too much of a change. It's that it would be too little ? ;) If there is any popular low-level language that is a "completely different approach", I'd say that language is Rust.

Yes, too little ;-)

Frankly, Rust just takes a few different approaches known since "forever" and promotes them to 1st class semantic citizens. Similarly Go takes another set. Like every language in existence. So some things will be super easily expressible in one or another language, other things more obfuscated. Yet you could do the same in older ones, but perhaps more verbosely, with more syntactic sugar or boilerplate structures. Hence the comparison to a genetic algorithm with a few mutations in each generation. All a variation of the same set of mental constructs, possibly with very similar descriptive abilities (even when leaving Turing completeness out of the equation).

Re: Rewrite Everything in Rust

#218

Earlier quoted context omitted.

For step 0, look at Rust's libc crate. For step 1, you'd need to carefully look at glibc's ABI, which is even more complicated than its API due to backward compatibility and symbol versioning.

Yeah ABI compatibility might be problematic, my currently plan is to LD_PRELOAD what I have to test it for speed. I have the feeling that rust could mock the ABI and serve as a general replacement, but first things first is it even fast enough to use at the lowest levels of the system.

If it's not, please file bugs. It should be.

Re: Rewrite Everything in Rust

#219
post #196

Earlier quoted context omitted.

> I'm saying that if you look at the larger use case you can design your code in idiomatic Rust to avoid it. As I said, may be you can, but it's far from trivial and unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on. You yourself said above, that it's hard. And unlike languages like C++ where OOP approaches are very well doc…

> You yourself said above, that it's hard. I said modeling single inheritance is hard. That's a very niche use case; basically only crops up when writing an interpreter for a language with single inheritance (and in cases like Servo's DOM) > unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on Again, it's not a thing that you d…

I don't mean one has to copy ideas from C++ or Java to Rust verbatim, but having some explanation on how to use Rust OOP abstractions for solving common programming problems would be useful. I don't think current Rust documentation covers that well.

Re: Rewrite Everything in Rust

#220
post #219

Earlier quoted context omitted.

> You yourself said above, that it's hard. I said modeling single inheritance is hard. That's a very niche use case; basically only crops up when writing an interpreter for a language with single inheritance (and in cases like Servo's DOM) > unless you know how to do it already, coming up with such approaches isn't something that one who just learns the language would be focusing on Again, it's not a thing that you d…

I don't mean one has to copy ideas from C++ or Java to Rust verbatim, but having some explanation on how to use Rust OOP abstractions for solving common programming problems would be useful. I don't think current Rust documentation covers that well.

Ah, fair.
Post reply on HN