Slashdot Mirror


Linux Journal Interview With Brian Kernighan

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."

39 of 333 comments (clear)

  1. Correct AMPL link by JohnGrahamCumming · · Score: 4, Informative

    The story has a link to ampl.org, the correct link is ampl.com.

    John.

  2. Woah by Sir+Haxalot · · Score: 5, Funny

    '...and how he had nothing to do with the creation of C'
    That's something to be proud of!

    --
    I have over 70 freaks, do you?
    1. Re:Woah by jmt9581 · · Score: 3, Funny

      I'd be more proud of having nothing to do with C++. :)

      --

      My blog

  3. Hey, we have something in common! by Anonymous Coward · · Score: 5, Funny

    I had nothing to do with the creation of C either!

  4. If I were Brian... by stevens · · 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!"

    1. Re:If I were Brian... by thogard · · Score: 3, Informative

      The 1st gets was based on a
      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.

    2. Re:If I were Brian... by AlecC · · Score: 4, Interesting

      int foo, *bar; creates an integer named foo, and a pointer to an int named bar. Right? Or am I wrong?

      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.

      --
      Consciousness is an illusion caused by an excess of self consciousness.
    3. Re:If I were Brian... by ajs · · Score: 4, Interesting
      You are exactly correct, and I have no idea what the original poster's problem with it was.
      [ajs@put /tmp]$ cat > /tmp/c.c
      #include <stdio.h>
      void
      main(int argc, char *argv[]) {
      int i, *j;
      i = 1;
      *j = 2;
      printf("i=%d, j=%d\n", i, *j);
      exit(0);
      }
      [ajs@put /tmp]$ gcc -o /tmp/c-test /tmp/c.c
      /tmp/c.c: In function `main':
      /tmp/c.c:3: warning: return type of `main' is not `int'
      [ajs@put /tmp]$ /tmp/c-test
      i=1, j=2
      Perhaps he was thinking of "int *i, j" which isn't all that bad in terms of confusion until you started seeing stroustrup's style, which I *hated* from day one of, "int* i" which of course lead to people using, "int* i, j".

      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!
    4. Re:If I were Brian... by muffel · · Score: 3, Interesting
      int Foo, *pBar, Flash, *pBang, Up, *pDown, etc;
      yuk. I can only agree with what Linux says in "CodingStyle":
      C is a Spartan language, and so should your naming be. Unlike Modula-2 and Pascal programmers, C programmers do not use cute names like ThisVariableIsATemporaryCounter. A C programmer would call that variable "tmp", which is much easier to write, and not the least more difficult to understand.
      [...]
      Encoding the type of a function into the name (so-called Hungarian notation) is brain damaged - the compiler knows the types anyway and can check those, and it only confuses the programmer. No wonder MicroSoft makes buggy programs.
      --

      bla
    5. Re:If I were Brian... by smittyoneeach · · Score: 3, Insightful

      Yeah, but the variable is just a label. The actual type in question is either int or int*.
      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.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    6. Re:If I were Brian... by Zan+Zu+from+Eridu · · Score: 5, Insightful
      So what is wrong with:

      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.

  5. SCO sueing Brian Kernighan by Anonymous Coward · · Score: 5, Funny

    Isn't SCO already suing Brian, both for being involved in a Linux OS, and because "C" happens to be found in the middle of SCO's trademark name?

  6. Re:It's official by Lazar+Dobrescu · · Score: 5, Informative
    It is well known that Kernigham had nothing to do with the creation of C. The K&R you are referring too are the authors of the BOOK, "The C Programming Language", that Kernigham wrote with Dennis Ritchie(which is the main inventor of C).

    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 ;)

  7. Re:BWK by JohnGrahamCumming · · Score: 4, Informative

    The book you are referring to:

    The Practice of Programming
    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.

  8. expressive by rnd() · · Score: 3, Insightful

    He mentions that he considers C to be the best combination of expressiveness and efficiency. I wonder, fellow Slashdotters, what you think the most expressive language is (efficiency aside)?

    --

    Amazing magic tricks

    1. Re:expressive by garcia · · Score: 3, Funny

      vuglar language.

      Flash video of Monty Python's famous skit ;)

    2. Re:expressive by ryants · · Score: 4, Funny
      what you think the most expressive language is (efficiency aside)?
      Chinese. In no other language can one syllable mean anything from "chicken" to "the interlocking fates of all beings in the celestial orb".

      And let's not forget crisitunity.

      --

      Ryan T. Sammartino
      "Ancora imparo"

    3. Re:expressive by leoboiko · · Score: 3, Insightful
      --
      Prescriptive grammar:linguistics :: alchemy:chemistry. Stop being a nazi and learn some science.
    4. Re:expressive by swordgeek · · Score: 3, Interesting

      Forth.

      After years of basic, fortran, 6502 assembler, pascal, and probably something else that I've forgotten, forth was magical. Still is.

      --

      "People who do stupid things with hazardous materials often die." -- Jim Davidson on alt.folklore.urban
    5. Re:expressive by jfengel · · Score: 5, Insightful

      You've got to be careful with your terminology here. All languages are equally expressive in the sense that anything you compute in one can be written in another. (At least in terms of computability. Access to hardware is a different matter.)

      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".

  9. Great people are so humble! by civilengineer · · Score: 5, Insightful

    He says " I wound up at Princeton" and "through good luck I got a job at Project MAC at MIT" and "probably because of the MIT experience, I got a job at Bell Labs in the Computing Science Research Center". Princeton, MIT, Bell Labs?? not easy!

    --

    New year Resolution: Don't change sig this year
  10. Re:Points in article: by DogIsMyCoprocessor · · Score: 4, Informative
    Why'd they interview him?

    Let's see ...

    • He invented Awk, a spiritual godfather to Perl
    • He co-authored The C Programming Language
    • He co-authored The UNIX Programming Environment
    • He co-authored Software Tools, an early manifesto of the "Unix Way" of using small, interoperable tools.

    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.

    --

    "And this is my boy, Sherman. Speak, Sherman." "Hello." "Good boy."

  11. Re:he's dead wrong about MS by SDPlaya · · Score: 3, Insightful

    While your argument may be beginning to hold some weight now, I find your position wrong for most of the history of computers. Historical Microsoft has been on the low-end of the price scale. In fact this is why they are scrambling against Linux, because they've usually been able to beat competitors by undercutting them in price (often destroying markets at the same time). I think you can argue that Microsoft has stifled innovation, but I don't think you can argue that they charge unreasonably high prices. Furthermore, outside of the OS, most other pieces of software are easy to migrate away from. If Microsoft's prices were "unreasonably" high, don't you think someone else would have taken over the Office Suite market by now?

  12. Simplicity by devphil · · Score: 5, Funny


    One of my favorite Kernighan quotes of all time:

    Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
    --
    You cannot apply a technological solution to a sociological problem. (Edwards' Law)
  13. Re:He teaches VB! by $rtbl_this · · Score: 4, Funny

    I'm a C nut...

    Just be glad you're not dyslexic as well. :)

    --
    "Are you being weird, or sarcastic?" said Emma. I said I didn't know because I get the two feelings mixed up.
  14. Atleast Windows is safe. by Niadh · · Score: 5, Funny

    ... since C is now owned by SCO, so is everything written in said language

    That explains why SCO isn't going after Microsoft.
    Windows being written in VB and all.

  15. overthrow the style oppressor by smarthippy · · Score: 3, Funny
    nothing to do with the creation of C? then why am i supposed to be using his coding style?! hrmph. i'll put my {}'s where i damn well please, now that the ugly truth has come to light.
    main() {
    for(;;) {
    printf("suck it!"); } }
  16. Holy shit, batman, where's your flame-proof suit?? by Rinikusu · · Score: 5, Funny

    Let's see:
    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.

    --
    If you were me, you'd be good lookin'. - six string samurai
  17. Why Pascal is Not My Favorite Programming Language by NearlyHeadless · · Score: 5, Informative

    Here's an HTML version of Why Pascal is Not My Favorite Programming Language. There's a Postscript version on Kernighan's website

  18. totally. I like this guy. by rebelcool · · Score: 5, Insightful

    Very practical. He wants to use the computer as a tool. Not a propaganda platform. Windows is fine and dandy for some applications, Unix for others. It all depends on what you're trying to do.

    --

    -

  19. Re:Holy shit, batman, where's your flame-proof sui by machine+of+god · · Score: 5, Funny

    You read the article didn't you. DIDN'T YOU. Never do that again.

    (It led you to assume that the rest of slashdot will.)

  20. these guys by Anonymous Coward · · Score: 5, Interesting

    My aunt used to work with these guys at the Labs here in NJ quite often. Shes dieing now and we sit for hours and talk about how she used to program in C and how much she loved unix. Hours on end of stories about these guys and different projects. I work with a guy now who worked with her, lots of stories from him as well. Awesome stuff, true geniuses. Gotta thank these guys for changing the world.

    -- chris

    http://elusive.filetap.com

  21. VB and Kernighan's course by Serf · · Score: 4, Informative

    Isn't it odd that I'd recommend to people who want to become programmers to avoid taking Brian Kerningham's class?

    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. ... like what you see on Slashdot every day). It's not just a programming course -- it covers pretty much every aspect of the field of computing and its related subjects, though in somewhat limited depth.

    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.

  22. Re:He teaches VB! by __past__ · · Score: 3, Funny
    It seems he teaches Visual Basic in his programming course at Princeton. I'm a C nut so that came as a shock to me.
    Well, he certainly is in good company.
  23. Slashdot should retitle the article by Comatose51 · · Score: 4, Insightful

    It should read, "Conversation with God (or a God)".

    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.

    --
    EvilCON - Made Famous by /.
  24. Only two real problems in computing? by kbeer · · Score: 3, Interesting

    In the interview KR said:

    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.

  25. Re:he's dead wrong about MS by DunbarTheInept · · Score: 3, Insightful

    Microsoft didn't bring computing to the masses, nor did it hinder it, the HARDWARE platform it was lucky enough to be attached to brought computing to the masses. The openness of the PC hardware made it more affordable than alternatives, and made the hobbiests like it for tinkering, giving the best of both worlds, attracting people BOTH from the 'I want to tinker' camp, and from the 'I want it cheap and don't care about the details' camp. Remember the 80's? The Mac was universally hated by the very same people who today talk about how cool OS/X is for being BSD based. That's because in the '80s the marketplace was driven by people who were willing to learn new software and new languages without even blinking an eye, and so the computer buying decision was driven more by the hardware than the OS that sits on top of it.

    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.

    --

    Don't label something "offtopic" unless you know the topic well enough to tell what's on topic.

  26. Re:Points in article: by sdowney · · Score: 3, Insightful
    He also co-authored The Elements of Programming Style with P.J.Plauger, and early classic on how, and how not, to program.

    The fact that the language under critque was FORTRAN, unfortunately today, obscures the underlying truths they were discussing.

  27. Re:Holy shit, batman, where's your flame-proof sui by babbage · · Score: 3, Insightful
    In The Power of Myth, Joseph Campbell talks about how among pretty much all religions, the laity & clergy get caught up in how their religion is better than all the others (the classical religious wars). However, most of these religions have a mystical wing -- monks, yogis, etc -- and in general the members of these groups are much more willing to reach out to the other groups and not try to paint things in terms of "us vs. them".

    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.