News for hackers. Stuff that matters.
Re:Next steps for Rust in the kernel by WiSaGaN on Wednesday September 21, 2022 @08:58AM (#32924459)
Any historical background for the reference of Perl by Torvalds?
Re:Next steps for Rust in the kernel by dijit on Wednesday September 21, 2022 @09:01AM (#32924504)
Perl is notorious for being "write only".

As in: keeping it clean and well structured is impossible and the impressive flexibility of the language is huge downside on larger projects.

I feel qualified to say such things as I've worked on a billion-line perl codebase before.

Re:Next steps for Rust in the kernel by belter on Wednesday September 21, 2022 @10:27AM (#32925622)
Shudder in horror.... "Booking.com uses the Perl programming language heavily across its entire technical infrastructure." - https://medium.com/booking-com-development/a-faster-perl-run...
Re:Next steps for Rust in the kernel by klabb3 on Wednesday September 21, 2022 @11:57AM (#32927049)
Dad, let's go home. Please.
Re:Next steps for Rust in the kernel by User23 on Wednesday September 21, 2022 @01:02PM (#32928034)
> Perl is notorious for being "write only".

> As in: keeping it clean and well structured is impossible and the impressive flexibility of the language is huge downside on larger projects.

Perl gets quite unfairly picked on here, to the point where it's basically a meme. It's not like, just to pick a somewhat popular language, Ruby doesn't provide plenty of ways to write completely unreadable code that can only be understand by running it through irb, if even then.

I agree that there is plenty of bad Perl code out there, but there's plenty of bad code in any language that achieves general popularity for a time. Disciplined use can produce perfectly clear and readable code and the module system is perfectly adequate for separation of concerns.

The language does give you an absurd amount of rope to hang yourself with though. If I were managing a large Perl project today I'd have an extremely restrictive style guide and would enforce as much of it as possible via pre-commit hooks.

> I feel qualified to say such things as I've worked on a billion-line perl codebase before.

For a language that permits such densely expressive code, that's appalling. I'm so sorry.

Re:Next steps for Rust in the kernel by singhrac on Wednesday September 21, 2022 @01:08PM (#32928121)
I’ve worked on a Perl codebase written by a good programmer and had the pleasure of starting the port over to Python.

This was surprisingly doable? Marshaling/unmarshaling Perl objects into Python ones isn’t difficult these days, and you can run Perl code via FFI so the transition can be piecemeal.

I have no opinions on Perl as a language (some constructs / patterns felt a bit hard to think about, but I’m far from an expert), but ultimately it’s a high level language and has been left behind tooling wise to another high level language, so it’s time to move. For us, one motivator was that having a large legacy Perl codebase (even one running well for years) hurt recruiting.

Re:Next steps for Rust in the kernel by bogeholm on Wednesday September 21, 2022 @09:07AM (#32924608)
_one billion lines of Perl_? Wow
Re:Next steps for Rust in the kernel by umanwizard on Wednesday September 21, 2022 @09:29AM (#32924872)
I suspect that person worked at Amazon. They at one point had gigantic amounts of Perl before they started slowly replacing it with Java. (I wouldn't be surprised if they still had sizable amounts of Perl in dark corners).
Re:Next steps for Rust in the kernel by Cthulhu_ on Wednesday September 21, 2022 @09:47AM (#32925096)
I can imagine corporate Java codebases can end up in the billion LOC as well. I mean it MIGHT be easier to read, or easier to find developers for...

I feel like - opinion, not based in fact, I've never worked on any codebase >1M LOC - the only way you can keep a codebase like that maintainable is by very strict code style and architecture rules - e.g. no functional programming, no feature X, no feature Y, strict code style rules, strict architecture rules, etc.

Re:Next steps for Rust in the kernel by gautamdivgi on Wednesday September 21, 2022 @10:03AM (#32925310)
Ha ha no. Sorry to disappoint :)

Personal experience. We have some java code from 15-17 yrs back. About the time “design patterns” and all the other “pattern” stuff was big in everyones mind. It’s a mess of abstraction for simple tasks. Couple all that with the fact that class instantiating is possible via reflection and at this point people maintaining it have kinda given up. It works - don’t touch it.

This isn’t an indictment of Java. Just resume driven design.

Re:Next steps for Rust in the kernel by rhacker on Wednesday September 21, 2022 @11:26AM (#32926485)
That's why I left Java 5 years (after like a 12 year career in it) ago and plan on never getting another Java job. It's just making classes have "some" kind of use no matter what the task is, there's no coding to solve problems, it's coding to make structure.
Re:Next steps for Rust in the kernel by gautamdivgi on Wednesday September 21, 2022 @12:03PM (#32927141)
To be fair, I’ve seen this in c++ as well. Building an entire structure of classes like “java” and then using “design patterns” on those abstractions. All to implement a simple 7 step socket communication protocol. It was a “wtf is going on here moment”?
Re:Next steps for Rust in the kernel by rhacker on Thursday September 22, 2022 @04:10PM (#32944002)
I was also part of it. I did my own share of - well if we design it this way then we can have a second "type" that does X with the same interface. And it just keeps on iterating like that. It's still a useful pattern, but often at least in my own case, overused for really trivial stuff.

Programmers are highly trained like to see the world as if everything can be cast the same way. While that IS a good way to see a large variety of software problems, when you isolate down to a companies' use cases, it quickly goes away in the pragmatic sense. It then becomes something the company is paying for because they chose Java and Java developers like that sort of thing.

Re:Next steps for Rust in the kernel by nkozyra on Wednesday September 21, 2022 @09:42AM (#32925036)
There's a spirograph guy in the corner, the only one left that knows perl, lurking out and trying to entice people with its merits.

Long ago I worked primarily in perl and ... yeesh, I recognize maybe 30% of it when looking, and that's the directly-c-adjacent stuff.

To be fair if I walked away from Rust for a year I'd probably be similarly lost.

Re:Next steps for Rust in the kernel by dhosek on Wednesday September 21, 2022 @10:44AM (#32925889)
I still will reach for Perl for the occasional quick one-of text-processing application, but I do spend a lot of time in perldoc when I do.
Re:Next steps for Rust in the kernel by thesuperbigfrog on Wednesday September 21, 2022 @10:46AM (#32925923)
>> I suspect that person worked at Amazon. They at one point had gigantic amounts of Perl before they started slowly replacing it with Java.

The Amazon retail website (amazon.com and related versions for various countries) used the Perl Mason templating system (https://masonbook.houseabsolute.com/) to allow various teams to build web site components in a performant and secure way.

It worked quite well since it ran quickly and isolated components so that only one small change could be made without breaking other components.

Re:Next steps for Rust in the kernel by VyseofArcadia on Wednesday September 21, 2022 @10:29AM (#32925652)
With Java? I usually think of Perl as a glue language, like bash scripting. Java would not be my choice to glue components together.
Re:Next steps for Rust in the kernel by dhosek on Wednesday September 21, 2022 @10:42AM (#32925871)
Nah, Perl can be a perfectly fine applications language. Some things get kind of ugly with it (object-orientation is notoriously hacky and there are two different approaches to classes that take inverse (literally) approaches to how to represent the objects in terms of Perl’s scalars, arrays and maps. It does suffer a bit from being an early mover so there are questionable choices like the fact that library code is traditionally installed system-wide so good luck if application A needs library v3 an application B needs v2 and v2 and v3 have some subtle incompatibility, but Perl is no less capable than Python and arguably more capable than PHP, both of which have plenty of applications written in them.
Re:Next steps for Rust in the kernel by umanwizard on Wednesday September 21, 2022 @11:34AM (#32926593)
Perl was the primary application-layer language at Amazon. It was used for most things that didn't need to be in a low-level language for performance or other reasons (for those, C++ was used instead).
Re:Next steps for Rust in the kernel by twic on Wednesday September 21, 2022 @11:49AM (#32926869)
Could have been worse. Could all have been on one line.
Re:Next steps for Rust in the kernel by LinuxBender on Wednesday September 21, 2022 @10:36AM (#32925785)
I've often found I could work around the "write only" mantra using perltidy. I pass other peoples code to perltidy with the flags that match my style, make changes, then pass it back through perltidy to match the author as close as I can. I try to encourage others to do the same.
Re:Next steps for Rust in the kernel by hardware2win on Wednesday September 21, 2022 @09:37AM (#32924963)
Bilion lines?

What, how?

Thats bigger than windows linux llvm chromium and 5 other compilers combined according to google

Re:Next steps for Rust in the kernel by dijit on Wednesday September 21, 2022 @09:39AM (#32924983)
Commentary on that was made at the time.

Linux is a pretty small codebase compared to most proprietary codebases in large companies to be fair though.

Re:Next steps for Rust in the kernel by angrygoat on Wednesday September 21, 2022 @10:55AM (#32926052)
Yeah, this – it's easy to forget that infrastructure code (Linux, libc, openssl, ...) really is the tip of the iceberg. Industrial codebases are often at least an order of magnitude bigger; really, that shouldn't surprise us: there are so many problems to be solved, it should be unsurprising that the specific outweighs the general.
Re:Next steps for Rust in the kernel by mschuster91 on Wednesday September 21, 2022 @09:01AM (#32924513)
There once was a time when the only common things you could expect to be present on a Linux system were the good old `sh` (not `bash`) and a more or less old version of `perl`.

The commands supported by `sh` are... let's keep it at "fossilized from somewhere in the 80s", and so the only alternative was perl which has a ... history of being not exactly user-friendly to code for.

Re:Next steps for Rust in the kernel by marcus0x62 on Wednesday September 21, 2022 @11:23AM (#32926430)
Eh? Bash predates Linux by a couple of years. I don’t remember any early Linux system — my frame of reference begins in 1994 — without bash as the default shell.
Re:Next steps for Rust in the kernel by mschuster91 on Thursday September 22, 2022 @04:19AM (#32936145)
The common Debian expectation to this day is to keep acting like you only had POSIX shell features aka /bin/sh [1]. You may use /bin/bash if you like though.

[1] https://www.debian.org/doc/debian-policy/ch-files.html#s-scr...

Re:Next steps for Rust in the kernel by marcus0x62 on Thursday September 22, 2022 @04:30PM (#32944230)
That may be their expectation stylistically, but the first Debian release shipped[1] with bash as the default shell. I’m not aware of them ever having shipped the original Bourne shell. Your claim — that I was responding to - was that on early Linux systems you might only find the Bourne shell but not bash. That simply was not the case.

1 - http://archive.debian.org/debian-archive/debian/dists/buzz/m...

Re:Next steps for Rust in the kernel by edgyquant on Wednesday September 21, 2022 @02:12PM (#32928965)
Linux was built out initially with a hard coded call to bash
Re:Next steps for Rust in the kernel by edgyquant on Wednesday September 21, 2022 @02:12PM (#32928977)
This is wrong, initially Linux was quite literally a bash kernel
Re:Next steps for Rust in the kernel by werdnapk on Wednesday September 21, 2022 @09:07AM (#32924603)
Perls big moto of TMTOWTDI always bugged me and I thought it was more of a negative than a plus which led to it being known for write-only code.
Re:Next steps for Rust in the kernel by chc on Wednesday September 21, 2022 @11:23AM (#32926425)
Rust is not so different from Perl in this regard — there are many ways to do practically everything. Do you want an argument that implements a trait? Cool, just use a generic with a trait bound (either specified as `<T: Trait>` or `<T> where T: Trait`). Or type the argument as `impl Trait`. Or take a `Box<dyn Trait>`.
Re:Next steps for Rust in the kernel by a1369209993 on Wednesday September 21, 2022 @03:48PM (#32930562)
I'm not particularly fluent in Rust, but at least several of those express meaningful differences in what you're doing, not just how. Eg are you promising to deallocate and otherwise clean up the object when you're done with it, versus are you promising that the caller can keep using it after you return.
Re:Next steps for Rust in the kernel by tialaramex on Wednesday September 21, 2022 @06:19PM (#32932331)
Whilst there are differences, that's not one of them. What decides whether the caller still has something is whether you passed it by reference.

fn eat(food: Edible) just takes an actual Edible. Afterwards the food is gone, perhaps this function stashed it somewhere, or gave it away, but you don't have it any more† so maybe it was Dropped (destroyed)

fn sniff(food: &Edible) -> Smell this time our function only wants an immutable reference to the Edible. The food isn't changed in any way by this predicate, it's still yours, and now you also know how it Smells.

fn lick(food: &mut Edible) -> Review but this function modifies the Edible via the exclusive reference. You still have the food, and now you've got a Review, but the food may be changed, perhaps irreversibly by being licked.

† If Edible is Copy then Rust will just copy it, so the caller still has it, types which are Copy are typically small, and they can't implement Drop, so if they were destroyed nothing happens anyway. An integer is Copy, a String isn't Copy, and neither is a File, or a network Socket, or whatever. You can make your own types Copy, if you want, and if they qualify.

Re:Next steps for Rust in the kernel by a1369209993 on Wednesday September 21, 2022 @06:39PM (#32932523)
> What decides whether the caller still has something is whether you passed it by reference.

I was referring to the `Box<dyn Trait>` one, as I'm at least 90% sure `Box<X>` passes a owned, dynamically-allocated X by reference (ie, Box<X> is a pointer to X).

Re:Next steps for Rust in the kernel by tialaramex on Wednesday September 21, 2022 @07:40PM (#32933098)
A Box<dyn Bird> is some sort of Bird on the heap. But if I pass a Box<Goose> to a function which wants a Box<dyn Bird>, then my call moves the Box<Goose> into the function, I don't still have that Goose, it's gone, I hope the function takes good care of it.

If the function only wanted a reference to it, that would be &Box<dyn Bird> and then I wouldn't give up ownership by passing it to the function. But that's also a very strange thing to ask for, since we can instead pass a reference to a Bird, no need to Box it.

Re:Next steps for Rust in the kernel by a1369209993 on Friday September 23, 2022 @03:50AM (#32949125)
> A Box<dyn Bird> is some sort of Bird on the heap.

No, a Box<dyn Bird> is a pointer to some sort of Bird on the heap. Unless Rust has wildly changed how it implements function calls/stack frames, local variables are stored on the stack. A pointer is a reference to the thing it points to (in sense used in the phrase "pass by reference").

> then my call moves the Box<Goose> into the function, I don't still have that Goose

Yes: you passed a Box<Goose> by value, you passed the Goose it points to by reference, and you transfered ownership of both.

Re:Next steps for Rust in the kernel by tialaramex on Saturday September 24, 2022 @03:23PM (#32965776)
I think what got confused here is just the nomenclature? In particular the use of "reference" to mean what we get when we borrow something in Rust, and its use to mean the address of something as part of a calling convention.

> are you promising to deallocate and otherwise clean up the object when you're done with it, versus are you promising that the caller can keep using it after you return.

Whether I ask for a Goose or a Box<Goose>, it's mine now. The caller no longer has it, it's not just that they shouldn't use it, they can't, the compiler won't let them. Since it's mine, it is now my responsibility as owner either clean up, give it to somebody else or explicitly leak() it.

Rust doesn't promise how exactly this is implemented, and it is likely to be different for an object of 4 bytes than for an object of 400 bytes.

Re:Next steps for Rust in the kernel by chc on Wednesday September 21, 2022 @06:35PM (#32932484)
None of the snippets in my post indicate borrowing. You can borrow or not borrow any of the types above.

It is true, though, that there are differences. With the generic, you can refer to the type again later, whereas the type is anonymous with `impl Trait`. And `dyn Trait` gives you dynamic dispatch. But in my experience there are usually some differences between the multiple ways to do something in Perk as well.