Live data from Hacker News

C Craft: C is the desert island language.

www-cs-students.stanford.edu

81–90 of 116 posts

Re: C Craft: C is the desert island language.

#81
"Other object-oriented programming preachers rebelled in practice, by spending most of their time in “fun” languages like Perl or Python. After all, who enjoys the boilerplate and verbosity of Java?"

- What has the verbosity of java vs python have to do with the validity of object oriented programming?

"New languages like Erlang and Go have become popular despite not being object-oriented. In fact, Joe Armstrong, inventor of Erlang, explains why OO sucks."

- Actually later Joe Armstrong came back and said the following:

"Actually it’s a kind of 180 degree turn because I wrote a blog article that said "Why object-oriented programming is silly" or "Why it sucks". I wrote that years ago and I sort of believed that for years. Then, my thesis supervisor, Seif Haridi, stopped me one day and he said "You’re wrong! Erlang is object oriented!" and I said "No, it’s not!" and he said "Yes, it is! It’s more object-oriented than any other programming language." And I thought "Why is he saying that?" He said "What’s object oriented?" Well, we have to have encapsulation, so Erlang has got strong isolation or it tries to have strong isolation, tries to isolate computations and to me that’s the most important thing. If we’re not isolated, I can write a crack program and your program can crash my program, so it doesn’t matter.

You have to protect people from each other. You need strong isolation and you need polymorphism, you need polymorphic messages because otherwise you can’t program. Everybody’s got to have a "print myself" method or something like that. That makes programming easy. The rest, the classes and the methods, just how you organize your program, that’s abstract data type and things. In case that the big thing about object-oriented programming is the messaging, it’s not about the objects, it’s not about the classes and he said "Unfortunately people picked up on the minor things, which is the objects and classes and made a religion of it and they forgot all about the messaging."

Re: C Craft: C is the desert island language.

#82
post #7

I'm deeply conflicted about this article because I agree with many of its premises. For instance: that C is superior to full-blown C++, that object-oriented programming is no panacea, that simplicity is good. I have serious concerns, however, especially with the first page and the first few chapters. - They support the biases of the myopic programmer who believes that now he or she knows C, they know everything one m…

>that C is superior to full-blown C++

Couldn't disagree more. C++ has a much better type system than C. For many C++ programmers (myself among them) C++ was less about OO and more about giving C programmers the ability to create new types that have the powers of the built in types. I can have strings with proper string schematics instead of an array of chars that is null terminated by convention (i.e. can't be type enforced).

Re: C Craft: C is the desert island language.

#83
post #66
post #44

Earlier quoted context omitted.

> C++ is object-oriented and C isn't Neither is object-oriented, except C++ allows you to easily work with objects unlike C, where you have to reinvent them. It is easy for me not to pick C if I need more abstraction than a struct with pointers to functions can provide.

"Neither is object-oriented" And thus the discussion devolves into a pissing contest over whose programming language is the most object oriented... Look, one can reasonable agree to disagree on the definition of 'object-oriented', but I don't see how you can seriously state that C++ is not object-oriented. According to the most broadly accepted superset of what constitutes 'object-oriented', C++ is object-oriented (o…

You're right, I meant that it's not strictly object-oriented, it supports multiple paradigms, with OOP being one of them. :)

Re: C Craft: C is the desert island language.

#84
post #76
post #60

Earlier quoted context omitted.

It is fascinating to see people having 24+" monitors -- and seeing ca 30 lines of code on their screen, because of the real estate eaten by their IDEs. To add maiming to injury, these guys write in modern Cobol (a.k.a Java). Not to mention that they can't print the code -- since it is 150+ chars wide(!) -- and browse it at a cafe. (I love my iPad, but It'll be iPad 3 before it is half as nice for browsing code [edit:…

"Not to mention that they can't print the code -- since it is 150+ chars wide(!) -- and browse it at a cafe." You can't print code longer than 150 characters wide? Since when?

Sigh, are you trolling or new? OK, I'll answer.

