Linux Journal Interview With Brian Kernighan 333
pndiku writes "Linux Journal has an interesting interview with Brian Kernighan where he talks about AWK, AMPL and how he had nothing to do with the creation of C."
"The following is not for the weak of heart or Fundamentalists." -- Dave Barry
Correct AMPL link (Score:5, Informative)
John.
Woah (Score:5, Funny)
That's something to be proud of!
Re:Woah (Score:3, Funny)
Hey, we have something in common! (Score:5, Funny)
If I were Brian... (Score:5, Funny)
...and someone asked me about the wisdom of gets(), I'd also be pointing at Dennis Ritchie and yelling, "It was him! Burrrn him!"
Re:If I were Brian... (Score:3, Interesting)
Huh, I consider gets to be a minor (!) snafu compared to the vile mind poison of:
int foo, *bar;
And the way that C interprets type modifiers as right to left except that any modifiers on the far left to the first type. Gnnn.
If I had a penny for every time I'd seen developers failing to completely understand C types because of this, I'd be handing my wet towels to Bill Gates.
Re:If I were Brian... (Score:2)
int foo, *bar; creates an integer named foo, and a pointer to an int named bar. Right? Or am I wrong?
What do you mean by the order of type modifiers? Can you give an example?
What I like is the way you can declare a variable const (ie, it's not constant and should not change) yet still assign to it and get away with merely a compiler warning.
Re:If I were Brian... (Score:5, Interesting)
So you have one declaration line which created variables of two totally disinct types. Fine for the opriginal creator, lousy for the maintainer, who sees a line declaring ints and had to do a serious double take to find that some of them are actually pointers. Abuse further as
int foo, *bar, flash, *bang, up, *down, left, *right;
Without reading the line again, what was the type of "up"?
And as for the other, I can never define any sort of function pointer in one line: I always have to typedef tthe function and then have a pointer to it. While I can work out, with a manual in hand, how to do it in one line, the syntax is so unintuitive that I never do it: I will just have to reach for the manual again wh
en I maintain it.
The mistake I would junk is allowing enum {fred=36, bill=19, joe=333} ; Which confuses predefined constants with the classic enumeration. The cost saving of a lookup table to convert the 0, 1, 2 sequence is tiny, and the knock on effects are horrible.
Re:If I were Brian... (Score:2, Interesting)
I'm not disagreeing with your point, but the acceptable (if not great) solution is to choose your variable names more wisely.
Re:If I were Brian... (Score:4, Interesting)
Re:If I were Brian... (Score:2)
Re:If I were Brian... (Score:2)
Note that Linus only refers to Hungarian notation in functions, not variables. I've seen people bash Hungarian function notation (where it's beyond stupid) and then use pVar and so forth all over their code.
Re:If I were Brian... (Score:3, Interesting)
int pFoo, *Bar;
Which falsely labels pFoo as a pointer and Bar as not a pointer, when the opposite is true? How's THAT for confusing. The problem with encoding type name with the variable is that it now means there are two seperate ways where you "define" the type - the one for the compiler's benefit and the one for the human reader's benefit. Since they are totally independant of each other, they can disagree - leading to no end of confusion. I much prefer coming up with a
Re:If I were Brian... (Score:2, Insightful)
Re:If I were Brian... (Score:3, Troll)
int foo, *bar;
The problem is when the C++ people come and insist you put the * by the type instead of by the variable.
int* foo, bar;
That line confuses the hell out of people learning the language. foo is a pointer, bar isn't. That's the big reason I always insist on putting the * by the variable name rather than by the type.
Re:If I were Brian... (Score:4, Insightful)
However, you example clearly shows where 'the C++ way' (and I'm one of these who got into coding after C++ was fairly standardized, and so never have done any 'real' C) is not the preferred answer.
The preferred answer is: knowledge.
Re:If I were Brian... (Score:2, Interesting)
The advantage of enums over constants is type checking by the compiler (warnings are issued if you try to assign a constant to a variable declared as an enum) and also warnings issued when you do a switch on an enum (as in switch(enum varBlah)). This might
Re:If I were Brian... (Score:5, Insightful)
int foo, flash, up, left;
int *bar, *bang, *down, *right;
Or even better:
int foo;
int flash;
int up;
int left;
int *bar;
int *bang;
int *down;
int *right;
Just because a language allows a construct doesn't mean you have to use it. This is a coding-style argument, which are of course all subjective.
I can never define any sort of function pointer in one line: I always have to typedef tthe function and then have a pointer to it. While I can work out, with a manual in hand, how to do it in one line, the syntax is so unintuitive that I never do it: I will just have to reach for the manual again wh en I maintain it.
This is a valid problem that has to do with operator precedence. In C the operator precedence is arranged in such a way most commonly used expressions can be written without a lot of brackets. I think this is more convenient, because normally you don't define a lot of function pointers, but you do use at least some pointer arithmetics.
The mistake I would junk is allowing enum {fred=36, bill=19, joe=333} ; Which confuses predefined constants with the classic enumeration.
A constant in C is not the same as an enum. Simply put constants are addressable, enum items are not. One could choose to introduce yet another construct for unaddressable constants, but this is far more practical.
And again, you don't have to use every feature in a language just to make your code more interesting. C was designed as a language-of-choice, not as a bondage-and-discipline language. If you don't like your freedom, don't use it, but please don't start whining you've got too much freedom.
C enums (Score:2)
The cost of the lookup table is not necessarily trivial. It depends how often it's used. The C enum is good at adapting to arbitrary numbering schemes, especially if they have gaps. enum{fred=36, bill, joe};
My only complaint is that the enum values enter t
Re:If I were Brian... (Score:2)
int * foo, bar
To the typical novice C programmer, that looks like it means "foo and bar are both of type 'int *', when in fact it means "foo is int *, while bar is just int" That is confusing. One thing I would have liked to have seen done differently is to use actual words for the different numerical formats. I'd rather see something like: hex$ff80 rather than 0xff80. This is espe
Re:If I were Brian... (Score:2)
char* x, y
This style is explicitly encouraged in the Stroustrup book. Now, what type is y? Easy because you're looking out for something, but in the middle of maintaining strange code it's easy to miss.
Cheers,
Ian
Re:If I were Brian... (Score:3, Informative)
Why? It is perfectly possible to write a C program that contains int foo, *bar; and performs correctly for all inputs. The same is not true for a C program that calls gets.
Re:If I were Brian... (Score:5, Interesting)
You can write badly obfuscated code by abusing visual association in just about every language, but this particular gotcha should have tipped off Stroustrup VERY early on that his style was agegeously misleading, and a good technical editor should never have let him publish a book with such incomprehensible gibberish.
That very thing is one of the primary reasons I didn't use C++ for years (not to mention that I regretted it when I did). My thinking was that if the creator of the language didn't see how damaging it was to introduce confusion in his published writing, then he wasn't likely to avoid such in a programming language. I think ANSI C++ stands as a monument to the correctness of my thinking on that point!
Re:If I were Brian... (Score:3, Insightful)
And void main is deprecated. Don't use it. gcc is nice enough to warn you.
Re:If I were Brian... (Score:3, Informative)
Re:If I were Brian... (Score:2)
Only because those people were idiots, they didn't actually understand what the hell they were declaring, and they were using bad style to perpetuate the previous two issues.
Not bad style as in "int* i", but bad style as in declaring multiple variables on one line. It's a complete non-issue if you declare each variable on it's own line. It also makes the code far more readable, and makes types m
Re:If I were Brian... (Score:2)
It's at an address pointed to by random trash on the stack where the j variable was allocated.
the line:
*j = 2;
Is going to sometimes segfault, sometimes not segfault, depending on what random trash was on the stack when 'j' was made.
Re:If I were Brian... (Score:2)
Yeah, I never figured out why some people can't get it into their heads that variable declarations in C is an equivalence construct. "int *i" is supposed to be read as "typeof(int) == typeof(*i)". The type on the left is equal to the type of the expression to the right. Since '*' is a p
Re:If I were Brian... (Score:3, Informative)
while(*buf++=getchar())
type of loop
Once the preprocessor got more goodies, and STDIO was cleaned up, it became:
#define gets(x) fgets(x,BUFSIZ,stdin)
So in the days when there were only 100 or so Unix sites you could declare strings with
char buf[BUFSIZ];
and you couldn't overflow it.
SCO sueing Brian Kernighan (Score:5, Funny)
Sueing for use of letters... (Score:2)
Never assume such things cannot happen. Actually, Deutsche Telekom [telekom3.de] (Germany's telecommunications monopolist) is sueing a small company [heise.de] (not even a competitor) for usage of the letter T.
They have been unsuccessful in sueing companies for usage of the color magenta in the past, though.
Atleast Windows is safe. (Score:5, Funny)
That explains why SCO isn't going after Microsoft.
Windows being written in VB and all.
FreeBSD on his Mac? (Score:2)
That's odd... How useable is the FreeBSD PPC port nowadays? Last I heard it only booted and nothing much more. Isn't he confusing FreeBSD and NetBSD? Or is he referring to the FreeBSD userland in OS X/Darwin?
I love FreeBSD though, I'd love to run it on my iMac instead of OS/X.
Mac OS X, Solaris, IRIX (Score:2)
As he metioned that most of the free unices these days are alike, I'm guessing that he's referring to the FreeBSD userland.
I love FreeBSD though, I'd love to run it on my iMac instead of OS/X.
Mac OS X runs pretty well on the G4 iMac that I use. Apple's flavor of X11 [apple.com] runs well enough for me, and there's plenty of OSS goodies, links, and documentation [apple.com] to keep most folks happy.
It is kinda interesting that h
Re:FreeBSD on his Mac? (Score:3, Informative)
Re:FreeBSD on his Mac? (Score:3, Interesting)
Re:FreeBSD on his Mac? (Score:3, Informative)
expressive (Score:4, Insightful)
Re:expressive (Score:4, Funny)
Flash [littlemikey.com] video of Monty Python's famous skit
Re:expressive (Score:5, Funny)
And let's not forget crisitunity.
Re:expressive (Score:2)
I'm actually trying to learn chinese and I'm having a rather difficult time of it. Damn intonation....
Re:expressive (Score:3, Interesting)
Re:expressive (Score:3, Insightful)
Re:expressive (Score:3, Insightful)
I suppose that all depends of the compilers and interpreters involved.
Re:expressive (Score:2)
Re:expressive (Score:2)
I of course meant "pretty damn expressive", although many would argue the original version was correct.
Re:expressive (Score:4, Insightful)
Re:expressive (Score:3, Insightful)
Re:expressive (Score:4, Interesting)
After years of basic, fortran, 6502 assembler, pascal, and probably something else that I've forgotten, forth was magical. Still is.
Re:expressive (Score:5, Insightful)
In your context, you might mean "expressive" in the sense of "saying as much in as few words as possible." Since C is a typed languge with explicit memory management, it's going to be more verbose than an untyped garbage-collecting language like Lisp or Perl. (Well, they have very limited typing, especially once you start adding constructs on top of the core language.)
Or you could mean "expressive" in exactly the opposite sense, where you have to be more "expressive" about the types of things. In this sense C is far less expressive than strongly typed languages like Haskell or even C++/Java.
Or you could simply be referring to the verbosity of the language, where COBOL holds the title of most ugly language and APL is without a doubt the shortest. (APL is indistinguishable from line noise.)
In the end the value of a "language" has less to do with the core language and much to do with the libraries for hardware access (memory, screen, disk, network) and compatibility with common features provided by the OS (clipboard, windowing, etc.)
So you pick your language for a host of reasons few of which have anything to do with a core "expressiveness".
Re:expressive (Score:2)
Re:expressive (Score:2)
Re:expressive (Score:2)
Re:expressive (Score:3, Interesting)
In the Kolmogorov sense, the "complexity" of a program differs between two languages by at most a bounded constant (the length of the interpreter of one language in the other).
But in the real world, I think K (http://kx.com) beats any other language in terseness (and is speedwise competitive with C as well). Rebol is also amazingly terse, even if not as fast.
Re:expressive (Score:2, Informative)
f (h:t) = h : f [ x | x <- t, x 'mod' h
main = f [2..]
The only reason it's possible is due to Haskell's lazy evaluation, so you can have infinite recursion defining a list, and it's not really a problem, unless you try to grab every member of the infinite list and u
He teaches VB! (Score:2, Informative)
Re:He teaches VB! (Score:2)
his sanity!
sri
Re:He teaches VB! (Score:5, Funny)
I'm a C nut...
Just be glad you're not dyslexic as well. :)
VB??? (Score:2)
Ugh!
Is there a more vile language you can teach to newbies? I guess it must be meant to weed out the people who don't really want to program.
There are so many better choices than VB for teaching, if you really want to show people a GUI, try Java. If you just want something that is clean and easy to get started with, try Ruby or even Python. But VB? It has awful namespace problems, an absurd mishmash of methods vs. functions vs. subroutines, etc. Yuck.
Isn't it odd that I'd recommend to people
VB for beginners (Score:2)
With the Visual Studio front end, learning to create (and de
VB and Kernighan's course (Score:4, Informative)
I know people who have taken his classes. I live with one of them (a CS type), and used to live with another (a non-CS type). All of them have nothing but good things to say about Kernighan's classes.
The class in which he teaches VB is oriented towards non-CS types, and, from what I saw of my former roommate's coursework, I can't imagine a better course to give people who are basically computer illiterate SOME idea of just what goes on inside the magic box, and some familiarity with all the issues surrounding information technology (legal, ethical, etc.
Complaining about VB's namespace problems in this context is like bitching about giving a toddler a tricycle because he'll never win the Tour de France on anything with three wheels. My former roommate had no problems with his programming assignments that he wouldn't have had in any other language, and, judging from what I've seen of people trying to pick up C and Java for the first time, VB is a far better choice of language for a course that aims to give people a flavor of what computers are all about.
Re:He teaches VB! (Score:4, Funny)
Great people are so humble! (Score:5, Insightful)
he's dead wrong about MS (Score:2, Interesting)
Like many people, I have mixed feelings about Microsoft. They have done much good for the world, producing a common environment that has enabled a lot of creative people to build new software and hardware and sell it at reasonable prices. Microsoft's work has made computing accessible to a huge population who would otherwise not be able to use computers.
listen folks: Microsoft did not bring computers t
Re:he's dead wrong about MS (Score:3, Insightful)
Re:he's dead wrong about MS (Score:2, Funny)
Re:he's dead wrong about MS (Score:4, Insightful)
Think about when PC's were becoming popular in the '80s with thousands of titles available for Microsoft DOS. The fact that the OS was DOS was largely irrelevant to those packages. They took over the whole machine when they ran and the OS's job was over once the program was running. So people didn't care that DOS was crap. What mattered is that at a time when the hardware wasn't fast enough to make a real OS feel "snappy", DOS could be shoved aside so your program had the whole CPU and memory to itself. It worked because at the time you couldn't spare the memory and time for a "real" OS.
DOS was a success because it was attached to PC's, not because of any features of DOS itself.
Actually, he is right. (Score:3, Interesting)
With MS having the forsight and balls to reserve the ownership of MS-DOS and grant IBM a license they opened the doot to one OS running on machines manufactured by multiple venders.
Consider that when your average PC cost $4,000.00 (US
Yes and no (Score:2)
Sure, hiding the details is a Good Thing.
I think there is a counterargument, though; y'all just can't express differential calculus easily in arithmetic terms.
The genius of MS is in targeting the lowest common denominator. Why does Joe User care about the difference between physical and logical partitions? Redmond has the a:\ b:\ c:\ market firmly in hand.
The utopian vision of 'source code for all my people' will never occur; they can't be bothe
Re:Yes and no (Score:2)
yeah, but that denominator keeps going lower. To what are they going to change "My Network Places" (shudder) that's dumber-down than THAT?
overthrow the style oppressor (Score:3, Funny)
Holy shit, batman, where's your flame-proof suit?? (Score:5, Funny)
1) He mentions he writes interfaces for.. Visual Basic
2) He mentions he writes code in Java
3) He mentions Microsoft in a positive light
4) He admits to owning a Mac
Fuck, man, the only thing he didn't do is say "vi" or "emacs".
Does this mean that, in reality, all of the contention regarding languages, operating systems, and idealogies is completely artificial and that we should really just use what we like instead of jumping on a particular bandwagon and denying the legitimacy of anything else?
Man, I think I want to go back to bed.
totally. I like this guy. (Score:5, Insightful)
Re:Holy shit, batman, where's your flame-proof sui (Score:5, Funny)
(It led you to assume that the rest of slashdot will.)
Re:Holy shit, batman, where's your flame-proof sui (Score:4, Insightful)
Kernighan sounds like he applies this kind of perspective to computers. From what I've read, for all the flame wars about Perl vs. Python, Vi vs. Emacs, *NIX vs. Windows, etc, the "monks" in these groups seem to be much more focused on the commonalities among systems rather than the differences between one and another. Kernighan talks about all the languages and operating systems he uses; Larry Wall gleefully puts the best of every language he can get his paws on into Perl; Guido van Rossum doesn't seem to object to letting a future version of Python run on top of Perl6's Parrot runtime engine; Craig Mundie has no fear preaching the Microsoft word at the Open Source Conference; and Tim O'Reilly tells people that he gets along well with all the people he has met at Microsoft.
I think that's wisdom.
Why Pascal is Not My Favorite Programming Language (Score:5, Informative)
Re:Why Pascal is Not My Favorite Programming Langu (Score:3, Informative)
Pascal's main problem is that nearly every "real world" implementation of Pascal has dealt with the problems presented in the paper, Unfortunately in different and incompatible ways.
these guys (Score:5, Interesting)
-- chris
http://elusive.filetap.com
Unix Guy Who Doesn't Hate Windows (Score:2)
It's a shared feeling... (Score:2)
I, Parasite (Score:3, Interesting)
All True.
What's more, I make a decent living off of Microsoft's products -- and like a good parasite, I don't actually harm my host.
Re:It's a shared feeling... (Score:3, Insightful)
Correction. It is just easier to use Windows software under Windows than most other OSes. But beyond that it's actually pretty mediocre.
Compare the individual components of Windows to their counterparts in the UNIX world. Compare *just* the window manager part (not the desktop) to Blackbox. Blackbox is easier to use. You can easily control the z-order of windows, snap to window or screen borders, etc., making it very easy to organize your windows on t
Slashdot should retitle the article (Score:4, Insightful)
Jokes aside, the names Kernighan and Ritchie are firmly planted in the minds of most CS majors. We have "celebrities" like Torvald or Stallman but at the end of the day, professors always say "Read page XXX in Kernighan and Ritchie", which we always proceeds to ignore until our code doesn't work. Then once again, we reach for the pretty little white book and thank someone or something for the well written proses. Unlike many other CS books, K&R seem to have cover most of the possible contingencies a fledgling CS major might have. I hate books that tell you how to do things only in one way, their way. K&R was written so well that I didn't have to.
favorite quote (Score:2)
Interesting. So in 50 years, we won't have a Star-Trek like voice interface for our computers? Damn.
80-year-old LMCBoy: "computer, make me a ham sandwich"
Mycroft 2: "Poof! You are a ham sandwich." (mechanical laughter)
80yoL: "In my
Only two real problems in computing? (Score:3, Interesting)
There are only two real problems in computing: computers are too hard to use and too hard to program.
Does everyone buy this? What about issues of availability and maintainability? How about:
There are three real problems in computing: computers are too hard to use, too hard to program and too hard to administer.
What an embarrassing interview (Score:3)
"Brian, what do you think of UNIX? Is it a good and reliable platform for development?"
"Is it true that you suggested the name "UNIX" for the long ago OS, Multics? What does that word mean?"
"What are your hobbies? Reading? Sports?"
"Could you say that you love computers (IT)?"
Etc. What a waste of a good man's time.
Nearly all the interview questions are either (a) things widely available in the literature (as in FAQs, not digging research - did the interviewer really not know what AWK stood for? If so, shame on him), or (b) idiotic questions that I might ask if I was interviewing a 6th grader.
If you can't think of anything interesting to ask your subject, don't bother with the interview!
Re:It's official (Score:5, Informative)
So, we still have K&R, just as before. Only now, maybe some readers understand better that K&R is not the names of the C inventors, but the name of the people who wrote the book about how to use C ;)
Re:It's official (Score:2, Funny)
<nazi class="grammar">
First off, which is in the wrong case. which is the objective case. It should be the nominative form, that.
Second, that/which is the wrong word. Dennis Ritchis is a person, and therefore should be substituted by the pronoun who (not whom, as that would cause that same nominative/objective problem again).
</nazi>
Re:It's official (Score:2)
Re:It's official (Score:2)
Re:It's official (Score:2)
Dw
Re:It's official (Score:2, Insightful)
Re:BWK (Score:5, Informative)
The Practice of Programming [amazon.com]
Kerningham and Pike
Addison-Wesley, 1999
is a classic text and it's very clearly written. The front cover sums up in three words the core philosophy of the entire book:
Simplicity
Clarity
Generality
It is a delight to read although it uses C/C++ as the example language everywhere and tends, therefore, to be a little C oriented, although there are examples in other languages.
Much of the material will be familiar to people who've done a CS degree (e.g. trees, O-notation, etc.) but the section on testing is very worthwhile if you are planning to write code that will last a long time.
John.
Simplicity (Score:5, Funny)
One of my favorite Kernighan quotes of all time:
Rob doesn't get enough credit (Score:2)
Re:Points in article: (Score:5, Informative)
Let's see ...
If you had done as much important work, I think you would be worthy of an interview, too. That's no guarantee that you'd have much to say, of course.
Re:Points in article: (Score:2, Interesting)
Some ideas are just right.
Re:Points in article: (Score:3, Insightful)
The fact that the language under critque was FORTRAN, unfortunately today, obscures the underlying truths they were discussing.
Re:Points in article: (Score:2, Insightful)
1. He says the graphical interfaces for running java are more responsive on Windows than X, not that everything is. You take that out of context, and in the process invite flame war Win vs X...
3. You are inviting a flame war Lisp vs C. They are very different languages to start with, and both have "loyal followers", one of the best recipes for flame war.
That's why your first post comes through as flamebait, and 2nd post comes through as a troll trying to draw more attention
Re:Mac running Linux problems (Score:2)