Live data from Hacker News

Where to begin when learning C? Start by making lots of errors

morganwilde.svbtle.com

31–40 of 90 posts

Re: Where to begin when learning C? Start by making lots of errors

#31
post #22
post #16

This situation is why there is "hello world"; that program seems trivial but actually has important implications; for instance, that your environment works, that you know how to feed programs to the compiler, that you can actually run the output. I never took "hello world" seriously until I started doing embedded systems work; it's now an extraordinarily important tool for me (I work an anomalously weird number of di…

I once had a particularly slow week at work, and decided to write an article about how "Hello World" works in C. How it really works -- including compiling, linking, system calls, operating system involvement, hardware I/O, communication between ICs, etc. The path from the block of text to photons emitting from the screen, with fairly detailed explanations at every level. I ended up with a 50 page LaTeX document that…

This is the sort of thing I was looking for when I started wanting to understand the 'big picture' of computer programming. Would be great if you posted it!

Re: Where to begin when learning C? Start by making lots of errors

#32
post #22

Earlier quoted context omitted.

I once had a particularly slow week at work, and decided to write an article about how "Hello World" works in C. How it really works -- including compiling, linking, system calls, operating system involvement, hardware I/O, communication between ICs, etc. The path from the block of text to photons emitting from the screen, with fairly detailed explanations at every level. I ended up with a 50 page LaTeX document that…

I second the motion to post the unfinished guide! Perhaps on Github where some other HN guys can make it complete for you. Regardless, I think it's a great idea, and would really give insight as to why things work the way they do, instead of us just seeing Hello World!

Posting it on Github is a fantastic idea.

Re: Where to begin when learning C? Start by making lots of errors

#33
post #7

I learned C by reading K and R and doing the book's exercises . . . on paper. At the time I didn't have access to a C compiler, so I wrote them all out in a notebook. A month later I got a job at a shop that was running Unix, and got the chance to type my programs in and try them. I had a lot of things wrong. It took me a while to understand the difference between control-D and EOF, for instance (how embarrassing). B…

People don't like K&R? I can understand it not being suitable for children and the very beginner, but it's one of a very few programming books that is useful, succinct, pragmatic, doesn't get bogged down in APIs, and is written clearly.

(The companion book "Programming in the UNIX environment" is the get-you-started guide from the very beginning, although it assumes 1970s terminal defaults)

Re: Where to begin when learning C? Start by making lots of errors

#34
post #25

Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.

Are you trying to dispute the fact that `main()` is THE entry point for any C program? I'd be interested in hearing a more comprehensive explanation.

Re: Where to begin when learning C? Start by making lots of errors

#35
post #25

Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.

-1, Learn don't guess.

http://stackoverflow.com/questions/2627511/why-do-c-compiler...

Re: Where to begin when learning C? Start by making lots of errors

#36

By the way, I would love any feedback on this approach and where I should take this further.

I'm surprised no-one's mentioned it yet, but this approach should go well with Zed Shaw's Learn C the Hard Way:

  http://c.learncodethehardway.org/book/

Re: Where to begin when learning C? Start by making lots of errors

#38
post #17

Earlier quoted context omitted.

And probably -Werror (all warnings become errors, breaking compilation). Fun post. Now I know why everyone was raving about the clang error-messages: echo "void main() {}" > main.c gcc -Wall -Werror --std=c99 main.c main.c:1:6: error: return type of ‘main’ is not ‘int’ [-Werror=main] cc1: all warnings being treated as errors clang -Wall -Werror --std=c99 main.c main.c:1:1: error: 'main' must return 'int' void main()…

Nice suggestion. Although I can't seem where one would have to look for those "pretty colours" you mentioned, I certainly can't see any of them on my Mac terminal...

Can't help you there -- but I don't think I've set any exotic terminal variables or anything like that, and I get this:

http://i.imgur.com/BjWj7h6.png

FWIW, I have:

    COLORTERM=gnome-terminal
    TERM=screen
and Debian takes care of my termcap etc, afaik.

Re: Where to begin when learning C? Start by making lots of errors

#39
post #25

Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.

Are you trying to dispute the fact that `main()` is THE entry point for any C program? I'd be interested in hearing a more comprehensive explanation.

To some extent, _start is (https://blogs.oracle.com/ksplice/entry/hello_from_a_libc_fre...), so you can make a working program that has no main(). And in general entry points are a quirky land heavily dependent on OS and compilation stack.

Re: Where to begin when learning C? Start by making lots of errors

#40
post #35
post #25

Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.

-1, Learn don't guess. http://stackoverflow.com/questions/2627511/why-do-c-compiler...

Yeah, got me making the same error as I was complaining about. Thanks for the link though.
Post reply on HN