Live data from Hacker News

Getting started with C

not.cafe

81–90 of 106 posts

Re: Getting started with C

#81

Earlier quoted context omitted.

Maybe there aren't any good alternatives to "read this go to book as the first book on the topic". Prove me wrong. (Please)

If an absolute beginner were to use K&R as a start they'd be learning C from 35 or so years ago. It's well written, but not helpful as a reference. Even something as simple as how a function is organized has changed. C Programming: a Modern Approach teaches C89 and C99, pointing out the differences in features when appropriate. Having used it myself this year, I found it much more helpful than K&R

If you start with the second edition (C89 / "ANSI C"), you'll discover that C has barely changed.

Re: Getting started with C

#82

May be an unpopular opinion, but K&R 2nd edition is still the best beginner's tutorial for a fast start into the C for me. As the knowledge starts to build, better learning material and experience will also be consumed. If I had read this lightning fast guide, I would be a bit lost. After displaying "Hello, world" on the terminal, do I really want to learn how to display "Hello, World" in a GTK window?

The writer intended this tutorial for absolute beginners without any experience in programming - which is, to be honest, totally bonkers! It's not a bad guide for someone trying to learn C as their second/third language though, it teaches you how to prepare a build environment to use third-party libraries in C, which is seldomly documented this clearly compared to other random articles on the Internet.

Re: Getting started with C

#83
post #24
post #18

Earlier quoted context omitted.

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

Completely agree, that was part of the point I was making, for example, I doubt I would ever have understood RAII had I never seen malloc. Parent was suggesting they are already a programmer, so I assumed they already had at least a grasp of how pointers and manual memory management work. If one happens to lack such knowledge, I agree learning C is an excellent first step.

I understood malloc very well long before RAII made sense to me.

I think what made RAII seem like a good idea was seeing a large C code base at a major company which had a consistent approach to cleanup and error handling. It's very possible to write good code that way, but it takes manual effort, discipline, consistency. At that point I understood that RAII was about letting the compiler handle what I was already doing in C.

Re: Getting started with C

#84
post #78

The absolute beginner technical guide may be the most difficult kind of writing there is. You have to know what's already in the head of the absolute beginner. If it's garbage, you need to set that straight before anything else can happen. You also have to know what's not in the head of an absolute beginner. Then you need to fill the gaps with background material. Not too much or your audience will tune out. Not too…

Yea, if I were writing something with the bold title "Absolute Beginner's Guide To..." I'd want to test it on my 8-year old who only knows how to launch the web browser and Minecraft. If she can use it successfully to cobble together a working Hello World program, then it's indeed an absolute beginner's guide.

Re: Getting started with C

#85
post #5
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.

I would be really interested in a course that actually holds true to the premise in the title here. I know my way around the JVM and python and started learning a little Rust on the side. However, I feel the need to at least dive my toes into C for a couple of weeks for completeness sake. Do you have a recommendation for something that is a little less than a book and a little more than learnCin10minutes?

Personally I think C isn’t useful to know topically. It really only became useful once I had a basic grasp on computer architecture, assembly language, and operating systems. Then suddenly its use made a lot more sense to me. If you’re not thinking about those things when writing C then you’re probably using it for the wrong reason, and there’s probably a better tool for the job.

Re: Getting started with C

#86
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.

Being able to produce a GUI app may be more interesting to beginners than crunching some IO with basic console C program. Really, you don't need to understand GObject much to just use GTK+. Surface understanding suffices, and you can structure your program at first in such a way to not need to create custom GObject based classes/interfaces.

Beginners will probably be a bit lost, because the article doesn't go into any depth about event loop, retained mode GUI, GTK signals/handlers, nor does it link to GTK+ docs that would explain each part of the code, etc., etc.

Re: Getting started with C

#87
post #65
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…

Strong disagree. Unless you're using it as "C with classes", C++ is a nightmare hell language that you should only use if you're forced to by your environment. Stay far away. C is a fine language, but it is from the 60s and 70s and feels like it. Rust is very nice, although poor for half-assed prototyping (which is actually maybe a good thing). Both are fine choices for systems-level programming.

I've been working on this which you might find of use:

https://github.com/glouw/ctl

Re: Getting started with C

#88
post #72

https://viewsourcecode.org/snaptoken/kilo/ This is the "getting started with coding" guide that I give to people who ask me about these kind of things. This is a defense mechanism - I tell them that I'll help them get started with a career in coding if they return me their completed text editor. So far nobody has, so maybe it's not the best beginner tutorial? I still thought it was a great tutorial.

I have completed about 45 steps of this tutorial, totally love this!! Antirez is a total wizard. This is totally a no bullshit intro to C.

Re: Getting started with C

#89
Despite some (already mentioned) shortcomings, I like it: it provides a simplified "real life" big picture of the whole process with sample tools; a thing that (in my experience) every other "getting started" guide seems to miss (most of them just mentions what is a makefile).

I also like the overall format of the website and the radio feature is a nice touch. I'll visit it again in the future, out of curiosity.

A follow-up article may extend it with collaboration (git) or may delve in either Unix-like (e.g. with the GNU utils etc) or Windows, or both. But the author should first address the highlighted shortcomings...

Re: Getting started with C

#90
post #78

The absolute beginner technical guide may be the most difficult kind of writing there is. You have to know what's already in the head of the absolute beginner. If it's garbage, you need to set that straight before anything else can happen. You also have to know what's not in the head of an absolute beginner. Then you need to fill the gaps with background material. Not too much or your audience will tune out. Not too…

Otherwise known as The Curse of Knowledge.

The reason so much documentation is garbage.

Post reply on HN