The point of printing and browsing code is that it is easier and nicer than to read it on a screen (you'll have a portable with you at the cafe anyway to search, annotate, etc.) If you get lots of broken lines, it isn't readable.

Point was, you lose a capability with long lines -- a nice way to go over code. This is important for many of us.

Edit: Point jedsmith, write it off as grumpy-old-man syndrome. Sigh, I just can't get that this isn't understood by everyone, anymore.

Re: C Craft: C is the desert island language.

#85
post #78
post #27

Earlier quoted context omitted.

I am skeptical of the claim that verbosity for its own sake aids comprehension. To borrow an example from Rob Pike, reading buf[thisVariableIsTheLoopIndex] = foo(...); is no more obvious than buf[i] = foo(...); and indeed is more likely to slow the programmer down by killing his train of thought and mental flow.

So I suppose this leads Rob Pike to use one-character names for all the variables and functions in his programs? Such programs must be a joy to read.

His code actually _is_ a joy to read and use. Some of it requires more than a passing scan. But that's true of any code worth reading - if you don't need to scan it twice, it's most probably useless and bureaucratic, and could be done away with if a better design is used.

Re: C Craft: C is the desert island language.

#86
post #84
post #76

Earlier quoted context omitted.

"Not to mention that they can't print the code -- since it is 150+ chars wide(!) -- and browse it at a cafe." You can't print code longer than 150 characters wide? Since when?

Sigh, are you trolling or new? OK, I'll answer. The point of printing and browsing code is that it is easier and nicer than to read it on a screen (you'll have a portable with you at the cafe anyway to search, annotate, etc.) If you get lots of broken lines, it isn't readable. Point was, you lose a capability with long lines -- a nice way to go over code. This is important for many of us. Edit: Point jedsmith, write…

You could have made that point without the personal attack.

Re: C Craft: C is the desert island language.

#87
post #68

Desert island language, as in "like trying to build a hut, and manage your hunting and gathering with the Swiss Army knife that happened to be in your pocket"? I agree that for Torvalds work it is the only sane choice. But I'm not writing kernels.

It's along the lines of "if you were stuck on a desert island and could only have one whatever, which would it be?"

So if you had to choose one programming language to do all of your work in, which language would it be?

Re: C Craft: C is the desert island language.

#88

Earlier quoted context omitted.

I see your Java, and raise you Objective-C: NSString *thing = [NSString stringWithFormat:@"Result: %@", [foo someoneCouldntComeUpWithAShorterNameWithZipcode:08205 name:@"larry" parcels:5]]; NSDictionary *request = [NSDictionary dictionaryWithObjectsAndKeys:@"iphoneapp/0.1", @"User-Agent", @"news.ycombinator.com", @"Host", nil]; This isn't to kick off pet language wars, by the way, just to point out that my OCD tic to…

"just to point out that my OCD tic to wrap to 80 characters has absolutely zero place in Xcode. Or Java." Dude. Are you still using CGA? Unless for your IDE you're running emacs on your wristwatch or phone there's no place for that shit in the real world, and you have no excuse. Ditch that green cathode ray tube, here, have 50c and go buy yourself a real monitor. :D

I work on a 27" iMac with a 27" second monitor, and a third 19" on a Linux box with Synergy. My primary language is Python, so I do have a place for that shit in the real world.

Re: C Craft: C is the desert island language.

#89
post #42

Earlier quoted context omitted.

I'd write the code in Python (or indeed any sensible modern language). foo = {}

and then you get an int instead of a string and your python app explodes. let's not start on "sensible modern" languages.

Yes, you do get bugs in Python due to variables being the wrong type... however the time it takes to fix them is vastly less than the time it takes to write the reams of boilerplate that Java requires (not to mention the cognitive overload caused by said reams of boilerplate).

My ideal would be an optionally typed language.

Re: C Craft: C is the desert island language.

#90
post #82
post #7

I'm deeply conflicted about this article because I agree with many of its premises. For instance: that C is superior to full-blown C++, that object-oriented programming is no panacea, that simplicity is good. I have serious concerns, however, especially with the first page and the first few chapters. - They support the biases of the myopic programmer who believes that now he or she knows C, they know everything one m…

>that C is superior to full-blown C++ Couldn't disagree more. C++ has a much better type system than C. For many C++ programmers (myself among them) C++ was less about OO and more about giving C programmers the ability to create new types that have the powers of the built in types. I can have strings with proper string schematics instead of an array of chars that is null terminated by convention (i.e. can't be type e…

That's indeed a great feature of C++. And there are more great features (auto-destructors/RAII, better "const", parameterized types).

But I find other features/interactions in C++ are unnecessary and even harmful (inheritance and virtuals, typedef of references, C++'s useless implementation of checked exceptions). Templates are implemented pretty badly (Haskell's type-classes a.k.a the discarded "Concepts" could have been used to reduce the auto-generated code duplication). The "rule of three" (Copy constructors, assignment, destructors) is not enforced by the compiler and is a great error-prone hole.

C++ exceptions are problematic, and I actually prefer C's lack of mechanism, where it is completely clear (as long as nobody uses "longjmp") what the control flow is, from simple static analysis or code review. In C++, you have to keep all of the code exception-safe, but due to interaction with external libraries, it can be tough and even error-prone. Cleanup order is sometimes very important and also implicit when using exceptions, making review of its correctness much harder.

Post reply on HN