TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

68 pointsby morganwildeover 11 years ago

16 comments

tptacekover 11 years ago
This situation is why there is &quot;hello world&quot;; 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.<p>I never took &quot;hello world&quot; seriously until I started doing embedded systems work; it&#x27;s now an extraordinarily important tool for me (I work an anomalously weird number of different environments).
评论 #6745091 未加载
评论 #6746579 未加载
评论 #6746738 未加载
kabdibover 11 years ago
I learned C by reading K and R and doing the book&#x27;s exercises . . . on paper. At the time I didn&#x27;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.<p>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). But the 30 days I spent without a compiler made me <i>think</i> about program behavior.<p>I&#x27;m not saying this is a great way to learn a language, but it can be done.<p>I keep hearing people complain about K and R being &quot;a terrible book.&quot; For me it was perfect: pragmatic, succinct, with great examples and good exercises.
评论 #6744837 未加载
评论 #6745201 未加载
评论 #6746001 未加载
评论 #6745129 未加载
评论 #6744836 未加载
评论 #6744813 未加载
pjmlpover 11 years ago
By making sure to <i>enable all warnings</i>, <i>enable warnings as errors</i> and use a compiler that integrates static analysis like clang.
评论 #6744759 未加载
评论 #6744926 未加载
评论 #6744755 未加载
评论 #6745084 未加载
foster1890over 11 years ago
Where to begin when learning C? Start at <a href="http://c.learncodethehardway.org/" rel="nofollow">http:&#x2F;&#x2F;c.learncodethehardway.org&#x2F;</a>. It&#x27;s going to be tough to top Zed Shaw&#x27;s approach. The best way to learn code is by writing code.
评论 #6746735 未加载
评论 #6746187 未加载
yetanotherphdover 11 years ago
I think I have some ingrained fear of making errors, from the days where a simple error might cause your program to chew through your whole hard drive. Actually I don&#x27;t know if that was ever the case, but that&#x27;s how I felt.<p>Anyway, the hardest step for me in learning a language is when I take some running code and make one change to see what happens. Once I get in the swing of it, it gets much easier, but that first step is still hard to do.
vparikhover 11 years ago
In order to for people to really understand C and be proficient in it very clearly, I always recommend that they learn the basics of programming (memory, basic types, looping structures and array manipulation) in a simple assembly language such as 6502. This helps immensely with understanding pointers and deciphering the many cryptic C compiler messages.
b0rsukover 11 years ago
Install Valgrind. It makes error messages a lot less cryptic (my #1 problem with C... not that&#x27;s it&#x27;s limited to C). If you don&#x27;t get proper feedback, it&#x27;s not learning, just banging your head against the wall.
评论 #6746297 未加载
评论 #6746093 未加载
idoescompootersover 11 years ago
Currently, I&#x27;m learning Python and have been learning it for over a year now. I&#x27;ve been thinking about moving to C as my next language. Is this a good idea? I&#x27;m eventually going to want to learn C++, but I&#x27;m not going to learn Java until I have to. Also, what are some really good C learning resources? I know there&#x27;s K&amp;R and learncthehardway.org
eonilover 11 years ago
I thinks this is a good approach. Checking most of possible exceptional cases while following regular learning course.<p>Errors = safety nets are usually the main reason to make stiff learning curve. This would be a great help for them.
agumonkeyover 11 years ago
As other people said earlier, reading existing code is great, when you have good sources. I&#x27;m an almost noob in C, and currently reading Ian Piumarta sources[1], I find they&#x27;re superb in presentation and design.<p><a href="http://piumarta.com/software/" rel="nofollow">http:&#x2F;&#x2F;piumarta.com&#x2F;software&#x2F;</a><p>[1] mostly for maru, his lisp system, but even tty2html (ascii control -&gt; html) is very clean and elegant.
mtdewcmuover 11 years ago
A minor point, but important to understand: the error came from the linker, not the compiler. It compiled just fine.
评论 #6746672 未加载
morganwildeover 11 years ago
By the way, I would love any feedback on this approach and where I should take this further.
评论 #6745437 未加载
评论 #6745239 未加载
评论 #6746732 未加载
laveurover 11 years ago
This all of this!
lhgaghlover 11 years ago
This is stupid. You should learn C properly (know how to avoid undefined behavior) or not at all. Exception if you&#x27;re doing something that can tolerate remote code execution.
passfreeover 11 years ago
You should learn go instead of C.
评论 #6746231 未加载
mbqover 11 years ago
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.
评论 #6745232 未加载
评论 #6745208 未加载