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…
Where to begin when learning C? Start by making lots of errors
81–90 of 90 posts
Re: Where to begin when learning C? Start by making lots of errors
#82Earlier quoted context omitted.
I have been looking for a guide like that. I would also appreciate a release of the unfinished version.
This book and its companion (free) online course are great: http://mitpress.mit.edu/books/elements-computing-systems http://www.nand2tetris.org
Re: Where to begin when learning C? Start by making lots of errors
#83Earlier quoted context omitted.
The Mac OS X C compiler is clang, no need to install anything extra. C is insecure by design and IT is still paying for its widespread, when used by developers that don't use the best practices for secure C coding. So when learning how to use it, the best way is to learn those best practices from day one.
Is it installed out of the box? I think you might need Xcode (or at least the command line tools). These instructions may help: http://railsapps.github.io/xcode-command-line-tools.html
No, Joe average user does not compile code.
Re: Where to begin when learning C? Start by making lots of errors
#84By the way, I would love any feedback on this approach and where I should take this further.
As for going further staying with the bare-bones approach, I suppose you'd have to start looking at assembly output and how that fits with what the c-code does. I don't know anything about OSX x86_64 calling conventions etc -- but at least under Linux (and afaik windows) 64bits is a lot more friendly and fun than the mess that was 32bit (and 16bit) x86. There are a couple of great (free) resources on 32bit x86 assemb…
Re: Where to begin when learning C? Start by making lots of errors
#85By making sure to enable all warnings , enable warnings as errors and use a compiler that integrates static analysis like clang.
FWIW: These are the compiler flags I typically use: -std=c99 -Wall -Wextra -Werror -pedantic-errors
Re: Where to begin when learning C? Start by making lots of errors
#86Earlier quoted context omitted.
K&R is the best second C programming book.
And first is?
Edit: Most resources on the Internet are too confusing for beginners. As a matter of fact, people who know C are usually unable to teach C to novices. Good introductory resources for C are rare - which corresponds to C's elitist nimbus.
Re: Where to begin when learning C? Start by making lots of errors
#87Earlier quoted context omitted.
The Mac OS X C compiler is clang, no need to install anything extra. C is insecure by design and IT is still paying for its widespread, when used by developers that don't use the best practices for secure C coding. So when learning how to use it, the best way is to learn those best practices from day one.
A more conservative rule would be not to use C where security is a concern, unless you know what you're doing. When you're writing the kind of software that's an invitation to hackers, like a web application, you should favor a language like PHP or Ruby, which takes things like buffer overflows out of the equation, and even then, you should know what you're doing.
Which if you follow my posts, you will see that I defend C and C++ should be replaced by safer systems programming languages, that exist since Modula-2 days.
Having said this, C and C++ are still used everywhere and will outlive most of us.
So when using them, for whatever reasons, at least one should take care to use the best practices regarding how to write secure and safe code in those languages.
Re: Where to begin when learning C? Start by making lots of errors
#88Re: Where to begin when learning C? Start by making lots of errors
#89[1] mostly for maru, his lisp system, but even tty2html (ascii control -> html) is very clean and elegant.
Re: Where to begin when learning C? Start by making lots of errors
#90Earlier quoted context omitted.
I am using the default `cc` compiler on Mac OS X for this without any flags, are you saying I should something non-stock in this case?
Try passing at least the -Wall and -Wextra flags. For learning, you could also add -ansi, as it will make your compiler be stricter about standards.