Live data from Hacker News

Getting started with C

not.cafe

41–50 of 106 posts

Re: Getting started with C

#41
post #6

Earlier quoted context omitted.

Just read K&R for 10 minutes.

:-) I wish people would stop recommending this outdated book, along with a few other default goto books (say, the Dragon book). Its super optimistic approach is more about the language K&R wanted C to be than the real thing.

I thought the book by K.N. King was a great introduction to (modern) C [0]. Easy to follow, nice questions at end of each chapter including a few challenges.

———

[0]: http://knking.com/books/c2/index.html

Re: Getting started with C

#42
The immediate next step after "hello world" is GTK programming? This is only "getting started with C programming" if your idea of C programming is copying magic incantations into an editor. Which, sadly, is increasingly being treated as programming in the StackOverflow era.

Re: Getting started with C

#43
post #7
post #3

Introducing newbies to GTK is a great way to show them a lot of code they don't understand, will take a while to understand, and will break in non-obvious ways.

..and that uses non-standard concepts like GObject. Win32 examples would have been peak hilarity. More seriously, I see where the author is coming from, but even historically, GUI code has always been a massive pain in C.

>Win32 examples would have been peak hilarity.

ExAmples

Re: Getting started with C

#45

I think this has merit not only for beginners to programming, but also for programmers who have never touched C. I like that it gets straight to business. Good intro, and props to the author for introducing it on three major desktop platforms, using modern build tools.

Agreed, but not for beginners. I just about fall into the second category (I am a school teacher) - I have published (internally to my school) a couple of VB apps and written a lot of code in Python, but I have never touched C. I understand nearly all of the terminology and feel that I would be able to use this to learn more about C. Beginners (of whom I have taught many!) simply wouldn't be able to use it.

Re: Getting started with C

#46

This is a very strange "getting started" guide to C, and I'm not sure who the intended audience could possibly be. The tone at the start really does seem to be aimed at "absolute beginners" ("[...] programs must be written in a very strict way. Miss a comma and the program will stop working"), but then it quickly gets into the weeds without much explanation. I'm trying to imagine an beginner reading this: The first t…

Wrt "the first line loads the stdio.h function library, which provides the printf() function", you're right, "loading a library" is not clear and, what's worse, is actively misleading as actually we're just telling the compiler that there is a function somewhere called printf that will get "loaded" (linked) later on. I remember that this was one of the things that confused me most about C when I learned it.

>that this was one of the things that confused me most about C when I learned it.

absolutely same, me too. and, there was no good websites / videos on the web back then.

Re: Getting started with C

#47
post #18
post #11

Earlier quoted context omitted.

It kind of depends on what you need out of C. The only real reasons left to use C in the wild are: * Legacy code * Embedded (including drivers, bare metal etc.) * Portability, FFI, etc. Performance used to be another major reason, but in $CURRENT_YEAR, if that's your goal, C++ and Rust are just as performant and there's very little reason not to opt into them. The other major reason to learn C is that it's a great "h…

I would still suggest that people learn C before attempting C++; while someone with C# or Java experience could probably do well in a "modern C++" codebase, as soon as they go off-piste into memory allocation and pointers they're in for surprises. (Is there anyone who learns Rust who isn't already a proficient but frustrated C++ programmer?)

I would recommend you to watch "CppCon 2015: Kate Gregory “Stop Teaching C"" https://www.youtube.com/watch?v=YnWhqhNdYyk

Re: Getting started with C

#48
post #25

That escalated quickly, poor beginners :').

Exactly!

The author assumes the reader doesn't know what a terminal is, and goes from a "hello world" to a cross-platform graphical "hello world" using GTK-3 without explanation.

"Trust me, I don't have time to explain!"

Re: Getting started with C

#49
post #38

Earlier quoted context omitted.

There should only be one way to succeed. Returning 0 for success makes complete sense. You can add layers of macros or enums to sugar coat this but retuning 0 for the success case makes complete sense

Yes, but if you use "magic constants" in your code, you will flunk code review in any halfway competent shop. Always use the constant symbols.

Flunked for returning 0 from main() in C? Not sure that's a competent shop.

Re: Getting started with C

#50

The article uses nano throughout. Is nano a popularly used editor? I have not seen anyone around using nano. I see vim, atom, sublime, vs code but never nano. Just curious if nano is popular. If nano is popular what are its pros and cons?

Personally it's simple and all the important shortcuts are displayed on the screen.

If I ssh into a machine to change a config value I prefer it to vim/vi.

I'm not going to write anything using it, but for quick edits it's perfect.

Post reply on HN