News for hackers. Stuff that matters.
Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @10:15AM (#18406764)
Nim produces smaller binaries, has zero-pause, realtime gc (and you can even define gc behavior) and compiles to optimized C. It's a win over Rust in every way including ease of use. Big issue with Nim is tribalism, pure and simple. It's author failed to get any major corporations behind it so it doesn't get hyped up in constant Medium articles and conference talks and therefore does not get a lot of attention, which keeps it a niche language, sadly.
Re:Writing Network Drivers in Rust [pdf] by the_duke on Thursday November 08, 2018 @11:03AM (#18407165)
Nim is a lovely language but I disagree with most of your points.

* The Rust borrow checker prevents a lot of issues in C(++) code. Including thread safety. Nim does not provide anything new in this regard.

* The lack of a GC is a feature, not a detriment. One of the reasons why Rust applications are often very fast is because the language naturally guides you to avoid allocations when possible and allows low level control where necessary. Combined with the safety guarantees of the borrow checker, this is a powerful combination. This is possible in Nim but using GC is easier and will be the preferred solution when in doubt.

* While Mozilla support does help a lot for sure, a lot of the hype around Rust (imo) comes from people trying it out, just falling in love with and then promoting it

Re:Writing Network Drivers in Rust [pdf] by dom96 on Thursday November 08, 2018 @03:43PM (#18409809)
> The Rust borrow checker prevents a lot of issues in C(++) code. Including thread safety. Nim does not provide anything new in this regard.

Actually Nim does offer something new in this regard. See https://nim-lang.org/docs/manual.html#guards-and-locks.

> While Mozilla support does help a lot for sure, a lot of the hype around Rust (imo) comes from people trying it out, just falling in love with and then promoting it

AFAIK Rust was a much different language before Mozilla officially adopted it (wasn't the borrow checker implemented after Mozilla sponsorship?). So not only was it not the same language, it wasn't known at all. Don't underestimate the power of full-time developers working on a programming language and having the support of a well known organisation behind them.

Sadly a lot of the hype is simply "omg, Mozilla uses this langauge" or "omg, Google uses this language".

Re:Writing Network Drivers in Rust [pdf] by tathougies on Thursday November 08, 2018 @05:09PM (#18410504)
Nim is garbage collected, which means it doesn't need borrow checking. Garbage collection in threaded languages is a well studied problem. Safe threading in a statically collected language is new.
Re:Writing Network Drivers in Rust [pdf] by imtringued on Thursday November 08, 2018 @06:04PM (#18410875)
This is clearly a better solution compared to the average language but what if you forget to mark a field or object as guarded?

Just take a look at the basic problem of multi-threading: two threads write to the same memory location. This situation is unpredictable and there never allowed to happen. There are three general strategies to deal with this: immutability, mutexes and linear types to ensure there is only one reference with write capability.

The latter makes writing code that is not thread-safe impossible at compile time without sacrificing efficiency and is used by at least two programming languages that I know of: Ponylang and Rust. For me impossible vs "oops forgot to guard it" are worlds apart. The compiler will inform you that it is not thread-safe and then you can decide to use a different solution like a mutex if necessary.

Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @11:35AM (#18407462)
<< While Mozilla support does help a lot for sure, a lot of the hype around Rust (imo) comes from people trying it out, just falling in love with and then promoting it >>

If there was no rampant tribalism, my comment would not be buried with negative votes. It would receive a response like the one you gave, which is subjective, and that would be the end of it. Some may even up-vote it because diversity is always good. But feels like Rust users are zealous and it's a bad sign, tbh. Wouldn't want to be part of a community that acted with hostility towards others for presenting alternative view points.

Re:Writing Network Drivers in Rust [pdf] by Majestic121 on Thursday November 08, 2018 @12:34PM (#18408018)
I think you're getting downvote because you're being very tribal about Nim, and apparently not open for discussion : "It's a win over Rust in every way including ease of use."

You can paint others opinion as being subjective, which they are, but you would be wise to realize yours are as well. That's what's bringing hostility, not the diversity of viewpoint (there's a lot of talks about Go in the thread for example)

Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @12:46PM (#18408133)
Yes, true.
Re:Writing Network Drivers in Rust [pdf] by the_duke on Thursday November 08, 2018 @12:30PM (#18407992)
You were downvoted because your claims were not substantiated by factual analysis.

Rather, your comment seemed rather "tribal" while criticizing Rust fans of the same.

Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @12:46PM (#18408136)
True.
Re:Writing Network Drivers in Rust [pdf] by the_duke on Thursday November 08, 2018 @12:54PM (#18408230)
Cheers for owning up to it.

BTW, I would see Nim more as a competitor to D, Swift and Java than to Rust.

Re:Writing Network Drivers in Rust [pdf] by kungtotte on Thursday November 08, 2018 @01:56PM (#18408842)
I think Nim absolutely has a place competing with Rust too.

It has several tunable GCs allowing for great flexibility there, and also supports running with no GC at all. It compiles to C that will compile nearly anywhere C does. It produces smaller binaries, and it can easily link against musl instead of libc for an even lighter footprint. It's also safe like Rust is, and the compiler will help you catch a ton of errors.

That's not to say that it's competitive at this point in time. It's much more unstable as a language due to not reaching 1.0 yet. They only just (August) received any real kind of funding, allowing them to hire on a new developer but it's still just a handful of core devs and some dedicated contributors. The standard library and the community repo (Nimble) can't compare with Rust's and Cargo in terms of package availability and support.

Re:Writing Network Drivers in Rust [pdf] by bluejekyll on Thursday November 08, 2018 @07:06PM (#18411240)
> it can easily link against musl instead of libc for an even lighter footprint

I'm not sure if you were implying that it doesn't, but Rust also supports musl:

    $> rustup target list | rg musl
    aarch64-unknown-linux-musl
    arm-unknown-linux-musleabi
    arm-unknown-linux-musleabihf
    armv5te-unknown-linux-musleabi
    armv7-unknown-linux-musleabihf
    i586-unknown-linux-musl
    i686-unknown-linux-musl
    mips-unknown-linux-musl
    mipsel-unknown-linux-musl
    powerpc64le-unknown-linux-musl
    x86_64-unknown-linux-musl
Re:Writing Network Drivers in Rust [pdf] by kungtotte on Friday November 09, 2018 @11:33AM (#18415630)
I apologize if I worded my post weirdly. It was a list of things that make Nim a competitor to Rust, not things that Nim does that Rust doesn't.

There's a fair bit of overlap for obvious reasons: they're two languages suited for the same tasks, after all :)

Re:Writing Network Drivers in Rust [pdf] by karavelov on Thursday November 08, 2018 @09:25PM (#18411934)
mrustc [1] compiles rust to optimized C also.

1. https://github.com/thepowersgang/mrustc

Re:Writing Network Drivers in Rust [pdf] by skocznymroczny on Friday November 09, 2018 @05:47AM (#18413608)
Nim, D and Rust are in the same league, as a "C/C++ replacement"
Re:Writing Network Drivers in Rust [pdf] by grogers on Thursday November 08, 2018 @11:14AM (#18407252)
https://nim-lang.org/docs/gc.html

> Tests show that a 2ms max pause time will be met in almost all cases on modern CPUs (with the cycle collector disabled).

So in a reduced mode, pause times are only bounded by 2ms. Not sure how you could say that is zero pause

Re:Writing Network Drivers in Rust [pdf] by monocasa on Thursday November 08, 2018 @01:51PM (#18408801)
The GC guys love doing that for some reason. Azul's "pauseless" GC only guaranteed 10ms pause times.
Re:Writing Network Drivers in Rust [pdf] by jononor on Thursday November 08, 2018 @01:05PM (#18408339)
Certainly not zero, but probably enough for hitting the frame deadline for 60fps graphics (16ms). Could even enough for real-time audio processing (at 4ms or 8ms). That will cover the vast majority of latency requirements that application developers using an OS deals with.

Some embedded realtime cases might have more strict deadline requirements, or be complicated by the potential jitter that a GC might intoduce. Eg most discrete math used in motor control systems assumes a fixed sample period.

Re:Writing Network Drivers in Rust [pdf] by chc on Thursday November 08, 2018 @01:56PM (#18408856)
I haven't done game dev beyond hobbyist level, but 12.5% of your total budget for a frame seems pretty significant. Is that kind of percentage hit generally considered negligible?
Re:Writing Network Drivers in Rust [pdf] by Kaveren on Thursday November 08, 2018 @02:59PM (#18409421)
60 FPS is not enough, many people have monitors with much higher refresh rates (120 hz, more). You have virtual reality which basically requires a higher refresh rate than 60 FPS to begin with. Using a runtime component for garbage collection is highly sub-optimal.

Rust is possibly an ideal language for game development. Standard Rust has no runtime component, which is perfect. It's also a high-performance language.

The ecosystem for Rust game development is immature, but there's progress being made.

Re:Writing Network Drivers in Rust [pdf] by majewsky on Thursday November 08, 2018 @06:57PM (#18411170)
Standard Rust absolutely has runtime components. Otherwise a "Hello World" would not compile into several 100 KiB of binary. (Not saying that that's bad, just that this is how it is.)
Re:Writing Network Drivers in Rust [pdf] by bluejekyll on Thursday November 08, 2018 @07:12PM (#18411283)
I haven't looked since, but jemalloc I believe was a significant cost in this. Recently there was a change merged in to use the system allocator by default:

https://www.reddit.com/r/rust/comments/9twam5/jemalloc_was_j...

Re:Writing Network Drivers in Rust [pdf] by red75prime on Thursday November 08, 2018 @10:49PM (#18412199)
It has runtime as in "C runtime", that is the code which runs before and after `main` and the code of standard library. It doesn't have runtime as in "Java runtime" (or "C# runtime") that includes the code that runs alongside your code (garbage collection thread).
Re:Writing Network Drivers in Rust [pdf] by Kaveren on Friday November 09, 2018 @01:07AM (#18412645)
Yes, I was loose in my use of the term "runtime" and sacrificing correctness. Writing "runtime component" rather than "runtime" makes it more misleading. I probably should've worded my original comment more wisely.
Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @12:52PM (#18408208)
Sorry, within 2ms not absolute 0, but to me it might as well be zero I've yet to notice it in practice.
Re:Writing Network Drivers in Rust [pdf] by mkl on Thursday November 08, 2018 @04:52PM (#18410381)
For a network driver, 2ms seems enormous. At 1Gbps that's 250 kilobytes, which is an awful lot of packets.
Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @05:03PM (#18410469)
But GC doesn’t run continuously! Sure, device drivers and kernel modules should be built in C. Everything else is an approximation.
Re:Writing Network Drivers in Rust [pdf] by dom96 on Thursday November 08, 2018 @03:36PM (#18409748)
I appreciate your enthusiasm for Nim, but even I (as a Nim core dev) wouldn't say that Nim is better than Rust in every way.

Trying to promote Nim like you are doing might in fact have the opposite effect :/

Re:Writing Network Drivers in Rust [pdf] by discoball on Thursday November 08, 2018 @04:55PM (#18410414)
Appreciate your work on Nim.

My statement is based on my opinion. There are certainly imperfections in Nim even bugs and things that annoy me but the mental load is far less than working in Rust, for me that is, and so to me it is better in every way since in the end I find it to be congruent with my mental model whereas I can’t say the same about Rust. It is a purely opinionated statement like everything else where meaning is involved. We are the meaning makers. It doesn’t exist in detached form.

Your opinion is valid.

Re:Writing Network Drivers in Rust [pdf] by palotasb on Thursday November 08, 2018 @10:43AM (#18407023)
In every way? One could argue that having a GC is a disadvantage compared to Rust regardless of how good a GC it is. Main reason for that is because it might still introduce unnecessary runtime overhead.
Re:Writing Network Drivers in Rust [pdf] by tcoff91 on Thursday November 08, 2018 @10:57AM (#18407118)
Also what about the data race detection stuff that rust does? A GC does not stop data races.
Re:Writing Network Drivers in Rust [pdf] by nimmer on Thursday November 08, 2018 @10:56AM (#18407109)
It does not.
Re:Writing Network Drivers in Rust [pdf] by monocasa on Thursday November 08, 2018 @01:53PM (#18408819)
GCs absolutely increase memory pressure overhead, or are so conservative that they practically lead to slow leaks. You have to keep that metadata of "what is and isn't a pointer" somewhere and that comes with a cost.
Re:Writing Network Drivers in Rust [pdf] by nimmer on Friday November 09, 2018 @10:07AM (#18414886)
Memory pressure is a different thing. And, once again, GC is optional.
Re:Writing Network Drivers in Rust [pdf] by monocasa on Friday November 09, 2018 @12:43PM (#18416260)
> Memory pressure is a different thing.

No it isn't. The GC has to touch that data, which means it's cache pressure, which means it's perf pressure.

> And, once again, GC is optional.

Sure, but it's an exclusive choice between memory safety and speed. Other languages let you have your cake and eat it too in that respect (Cyclone, Rust, etc.).