News for hackers. Stuff that matters.
Re:Brian Kernighan on C [video] by kozukumi on Tuesday August 18, 2015 @06:22PM (#10082608)
Indeed. C is a beautiful language. Sure it has its problems if you use it poorly, which is very easy to do, but used properly it is still my favourite language. I find that problems I solve with C are generally solved better in the sense that simpler and easier to read and understand is better.
Re:Brian Kernighan on C [video] by MichaelGG on Tuesday August 18, 2015 @08:04PM (#10082965)
Really? I like C but I'm not sure it's beautiful, compared to a LISP or some sort of ML. And my limited experience says that C programs involve a ton of boilerplate code dealing with copying bytes around. Every time I see a loop doing a series of if/elseifs to parse command line options, I think this is very much not beautiful.
Re:Brian Kernighan on C [video] by vezzy-fnord on Tuesday August 18, 2015 @09:46PM (#10083282)
Lisp and ML represent quite different models of computation.

For a register machine, C can be pretty beautiful.

It's funny you talk about parsing command line options. Plan 9 solved that problem well with the arg(2) macros. [1]

In fact, Plan 9 in general is a premier example of really clean and elegant ANSI C-compatible code. [2]

[1] http://man.cat-v.org/plan_9/2/arg

[2] e.g. https://github.com/0intro/plan9/blob/master/sys/src/libndb/n...

Re:Brian Kernighan on C [video] by kabdib on Tuesday August 18, 2015 @10:41PM (#10083432)
Read the V6 Unix sources. They are seriously pretty. A file system in maybe a thousand lines of code. A scheduler and swap manager, a TTY layer, and device drivers with nearly no waste. You can read the code in an afternoon and understand it and make changes to it.

Even in crusty pre-ANSI C, it's very elegant stuff.

(Then I look at the Bourne shell sources and weep. It's like the author of that was in denial of everything that made C a decent language and wanted desperately to be doing something else)

Re:Brian Kernighan on C [video] by comex on Tuesday August 18, 2015 @10:52PM (#10083464)
Re:Brian Kernighan on C [video] by rdc12 on Wednesday August 19, 2015 @12:00AM (#10083615)
How would XV6 compare to V6 for code elegance? XV6 being a reimplementation, of V6 Unix with ANSI C and targeting X86 instead. But was done by different people as far as I know.
Re:Brian Kernighan on C [video] by coldtea on Wednesday August 19, 2015 @12:09AM (#10083643)
>Really? I like C but I'm not sure it's beautiful, compared to a LISP or some sort of ML.

It's another sense of beauty, the one of talking almost directy to the machine, with few abstractions, and few wastage.

Re:Brian Kernighan on C [video] by justwannasing on Tuesday August 18, 2015 @09:27PM (#10083237)
C doesn't have any problems just because you use it poorly. The only thing with a problem would be the coder.
Re:Brian Kernighan on C [video] by coldtea on Wednesday August 19, 2015 @12:14AM (#10083655)
That's actually ad-hoc cargo-cult, not a scientific assesment.

If a programmer uses a language poorly it can be the programmer but in a lot of cases it can also be the language, that has poorly thought out, conflicting, etc constructs.

There is a field called PL research (part of Computer Science) and researchers can all agree on several problems that C (and what would have been a better design).

Some of the problems are so obvious that the creators of C admitted them too. Some have been corrected in later revisions (C99 etc).

Re:Brian Kernighan on C [video] by justwannasing on Wednesday August 19, 2015 @08:08AM (#10084907)
To blame your tool when you don't use it correctly is a typical fallacy found on forums everywhere. You blame the car for your accident, your parents for being in jail, the hammer for breaking your thumb.
Re:Brian Kernighan on C [video] by stormcrowsx on Wednesday August 19, 2015 @12:19PM (#10086578)
I can actually blame my car for an accident if it didn't respond to my brake press. The hammer can be blamed if the head flew off mid-swing striking my finger instead of the nail.

The tool can be the source of your issue if its not made correctly.

Re:Brian Kernighan on C [video] by justwannasing on Wednesday August 19, 2015 @01:56PM (#10087263)
You're talking about tools that have broken. We're talking about tools that work as advertised.
Re:Brian Kernighan on C [video] by coldtea on Wednesday August 19, 2015 @02:39PM (#10087540)
That's the thing: going beyond what the parent commentor said, tools that "work as advertised" can still be bad.

"Pure wire-mesh electric blanket -- no insulation whatsoever! Only $20 dollars. Will raise the heat with sparks of electricity, plug directly into your 110v outlets!".

Sure, works as advertised. But it's ill concived and will fry anybody trying to use it, either because he wants to or because he is forced to (by his boss or needing to deal with legacy code in the case of a programmer).

The example is contrived to showcase the point, but the gist is: "works as advertised" doesn't mean much with regards to quality or well thought-out architecture.

Re:Brian Kernighan on C [video] by justwannasing on Wednesday August 19, 2015 @05:13PM (#10088542)
If someone can find an out, someone on HN will find it.