News for hackers. Stuff that matters.
Re:Rewrite Linux Kernel in Rust? by polygot on Saturday June 03, 2017 @10:14PM (#14479560)
This is an interesting idea, but probably won't work out because Linus (and other developers) may not want to transition away from the C language (see Linus's comments about not using C++.) I think it would be excellent to see Rust being used, but the implementation of replacing C with Rust could be very complicated, and Rust's benefits may not be directly visible when having to port/rewrite a lot of the components.
Re:Rewrite Linux Kernel in Rust? by ktta on Saturday June 03, 2017 @10:39PM (#14479631)
I mean, the advantages of C++ are complexity management and the downside is its abstractness which is what Linus' argument was about (It is a behemoth compared to C therefore easy to make mistakes).

Rust might prove to be a possible candidate because it can help with safety. This is a different rationale than what the argument for C++ was about, so we cannot say.

The bigger problem I see is how premature the Rust eco-system and understanding is. It needs to go quite a long way people people start believing in it and before the language is well understood by more than a niche group of people who learn it just out of interest.

Re:Rewrite Linux Kernel in Rust? by delhanty on Sunday June 04, 2017 @12:28AM (#14479879)
If there were a fork and the fork were to gain momentum it might be not be up to Linus.

A project like this might attract new developers because it might be less intimidating than joining the Linux kernel proper. There would also be the attraction of learning Rust in a very real world context.

edit:s/in/it

Re:Rewrite Linux Kernel in Rust? by Someone on Sunday June 04, 2017 @02:57PM (#14482910)
"A project like this might attract new developers because it might be less intimidating than joining the Linux kernel proper."

Quite possible, but for the new project to be successful, existing _users_ will have to see clear benefits. The only way I can see those "new developers, using Rust" make a better product than "current developers with sometimes decades of experience, using C" if those experienced developers currently create lots of ownership related bugs.

IMO, _any_ argument claiming the way forward is a (partial) rewrite in Rust should start with some estimate of the number of ownership related bugs in the current code base.

Re:Rewrite Linux Kernel in Rust? by nickpsecurity on Sunday June 04, 2017 @01:13AM (#14479995)
This is a good argument if a massive amount of effort was piled into this with lots of refactoring on top of it. Meanwhile, it doesn't have a snowball's chance in hell of accomplishing anything.
Re:Rewrite Linux Kernel in Rust? by delhanty on Sunday June 04, 2017 @02:46AM (#14480187)
The key for such a project being successful would be to set expectations low in defining what success was. Something like "a proof of concept of an experiment to rewrite small amounts of the Linux kernel in Rust".

One would fork Linux on GitHub, name it something other than Linux, and just have the existing branches track Linux.

Linus has stated that he isn't particularly interested in security bugs. Other people take a different view. Eg. [1], [2]

Another incremental step to improved security in Linux after a Rust fork might be to take the lessons learned to create a conservative set of Rust inspired extensions to C without all the hoariness of C++.

[1] https://news.ycombinator.com/item?id=2539839

[2] https://www.schneier.com/blog/archives/2015/11/linus_torvald...

edit 1: removed apparently dead link to original source http://lkml.org/lkml/2008/7/15/296

edit 2: clarify that one wouldn't use the name Linux for the fork

Re:Rewrite Linux Kernel in Rust? by nickpsecurity on Sunday June 04, 2017 @12:32PM (#14482269)
"One would fork Linux on GitHub, name it something other than Linux, and just have the existing branches track Linux"

That's already hard given how many commits go into Linux. One must always remember it's not just some volunteer project: most of the commits are by paid programmers working at companies. That's where the labor comes from. You'd need a lot of volunteers to keep up with the paid programmers. Even Linux itself couldn't achieve that. Hence, all the paid programmers working on it.

"might be to take the lessons learned to create a conservative set of Rust inspired extensions to C without all the hoariness of C++."

Now you're thinking on the right track. That sort of thing has been done multiple times at the compiler level where they automagically make C safe with a performance hit. Several teams did it at CPU level. These projects have been used on FreeBSD mostly but also Linux. The strongest one so far is CheriBSD on CHERI processor.

Alternatively, for a safer C that you're manually using, what you describe has already been designed and actually inspired Rust's safety model:

https://en.wikipedia.org/wiki/Cyclone_(programming_language)

It could be revived and improved if people wanted. It got nowhere with C programmers, though, in the past.

Re:Rewrite Linux Kernel in Rust? by delhanty on Monday June 05, 2017 @04:57AM (#14486172)
>It could be revived and improved if people wanted. It got nowhere with C programmers, though, in the past.

I guess the market will decide.

Ransomware will explode in the next few years.

If a big enough exploit gets pinned on Linux then sentiment could change and there could be a well-funded hard fork.

edit: saw this quoted on Twitter today (but can't recall where):

“Only a crisis - actual or perceived - produces real change. When that crisis occurs, the actions that are taken depend on the ideas that are lying around. That, I believe, is our basic function: to develop alternatives to existing policies, to keep them alive and available until the politically impossible becomes the politically inevitable.”

Milton Freidman

http://www.goodreads.com/quotes/110844-only-a-crisis---actua...

Re:Rewrite Linux Kernel in Rust? by delhanty on Monday June 05, 2017 @04:51AM (#14486152)
So we agree about something at least ;-)

Slight tangent: I started my programming career in 1989.

The product was Parasolid and the language was AGA - a C inspired language that preceded C++.

I vaguely remember the following extensions:

* built in logging with Undo

* overloaded operators leading to vector and interval types that worked better than C++

* a proper module system

Re:Rewrite Linux Kernel in Rust? by nickpsecurity on Monday June 05, 2017 @11:40AM (#14488373)
Interesting. Never heard of it. The main safe language from that time was Ada. It's been updated regularly. The neat thing about it is how it was systematically designed to mitigate errors in about every operation.

http://www.adacore.com/knowledge/technical-papers/safe-and-s...

There's also a variant called SPARK that can automatically prove the absence of errors like buffer overflow in a way that would normally take a theorem prover.

https://en.wikipedia.org/wiki/SPARK_(programming_language)

Re:Rewrite Linux Kernel in Rust? by delhanty on Wednesday June 07, 2017 @02:34PM (#14508754)
>Interesting. Never heard of it.

You wouldn't of. It was developed internally to write Parasolid. Probably they still use it - several of the original devs are still there 30 years later.

Re:Rewrite Linux Kernel in Rust? by nickpsecurity on Wednesday June 07, 2017 @09:11PM (#14511159)
IBM did that with PL/S. It was a system version of PL/I with no runtime and ability to decide how a function was compiled via annotations in that function. Kept getting updated but no public release. Here's a few more that you might find interesting for general usage that were proprietary or started internal:

http://www.semdesigns.com/Products/Parlanse/index.html

https://web.archive.org/web/20130303055647/http://www.founda...

https://en.wikipedia.org/wiki/Pike_(programming_language)

https://en.wikipedia.org/wiki/Roxen_(web_server)

Parlanse is used in Semantic Designs' powerful toolkit. Flow was used to make a Spanner competitor, FoundationDB, that was good enough in some way for Apple to buy & pull off the market. Pike was used to build Roxen server that had significant advantages in its time period. A number of companies also used LISP and REBOL for their advantages with at least one asking LispWorks to do a real-time implementation for telecom or something. So, usually it pays to go with a common, often-crappy language with its ecosystem. However, doing one's own language with competitive edge does pay off at times. I think these days one can just do a DSL in Racket or Haskell on top of main language to negate benefits of totally rolling own stuff. People got far with it, though. Galois is on a roll with that in high-assurance systems with this as an example:

https://ivorylang.org/ivory-introduction.html

So, just some fun examples of homebrew for you in return. :)

Re:Rewrite Linux Kernel in Rust? by geezerjay on Sunday June 04, 2017 @03:54AM (#14480344)
> Meanwhile, it doesn't have a snowball's chance in hell of accomplishing anything.

That's only true if you believe that the only possible accomplishment is to become the #1 kernel in the world.

Meanwhile, it's a very interesting project and it's a clear proof of technical proficiency. There are not many people in the world who can claim that they've written a kernel, let alone one in a cutting-edge programming language like Rust. I would love to have something like that on CV. Meanwhile, criticizing other people's projects does nothing to advance your career.

Re:Rewrite Linux Kernel in Rust? by nickpsecurity on Sunday June 04, 2017 @12:28PM (#14482249)
"Meanwhile, it's a very interesting project"

I was responding to a comment about doing the whole Linux kernel, not the original project. The original project makes sense. You gave another, good reason for that.

"Meanwhile, criticizing other people's projects does nothing to advance your career."

Professors grading things, peer review of research, managers reviewing performance, consumer organizations reviewing products... there's a lot of reasons that statement is wrong. I try to critique with an alternative solution presented and citations for both statements where possible. In the Linux case, I've often recommended tech at hardware and compiler level that automatically makes C code safe some of which have been used on FreeBSD and Linux. Alternatively, running it as a VM on top of a secure microkernel with security-critical apps running outside the VM.

Re:Rewrite Linux Kernel in Rust? by shmerl on Saturday June 03, 2017 @11:33PM (#14479763)
Rust doesn't have downsides of C++ by design.
Re:Rewrite Linux Kernel in Rust? by jfoutz on Sunday June 04, 2017 @01:58AM (#14480081)
Yet. I like rust. It has a deep, thoughtful approach to many problems. But, C++ is pretty long in the tooth. Of course it's weird and inconsistent. Give rust 30 years to really entrench itself as a systems language. It'll be wierd also.
Re:Rewrite Linux Kernel in Rust? by paulddraper on Saturday June 03, 2017 @11:39PM (#14479774)
And GNU Herd weren't on board with creating a monolithic kernel.

So what? It got built.

Re:Rewrite Linux Kernel in Rust? by wangii on Sunday June 04, 2017 @05:21AM (#14480503)
you mean GNU HURD?
Re:Rewrite Linux Kernel in Rust? by paulddraper on Sunday June 04, 2017 @01:57PM (#14482616)
Yeah. Dang English phonetics.