News for hackers. Stuff that matters.
Re:Rob Pike comments on Ryan Dahl's rant by etrain on Wednesday October 05, 2011 @09:27AM (#3075471)
Doug McIlroy (inventor of pipes, original author of diff) was on my undergrad thesis committee. I think he would agree with Rob here.

While the design of these additional features violates the "UNIX way," it doesn't violate pragmatism. Too often in our field, perfect is the enemy of good enough. Is BSD's model and implementation of sockets perfect? Surely not. Is it good enough? From the purists perspective, maybe not. From the pragmatists perspective, absolutely. I probably wouldn't be typing this today (on my macbook pro) without the implementation of BSD sockets.

Re:Rob Pike comments on Ryan Dahl's rant by nicolaus on Wednesday October 05, 2011 @11:37AM (#3076095)
I recall this missive from Linus Torvalds on the design of Linux:

"If you want to see a system that was more thoroughly _designed_, you should probably point not to Dennis and Ken, but to systems like L4 and Plan-9, and people like Jochen Liedtk and Rob Pike. And notice how they aren't all that popular or well known? "Design" is like a religion - too much of it makes you inflexibly and unpopular."

http://kerneltrap.org/node/11

Re:Rob Pike comments on Ryan Dahl's rant by uriel on Wednesday October 05, 2011 @11:48AM (#3076151)
That is a somewhat silly comment from Linus given that ken and rob designed and built Plan 9 together. (For example, ken designed UTF-8 while rob helped write the code: http://doc.cat-v.org/bell_labs/utf-8_history )
Re:Rob Pike comments on Ryan Dahl's rant by yxhuvud on Wednesday October 05, 2011 @01:25PM (#3076582)
Yes, like Apple.

.. oh wait.

It is rather that good design make you popular and not so good design doesn't.

Re:Rob Pike comments on Ryan Dahl's rant by william42 on Wednesday October 05, 2011 @02:47PM (#3076948)
Apple's internal design was a mess pre-OSX though. Still kind of is. Apple's praised for end-user interface design.
Re:Rob Pike comments on Ryan Dahl's rant by uriel on Wednesday October 05, 2011 @02:57PM (#3076996)
OS X design is still a horrible mess, a monolithic BSD kernel bolted on top of a monstruous Mach 'micro'-kernel. Not to mention things like the new XML-based init system, property list files, hacks around 'extended attributes' (or whatever they call them) and many other aberrations.
Re:Rob Pike comments on Ryan Dahl's rant by dextorious on Wednesday October 05, 2011 @03:28PM (#3077132)
And those are a mess because?

Property list files: a big f*n win compared to the ad hoc mess in a Linux/BSD /etc directory.

Hacks around extended attributes: any reason not to like those? Or just because in 1977 a file was just a file, and that's the way it should be, god damn it?

XML-based init system: a sane init system. And XML added in for standardization.

OS X is a mess in several ways, but those are not it. And the "monolithic BSD kernel bolted on top of a Mach 'micro'-kernel" sounds like a win-win situation. Monstrous why? Because it doesn't fit some idealistic model?

Re:Rob Pike comments on Ryan Dahl's rant by FooBarWidget on Wednesday October 05, 2011 @05:17PM (#3077649)
Even standard system calls are messily implemented. poll() is broken. kqueue is broken. See http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod#OS_X_AN...

Last year I even discovered a kernel bug in their file descriptor passing implementation that, AFAIK, still isn't fixed. Various signal handling properties are more buggy than on Linux.

Re:Rob Pike comments on Ryan Dahl's rant by udp on Wednesday October 05, 2011 @07:56PM (#3078206)
TCP_NOPUSH is broken, too - if you enable it and then later disable it with setsockopt, it doesn't immediately send any pending data (as it does on FreeBSD, and as TCP_CORK does on Linux).

IIRC, a lot of their code came from FreeBSD back in the day. I wonder why they didn't keep it in sync?

Re:Rob Pike comments on Ryan Dahl's rant by enneff on Wednesday October 05, 2011 @04:02PM (#3077274)
It's a mess because there are several ways to do the same things, and no two things are done in the same way. It feels like any time I want to do something new in OS X I need to learn a new system of some kind. That is bad design. It should just be obvious.
Re:Rob Pike comments on Ryan Dahl's rant by exogen on Wednesday October 05, 2011 @04:48PM (#3077501)
If "obviousness" is the criteria for a well-designed OS, I'm not sure we've seen a (successful) well-designed OS in the history of computing. OS X certainly doesn't deserve to be called out. :)
Re:Rob Pike comments on Ryan Dahl's rant by enneff on Wednesday October 05, 2011 @05:44PM (#3077752)
Actually, I think it does. OS X is a horrendous frankenstein of several different systems with different design philosophies. It is really, truly awful. (Although it works - I'm using an OS X machine to type this now.)

One of the great things about Plan 9 is that everything implements the same interface. If you can interact with one thing, you can interact with everything. Using new parts of the system becomes obvious because you already know the interface.

A concrete example of why this works: In Plan 9, process information is available via (guess what) the file system, so the Plan 9 debugger just reads the state of running processes from those files. Because file systems are automatically exported over the network (also part of the file system), you can debug a running process on another machine without the debugger knowing anything about the network. Nobody had to implement network debugging - it just worked right away because of good design.

You know you have a good design when these kinds of complex behaviors just "fall out" without any additional work.

Re:Rob Pike comments on Ryan Dahl's rant by yxhuvud on Wednesday October 05, 2011 @03:21PM (#3077102)
So is Unix.

It is just that the end users are different people to the ones on Mac (and would indeed usually be power users or developers there).

Re:Rob Pike comments on Ryan Dahl's rant by justincormack on Wednesday October 05, 2011 @09:31AM (#3075488)
On the other hand, signals were just a poor design. They are much nicer now on Linux with signalfd(2), which gives you a file descriptor to read them on, a much nicer interface than all the old syscalls for signals.
Re:Rob Pike comments on Ryan Dahl's rant by anatoly on Wednesday October 05, 2011 @01:12PM (#3076533)
Well, I'm not sure signalfd(2) was feasible back when signals were added. Was it?

Today it's usual to structure your main() as some kind of select()-like loop; even if you don't need one for your main workflow, at the worst you can spawn an I/O thread and put it there. But back then, you didn't have threads. Lots of programs didn't read your input but still wanted to catch signals, e.g. to exit cleanly on kill -15. Many others read input, but without an event loop - they would just try to readchar() periodically when they had nothing else to do.

Was there an obviously better design back then?

Re:Rob Pike comments on Ryan Dahl's rant by justincormack on Wednesday October 05, 2011 @01:57PM (#3076740)
An occasional readchar could be replaced with an occasional read to a signalfd. The problem is blocking calls, you need to not block for too long in case a signal arrives, which is more messy it is true.
Re:Rob Pike comments on Ryan Dahl's rant by caf on Wednesday October 05, 2011 @10:16PM (#3078734)
Blocking calls are not the problem - you simply block on select({stdin, signalfd}) instead of blocking on read(stdin). The problem rather is slow IO calls that nonetheless never block - the canonical example being a read() from a disk file. In this case (eg. /bin/tar) you would have to poll your signalfd after every read() - but this breaks the file abstraction for programs like /bin/cat that don't care whether the file descriptor they're reading from is the blockable type or not, so they'd have to do both.

This is now starting to look considerably inelegant, and we haven't even talked about implementing the equivalent of synchronous signals provoked by a program's own action (SIGILL, SIGFPE, SIGSEGV, SIGBUS...).

Re:Rob Pike comments on Ryan Dahl's rant by ori_b on Wednesday October 05, 2011 @03:11PM (#3077061)
If you need to handle signals immediately, you can always put the signalfd reader into it's own thread.
Re:Rob Pike comments on Ryan Dahl's rant by mdellavo on Wednesday October 05, 2011 @09:36AM (#3075516)
I absolutely agree with you.

I can't help but juxtapose this current dialog (which now includes one of the Unix forefathers) with the idea of "Worse is Better" (http://www.jwz.org/doc/worse-is-better.html). Maybe it's the Jersey in me but at the end of the day working, shipped software is all that concerns me.

Re:Rob Pike comments on Ryan Dahl's rant by mhd on Wednesday October 05, 2011 @12:00PM (#3076202)
The interesting bit here(I don't wanna say "problem"), is that we're actually a few steps further down this staircase of "let's ship". Unix wasn't exactly the purist ivory tower to begin with, then it merged with the partially compatible BSD, then we got some not-quite-Smalltalk GUIs on top of that, and now we're building elaborate web stacks on top (and/or instead) of that. And I don't even want to talk about mobile apps that in an almost unholy ceremony combine that again…

It's a Babylonian tower made of mud (some would say camel poo). But it's brightly painted and has a good view, and all your friends live in it.

Personally, I don't wanna move out either, but I still have to turn my head every time you see the paint come off somewhere…

Re:Rob Pike comments on Ryan Dahl's rant by DanBC on Wednesday October 05, 2011 @02:15PM (#3076818)
I'm not technical, but even I can appreciate some of the very many layers beneath my web-browsing.

But, taking me typing into this text-box on HN as an example: What would the Unix way be? (If every tool does one thing and does it well, with text as input and output, and pipes to join it all together.)

Would I really have an unholy long command-line of a bunch of tools piped together (but accessed by clicking an icon)?

Re:Rob Pike comments on Ryan Dahl's rant by mhd on Wednesday October 05, 2011 @06:33PM (#3077922)
I'm really not the expert to ask here, my personal style is a bit too tainted for the hardcore V7/P9 fans. But it's interesting to think about, so I'll give it a try.

Let's cut to the chase: Why would you have a textbox and a specific site for what amounts to a simple discussion? There's really no big conceptual reason why we couldn't do this via email, nntp or some similar protocol.

Leaving that aside, the more difficult question is how you'd get the textbox on your screen, i.e. what's the "True Unix" way of "web browsing"? There aren't that many examples of a rather graphical, highly interactive programs that believers would classify as really Unix-like. Maybe something roff-like, where you have a pretty universal display language and different (server-side?) tools are used to create something that would be too hard to express in the language as is (cf. tbl, pic), but then how would you make that interactive without doing the same stuff as HTML/CSS/JS? I was quite fond of the concept of NeWs, where you'd distribute your application over the net as PostScript, and I think Pike's Newsqueak went in a similar direction.

And how would you handle things on the server side? I don't think it would be that much different from what we're doing now. HTTP is quite resource-oriented and thus maps closely to a file system (the path-like nature of URLs is no accident). A CGI/PHP model for simple "files" would suffice, and you could have an almost arbitrarily complex application that appears as a file system, just like you can have that now appearing as a bunch of HTTP resources. People wrote "big" C applications, even though they could've theoretically done it all with a bunch of shell scripts, awk and ed. The "one thing and one thing only" mantra never was that religiously adhered to.

So, in conclusion, I don't think we're that far off right now, especially on the server side. If you look at what Pike's complaining about, it's mostly how you do it. Quite often the wheel is needlessly reinvented or has too many spokes, it's not that driving somewhere is wrong.

I'd argue that our current system is closer to "Unix" than it would be too Lisp Machines, Smalltalk and other more homogenous systems.

Re:Rob Pike comments on Ryan Dahl's rant by hvs on Wednesday October 05, 2011 @03:40PM (#3077186)
No, the web server (one tool) would instantiate another tool (e.g. python/ruby/arc parser) which renders the HTML page pipes it back to the server which sends it to you. You fill out the form, press submit, the web server passes pipes those parameters back into the python/ruby/arc parser which ... etc.

It's basically the model for CGI scripts.

Re:Rob Pike comments on Ryan Dahl's rant by adestefan on Wednesday October 05, 2011 @10:13AM (#3075666)
BSD sockets has somehow made it's way through the entire computing world and we're never going to get rid of it. Even the tiniest of embedded systems have decides that sockets are the one-true-way of network programming.
Re:Rob Pike comments on Ryan Dahl's rant by yxhuvud on Wednesday October 05, 2011 @01:27PM (#3076597)
I'm curious: What is the alternative?
Re:Rob Pike comments on Ryan Dahl's rant by quadhome on Thursday October 06, 2011 @11:06AM (#3080331)
Re:Rob Pike comments on Ryan Dahl's rant by uriel on Wednesday October 05, 2011 @11:02AM (#3075921)
And this is so sad.

By the way, Plan 9 doesn't have sockets, it has /net: http://man.cat-v.org/plan_9/3/ip with the dial API built on top: http://man.cat-v.org/plan_9/2/dial

This means that for example, Plan 9 applications that do networking are not tied to a specific network stack, you can mount multiple network stacks concurrently, you can have 'virtual' network stacks (for example running in user space and proxying to a remote host, or doing other neat tricks), and the apps don't need to care.

Also when Ipv6 was added to the Plan 9 stack, no application code had to be modified, because the API nicely abstracts network addresses.