Live data from Hacker News

Beej's Guide to C Programming (2007)

beej.us

21–30 of 81 posts

Re: Beej's Guide to C Programming (2007)

#21
post #20

Very good. A pet peeve is that it consistently says "sizeof()", like this: You can use the sizeof() operator to determine how many bytes of memory a certain type uses. (I know, sizeof() looks more like a function than an operator, but there we are.) BUT: sizeof does not in fact need the parentheses always! Syntactically they are part of the argument, and only needed when the argument is a type name, i.e. the argument…

About casting the malloc() : http://c-faq.com/malloc/mallocnocast.html

Re: Beej's Guide to C Programming (2007)

#22
post #2

Beej's Guide to Network programming ( http://beej.us/guide/bgnet/ ) is also pretty good. It was effectively used as the textbook in my networking class. (There was also an actual textbook, but almost nobody bothered to read it.)

I will also share praise for Beej. My network programming course was in C, and most of my programming experience had been in Java, Python, and JavaScript. This guide was probably the reason I passed.

Re: Beej's Guide to C Programming (2007)

#23
post #20

Very good. A pet peeve is that it consistently says "sizeof()", like this: You can use the sizeof() operator to determine how many bytes of memory a certain type uses. (I know, sizeof() looks more like a function than an operator, but there we are.) BUT: sizeof does not in fact need the parentheses always! Syntactically they are part of the argument, and only needed when the argument is a type name, i.e. the argument…

About casting the malloc() : http://c-faq.com/malloc/mallocnocast.html

Yeah, that's a good resource. I also recommend https://stackoverflow.com/questions/605845/do-i-cast-the-res....

Re: Beej's Guide to C Programming (2007)

#25
post #2

Beej's Guide to Network programming ( http://beej.us/guide/bgnet/ ) is also pretty good. It was effectively used as the textbook in my networking class. (There was also an actual textbook, but almost nobody bothered to read it.)

It's definitely worth reading, but be aware that it's quite old-fashioned in that it focuses entirely on blocking I/O and select(). Also this page fails to explain why you would call shutdown(): http://beej.us/guide/bgnet/output/html/multipage/shutdownman...

What has replaced select()?

Re: Beej's Guide to C Programming (2007)

#26
post #2

Beej's Guide to Network programming ( http://beej.us/guide/bgnet/ ) is also pretty good. It was effectively used as the textbook in my networking class. (There was also an actual textbook, but almost nobody bothered to read it.)

It's definitely worth reading, but be aware that it's quite old-fashioned in that it focuses entirely on blocking I/O and select(). Also this page fails to explain why you would call shutdown(): http://beej.us/guide/bgnet/output/html/multipage/shutdownman...

Do you perhaps have some examples of some more modern resources or examples we can consult? I would appreciate it.

Re: Beej's Guide to C Programming (2007)

#27
post #25

Earlier quoted context omitted.

It's definitely worth reading, but be aware that it's quite old-fashioned in that it focuses entirely on blocking I/O and select(). Also this page fails to explain why you would call shutdown(): http://beej.us/guide/bgnet/output/html/multipage/shutdownman...

What has replaced select()?

epoll on linux. Other apis on other oses.

More reading: http://www.kegel.com/c10k.html

Re: Beej's Guide to C Programming (2007)

#28
post #24

As someone who currently works with C# - is there much of a point to learning C? I've always found it interesting, but never had a reason to jump into it.

While C remains the single most important programming languages of all time, its share of popularity is shrinking, giving way to C++, C#, Java, and Swift (from Objective-C).

Nevertheless, I don't think anyone should call themselves a (true) programmer unless they know C.

C is easy to learn, because it's a small language. If you are not new to programming, pretty much all there is to know is in the second edition of the K&R book.

Re: Beej's Guide to C Programming (2007)

#29
post #28
post #24

As someone who currently works with C# - is there much of a point to learning C? I've always found it interesting, but never had a reason to jump into it.

While C remains the single most important programming languages of all time, its share of popularity is shrinking, giving way to C++, C#, Java, and Swift (from Objective-C). Nevertheless, I don't think anyone should call themselves a (true) programmer unless they know C. C is easy to learn, because it's a small language. If you are not new to programming, pretty much all there is to know is in the second edition of t…

I've been using C# on a daily basis for ~2 years at this point. I've had that book on my wish list for awhile, but wasn't sure if I would make use of it - I'll likely order it soon.

Re: Beej's Guide to C Programming (2007)

#30
post #24

As someone who currently works with C# - is there much of a point to learning C? I've always found it interesting, but never had a reason to jump into it.

First, what is programming? Programming is basically writing out instructions with names, verbs, if/else's, and loops. The latter three are not much different in all languages, but names! The programs we wrote -- the style, details, and effectiveness -- depend on the understanding of entities behind those objects. For example, the name Michael, if we assume he is intelligent and equipped with common sense, we may choose to instruct him in a high-level or declarative way. But if we assume he is dumb we may have to instruct him in a more detailed and imperative way and often it is the easier and more effective way. The state of programming: All entities are in fact very dumb, but programming languages often disguise it and make you think they are smart (smarter than they really are). If you don't care about efficiency and even how it is actually done, as many frameworks and languages designer wished, the more deceivingly smart the entities appear, the better, so the programmer can program without worry about how it is actually being done with a good conscience. But as soon as the programmer start to care about how it is actually get done, or as soon as they desire some control -- out-of the inflated self-respect that they are smarter than the language and framework, then they need the understanding of their entities in details. With most higher level languages (with C#, the libraries, and framework), the objects are very complex and it is difficult or practically impossible to fully understand (due to the fact that we are only human), so the programmers are often doing programming with an assumed understanding (in reality it is just a religion). It is still programming, but programming with trust and faith. With C (the language, not some libraries or framework) however, the subjects are simple -- 1-byte integer or 8-byte integer, 4 -byte float or 8-byte float, and even names representing functions are simple entities. It is possible to fully understand your entities when programming in C. They are dumb as minions, but you are in 100% control. Only the experience of programming with entities that you truly understand and fully in-control can reward you with the certain zen of programming -- the demigod-like joy of producing and enjoying fruits that you are in control of near 100% of its creation.

So, it depends on your objectives in programming. You don't need C or even C# if all you care is a job or an end objective (in fact, you would very much like to skip the programming part if possible). But if you care about programming as an activity of love, then the experience with C -- especially the one with few dependence of third-party libraries -- is uniquely rewarding.

Post reply on HN