Ask HN: Should I learn C? | Hacker News [PDF]

Jul 17, 2010 - Would it be worth my time to learn C (C++ possibly?)? ... I'm aware I will have to learn at least C for c

3 downloads 29 Views 165KB Size

Recommend Stories


Which-programming-language-should-i-learn-first-pdf
Keep your face always toward the sunshine - and shadows will fall behind you. Walt Whitman

What Questions Should I Ask When Choosing a Wealth Advisor?
Knock, And He'll open the door. Vanish, And He'll make you shine like the sun. Fall, And He'll raise

Roof hood HN HN
Almost everything will work again if you unplug it for a few minutes, including you. Anne Lamott

(PDF)Download Learn C the Hard Way
I cannot do all the good that the world needs, but the world needs all the good that I can do. Jana

Five compliance questions every ceo should ask
You have to expect things of yourself before you can do them. Michael Jordan

Quickly Learn C# Programming
Silence is the language of God, all else is poor translation. Rumi

One thing I ask
Life isn't about getting and having, it's about giving and being. Kevin Kruse

ASSE Kuwait Chapter -> News -> News & Information -> KNPC C&MD [PDF]
May 16, 2013 - Greetings to You. You are aware that ASSE Kuwait Chapter has been awarded the prestigious KNPC C&MD award under the category :Social Group/Institution and local community. This is first time we have been recognized by an award by Kuwai

[PDF] Download Growth Hacker Marketing
If you are irritated by every rub, how will your mirror be polished? Rumi

[PDF] The Hacker Playbook 2
Never let your sense of morals prevent you from doing what is right. Isaac Asimov

Idea Transcript


Hacker News new | comments | show | ask | jobs | submit

login

Ask HN: Should I learn C? 55 points by lukeqsee 2748 days ago | hide | past | web | favorite | 94 comments

I'm a recent high school grad going into college as a comp sci major. I have 2 years experience in Python and JS. Would it be worth my time to learn C (C++ possibly?)? (Or maybe you have another language that would be more profitable now.) I'm aware I will have to learn at least C for college, but is it something I should learn now? I'm looking for your opinion because a lot of you have either gone through a comp sci degree or have done some programming in C. Thanks HN!

mechanical_fish 2748 days ago [-]

Yes, you should learn C. And enough assembly language to understand aspects of how C works, like what a "stack frame" is. Now is a great time to start. Go find K&R, fire up Linux and write and compile "hello, world". Then keep going until you experience your first segmentation fault. ;) (Do not study C++ at this point. Study C. These things turn out to be very very different.) sreque 2747 days ago [-]

At my university we have a course that goes over all the levels of abstraction between the hardware and systems-level UNIX programming. I never took the class, but I followed the course book on my own and it proved to be one of the most enlightening self-learning experiences I've had with programming. The book is Computer Systems: A Programmer's Perspective, and I highly recommend it. I've found that even though I now spend most of my time programming in higher level languages, my understanding of C and assembly, compilers and debuggers, the virtual memory model and system memory hierarchy, and CPU architecture are still very valuable in helping me reason about my code and how it interacts with the rest of the system. I also still have developers at work on the C development team occasionally come ask me code questions, and often the answers to their questions come down to understanding one of the above better. If you can master multiple levels of abstraction you will be a much more effective developer. TeHCrAzY 2747 days ago [-]

ISBN for anyone interested: 978-0130340740 jolan 2748 days ago [-]

> Then keep going until you experience your first segmentation fault. Or your first cryptic compiler error. I'm pretty sure mine was "numeric constant contains digits beyond the radix". Goladus 2747 days ago [-]

For learning C I strongly recommend C: A Reference Manual (Harbison and Steele), not K&R. Read K&R for context, sure, but Harbison and Steele is more up-to-date and comprehensive while still a concise language reference. That book can basically answer almost any question about the language standard that isn't compiler-specific. http://www.amazon.com/Reference-Manual-Samuel-P-Harbison/dp/... silentbicycle 2747 days ago [-]

Read both, and then C Interfaces & Implementations by Hanson. Best advanced C book, ever! awongh 2747 days ago [-]

You, and it seems most others here are suggesting that you learn C by doing some systems programming; I was thinking of dabbling in C, but maybe starting out by doing something with AVR/arduino or something like that.... Is the C your write for embedded stuff fundamentally different from the C you write for linux? I would eventually like to know how to write a php module or something like that, is starting by hacking on linux or some other os a better start? Rusky 2747 days ago [-]

I think the real value of C is how it deals with lower-level stuff- embedded systems, drivers, kernels, etc. Writing something like a PHP module would make more sense in another language (and then wrapping it in C if you need to). SamAtt 2746 days ago [-]

I'm sorry but I think this is bad advice. I'm not against learning C in general. I think everyone should. But his question isn't should he learn C ever it's should he learn it in his spare time between High School and College The best thing I did for myself during college was to program on my own time in languages that people use out in the world. Learning C, Assembly, Data Structures and all the rest is great but when you get out into the world it helps to have been programming in Python or Ruby for 4 years and be experienced in that. So I say "No". Learn C in school but in your free time I suggest you learn Python (Here's a great starter book I used when I taught a class on it: http://www.amazon.com/Python-Programming-Absolute-Beginner-3...) lukeqsee 2746 days ago [-]

I already am fluent in Python. I've used it in real world stuff for 2 years. I also am in the midst of learning Ruby (with _Why's guide). riso 2747 days ago [-]

A good book that goes over both C and assembly is "Hacking: The Art of Exploitation". The first 100 pages alone will give you a solid understanding of what is happening behind the code. swolchok 2747 days ago [-]

I can't recommend that book for learning C and assembly. Its coverage is amateurish and unprofessional, which are indicative of or at least encourage fuzzy thinking. You can read it for a time-efficient overview, but please don't go thinking you know C or assembly if that's all you've read. riso 2747 days ago [-]

For clarification, the recommendation was not for learning C and assembly, but rather to get a good feel for what is happening at a lower level ie. stack frames, stack pointers, etc. awongh 2747 days ago [-]

since I had to look it up, maybe others don't know: K&R refers to: The C Programming Language by Brian W. Kernighan and Dennis M. Ritchie http://www.amazon.com/exec/obidos/ASIN/0131103628/thedinosau... SwellJoe 2747 days ago [-]

I feel compelled to add that I tried to learn C from a half dozen other books over several years (starting in childhood, so it was probably a bit early), but it never made any sense until I worked through K&R. Suddenly, C seemed like a beautiful and simple language (which it is). There are many subtleties, particularly in the macro system, that are not covered at all by K&R, but it is, by far, the best choice for learning C. In other words: Don't waste your time trying to learn from anything other than K&R, at first. It's just the most concise text available...C is a concise language, and it is not well-served by big fat books. RiderOfGiraffes 2748 days ago [-]

Absolutely, yes. + From the point of view of Python or Java (say), it's close enough to assembly language to let you understand how things might work; + If you need speed or control over hardware, sometimes it's your best route to extend whatever you're working in; + In many jobs you'll be the only one who has the knowledge to do unusual things, hence you'll be more valuable; + It gives you another point of view when designing systems; + You say you'll need it for college - learn it now; + A spread of languages is critical if you want to master programming. You can carve out a perfectly good programming career without knowing C, but it's always of benefit and value to get a wide range of skills. Some recommend: + Pure OOP: perhaps smalltalk or Self + Pure Functional: perhaps Haskell (non-strict) or ML (strict) + Pure Imperative: perhaps C + Pure Logic: perhaps Prolog Other hybrid languages are useful and perhaps more productive, but it's the ideas that really matter while you're still learning. macrael 2747 days ago [-]

I'd just add that c teaches you about pointers and how objects are stored in memory which is useful in whatever language you end up using. gtani 2747 days ago [-]

+1 learn different paradigms. Besides reading language tutorials, read some PLT (prog lang theory on Lambda the ultimate, and these survey type things. (And you'l frequently see ruby, python, erlang folks say "We have to drop down in C to get plausible performance" or "this algo was already thoroughly tested in C or java". You kinda have to know C and java to get s##t done. http://mvanier.livejournal.com/998.html http://matt.might.net/articles/best-programming-languages/ http://www.info.ucl.ac.be/~pvr/VanRoyChapter.pdf http://www.info.ucl.ac.be/~pvr/paradigmsDIAGRAMeng101.pdf http://www.slideshare.net/brweber2/functional-concepts-for-o... ----------------Oh, SICP and books like PL pragmatics http://www.amazon.com/Programming-Language-Pragmatics-Michae... ---------------and i love "Traps/pitfalls" from 1989!) http://www.amazon.com/C-Traps-Pitfalls-Andrew-Koenig/dp/0201... xenophanes 2747 days ago [-]

I'm not sure about aiming for "pure" languages. Lisp is functional enough that one can learn pure functional programming using it, if he tries. And Ruby is OO enough that one isn't missing much, isn't it? Nothing wrong with the pure languages as options, just I think impure languages can fit the categories too. adbge 2747 days ago [-]

I would recommend Ruby, too. Even though I don't write large programs or webapps in Ruby, I use it to write the occasional script to glue different things together. I think that there's probably more (practical) benefit to be had with Ruby than Smalltalk or Self. contextfree 2747 days ago [-]

Good post. Not sure C qualifies as "pure imperative" - it has expressions and functions after all. I'd think a true pure imperative language would have to be either assembly without macros or something like Forth (where IIRC each "word" is a self-contained command that performs an action on the stack etc.) alttab 2748 days ago [-]

A lot of people take the route of not learning C. If you do web development and your team finds something hard or impossible to do, watch their reaction when you say "I'll just write a C extension." The stack-frame comment is spot-freaking-on. Knowing this level of detail will make you a way better programmer in every other language because you won't make stupid memory hogging decisions or mistakes. You also understand the complexity of doing things one way and the tradeoffs of another. I best learnt C by re-writing large portions of the Pintos operating system. It's an academic OS and will be interesting to look at the source. Systems programming is where C packs the most punch, but all of those concepts can be re-applied in user land for some amazing effects. pinchyfingers 2748 days ago [-]

I'd never heard of Pintos before. This looks like something I'd really enjoy working on, thanks for bringing it up. kaens 2747 days ago [-]

http://www.jamesmolloy.co.uk/tutorial_html/index.html ciupicri 2747 days ago [-]

this makes me wonder if DHH (David Heinemeier Hansson) knows or has ever learned C. kaens 2748 days ago [-]

I, like many here, would strongly recommend learning C. I don't know if I'd call it "profitable" to do so at the moment, assuming you mean profitable in the money sense. C is a good language to learn, and a lot of interesting, well-paying jobs use C, and a lot of interesting open-source projects use C -- but if you just want to make steady cash, you can do so much easier with Java or PHP. That said, if you go about your programming self-education correctly, you won't have a problem using Java or PHP (well, you won't have a problem in the sense that it won't be difficult for you to design programs in those languages). It's good to have a handle on how the architecture of your machine works. C gets you much closer to that, and you will learn about a lot of things that are hidden from you in HLLs like Python, but that are still relevant to non-trivial programs. So yeah. Learn C if you're passionate about comp-sci, or software engineering. If you're learning programming only for a career, it may not be as beneficial for you. Learning C before college is definitely a good thing. Also, if you learn C, the last chapter of SICP is much easier to do, and you should go through SICP at some point ;) Don't touch C++ until you need to touch C++. You'll know when that time is, if ever. lukeqsee 2748 days ago [-]

I don't know if I'd call it "profitable" to do so at the moment, assuming you mean profitable in the money sense. I was meaning the in overall sense; "profitable" as in good for me. Sorry for the misunderstanding. kaens 2748 days ago [-]

Ahh, in that case learning C is a veritable goldmine! Edit: Also, if you use linux and end up going down the rabbit hole a bit, C is a prerequisite. zavulon 2747 days ago [-]

Being good at C can be very profitable in a money sense of the word too. Bloomberg is one example that hires a lot of C hackers and pays them obscure amounts of money (very very long hours though) infinite8s 2746 days ago [-]

I wouldn't call their salaries obscene when you consider the cost of living around NYC. But they are great if you are single and don't mind living in a tiny apartment. kaens 2747 days ago [-]

True, but it generally takes quite a bit of time to get to the point where you're "money profitable" with C compared to higher-level languages that are in popular use. dschobel 2747 days ago [-]

Obscure amounts of money? Mentat_Enki 2747 days ago [-]

malapropism... think he meant 'obscene'. cdr 2747 days ago [-]

There's a still a lot of C questions in interviews, plus usually bonus points for knowing it - it can definitely be literally profitable even if you never use it for anything substantial. dedward 2748 days ago [-]

You should absolutely learn C - you don't need to be an expert, but you should fully grasp the use of pointers and memory allocation, and how the compiler really works (intermediate stages and all that). This, for the same reason you should learn some provisional level of assembler on an older 8 or 16 bit processor with a simple instruction set (intel 8080 or 8086, and then maybe something RISC just for kicks). You don't need to be an expert, just dabble enough that you "get" how it works. Also learn how to implemenet a few other progrmaming patterns in C - you can do OO in C, you can do functional in C, you can do concurrent in C. You likely won't have to in real life, but understanding those concepts at the level of C will really help you understand the benefits of higher level languages. I'd say the same for any of the Lisps - learn one, even if you'll never use it - the insights it gives you are worth it and will make your other code better. chronomex 2746 days ago [-]

I wouldn't recommend learning assembly on the 8080 or 8086. These systems are register-poor, which makes programming on them frustrating. Instead, try ARM or perhaps MIPS. If you learn ARM, you'll probably end up programming at a higher level on it in the future. On second thought, learn assembly language for a platform you can run it on. If you only have x86, learn 8086. yason 2748 days ago [-]

You won't learn anything unless you need it, and it depends on your interests whether you need C in your programmings. Other than that, I can't speak for anyone but myself. For me, C has taught me so much since I was 14 that I couldn't possibly be where I am if I hadn't spent years writing C and I couldn't possibly recommend anyone not to learn it. But it's a different world for everyone and I can't say it's a bad thing if you don't know C. It would be a bad thing in my line of business but not everyone does the same things I do. One thing about C is that it's a nice forced marriage with the von Neumann machines we're using these days. If you really want to know C, you really want to know the current hardware architecture as well. It will change but it won't do that at least in the next couple of decades. On the other hand, mastering high-level languages first and dropping down when necessary might be a wise choice, if you only know you can do it. Like I said, architectures and paradigms will change in the future, and higher-level languages can embody abstractions that are very hard if impossible to contain in a von Neumann machine and it is the revolution of some new architecture when C will eventually be obsoleted. barrkel 2746 days ago [-]

An irony is that von Neumann architecture - specifically, code and data in the same memory space - is not modeled by the C language in its most distinguishing sense, and would arguably be better modeled by a language with first class functions. First class functions - the notion of creating new code, and passing it around as if it were data capture this essence, that the data and code lie in the same memory space, and that both are potentially mutable. forkandwait 2748 days ago [-]

I would suggest Python and C, in that order. Python will let you quickly have fun building large applications, and it will teach you object oriented programming. Once you know what a loop is, though, go by "Advanced Programming in the Unix Environment" and a decent C book and trip out on that for a year or so to really understand how computers work. I don't write C for a living at all, but it is great to know how everything is working under the hood, and APUE will teach you that. To be honest, I wouldn't bother with Java. I think in ten years Java will look like Ada does now: we will all be asking ourselves "What were we thinking?" I also wouldn't bother working on anything but Unix, but that is just bias... johnwatson11218 2747 days ago [-]

I just checked Amazon for that book and it looks like you can get used copies of the first edition for under a buck. http://www.amazon.com/gp/offer-listing/0201563177/ref=dp_olp... silentbicycle 2747 days ago [-]

True, but the Unix world has changed quite a bit since then...there was this thing called "Linux", maybe you've heard of it? 1st ed. APUE won't cover e.g. epoll/kqueue at all. Get the 2nd. Fantastic book, though. Figs 2747 days ago [-]

You should learn C and Java. These languages seem to be the most commonly used in college classes right now, and if you are already fluent in them, you can focus on the actual lessons much more easily, rather than wasting time with the nuances of the programming languages. Of course, it will also help if you start working on the following things, as they will show up in your classes. Don't worry if you don't understand it all right away, that's why you're going to college, right? :) - How to debug (go read the book by Agans if you haven't already. It's short and fun to read.) - How to do base conversions (eg. how do you convert decimal numbers to binary? decimal to hexadecimal?) - How to work with sets (If you know how to work with list comprehensions or the set objects in python, or have played with SQL, that's quite handy) - How to write a proof. (Here are some handy words to google for: "modus ponens", "modus tolens", "propositional logic", "truth table", "logical fallacies" and, once you get a feel for propositional logic, go look for "first order logic".) - How a computer works at the level of logic gates. (Go play with the java applet "xLogicCircuits": http://math.hws.edu/TMCM/java/xLogicCircuits/ and see if you can figure out how to design a CPU. It can be pretty fun, although the applet's a little clunky.) - What state machines are, and how they relate to regular expressions. - While you're learning C, go look at assembly languages and see if you can understand the relation between C and assembly, and also between assembly and logic circuits. - How to study and manage your time (Yeah, I'm still working on that one myself...) :) TallGuyShort 2748 days ago [-]

Even though C is used more and more rarely outside of systems programming, I definitely recommend learning it. Learning about pointer arithmetic, memory management, etc... will give you a depth of understanding in other programming languages that other students will be sorely lacking the first few years of college. Other than a little OS-hacking on the side, I've never used it for a project, but understanding how C works has helped me debug much more effectively in several other languages. jolan 2748 days ago [-]

It's also very useful for extending other languages by binding a library. pgbovine 2748 days ago [-]

agreed ... since you seem to be proficient in Python, one potential exercise is to write a C extension to the Python interpreter or C library modules for high performance benofsky 2747 days ago [-]

This also has the extended benefit of learning more about how Python is implemented, which always helps! fauigerzigerk 2747 days ago [-]

It is used a lot for embedded systems programming. jpdbaugh 2748 days ago [-]

I really only have experience with web development with Rails and in PHP. I also have done a little Java at school. I am considering diving into iPhone development and learning Objective C. Would I get at least some of the benefits of learning C that you all have described in this thread from Objective C? From what I understand you even have to learn some raw C to work with Objective C. mechanical_fish 2747 days ago [-]

The answer is "yes, some". You will have to deal with pointers and memory allocation, though I believe the newest ObjC runtime has a garbage collector so your exposure might be limited... if you're lucky. ;) And you'll get a general exposure to C syntax, the compilation cycle, et cetera. From a strictly pedagogic perspective, it would also be good to spend some time studying vanilla C and the POSIX APIs. When we say the phrase "learning C" in a thread like this one, we tend to actually mean "learning to work at a lower level of abstraction, closer to the OS, to assembly language, or even to the hardware itself". And I believe that most of iPhone development consists of telling Cocoa to do things, and Cocoa is presumably not a very low level API -- thank god. However, any C is better than no C, and iPhone development is fun and useful, so if it inspires you, go for it. jonhohle 2747 days ago [-]

Objective-C is just a layer on top of C (and inlcudes a C interface to the runtime as well). Knowledge of pointers and memory management is required in Objective-C. Objective-C methods _are_ C functions. I would imagine it would be hard to be effective at Objective-C without a working knowledge of C. j_baker 2748 days ago [-]

My answer to the question "Should I learn ?" is almost always "yes". Even if you never need to use it, it's always good to have a different way of looking at things. One thing you might want to look at is cython[1]. It allows you to write C extensions in a Python-like language. Could be useful as a "bridge". [1] http://cython.org/ codingthewheel 2748 days ago [-]

Yes! Learn C!! But learn it with a view towards using it to inform your use of other languages. The low-level aspects (pointers, memory management, working with .DLL or object libraries) are things that most languages, however fluent or high-level, use under the hood. Spolsky and Atwood argued this out in Stackoverflow Podcast #2. http://blog.stackoverflow.com/2008/04/podcast-2/ Just get a comfort level with it (C), and move on. It will pay dividends. AndrejM 2747 days ago [-]

I've only had a few months of experience with Python, but I had no trouble learning C (it only takes a week or two to get used to the syntax). I'm pasting this from my reply in a Reddit thread: If you're going to read K&R, make sure you visit the Errata page. There are a bunch of examples that have typos (some of them are not on the Errata page though). But reading one C book isn't going to teach you everything about C. A lot of the C code out there makes heavy use of macros and multiple pointer indirections, which isn't covered in much detail in K&R. And if you're interested in the newer C99 standard, The C Primer is a great book (but it's quite thorough, which imo, is a good thing). If you're going to try out the examples from K&R, pass these arguments to gcc: -ansi -pedantic -Wall -Wextra -g The -g flag is for debugging symbols. I think I still have most of the fixed examples from K&R that will compile, if you're interested in these. Also, make sure to bookmark these two links: http://www.eskimo.com/~scs/cclass/krnotes/top.html http://users.powernet.co.uk/eton/kandr2/ The first one gives you some better explanations of what has been said in the K&R book (divided by chapters). The second one has most answers to the exercises in the book. rmk 2747 days ago [-]

NO to C++! If you want to learn something that is object-oriented, go for Ruby... Much more accessible than C++, and also in demand. As for C, yes, you should learn C. In several industry segments (such as embedded systems), you cannot even get an interview if you do not know C. A nice way to do something in C is to write a text editor using ncurses for the GUI. This was something I did in my second year as a Comp Sci major in school, and it was a great experience (with a friend). JoelMcCracken 2747 days ago [-]

Theoretical aspects: I assume that you want to be a good hacker. A good hacker has a healthy mix of knowledge that will allow him to start work quickly on almost anything. Without a solid grounding in C, (and a perspective of JS and Python), there are a whole class of things that you won't be comfortable working with unless you have some lower level experience. With your current knowledge, how easy would it be for you to start hacking on an IP stack? Not that you would ever need to, but with a good knowledge of C such a thing becomes natural to you. All of those RFCs begin to make much more sense. Another big benefit to C is how simple it is. You begin to see how possible it would be to create a simple C compiler, and this is a good spot for this intuition. It has a simple syntax, is somewhat feature-poor, and is very close to the hardware. Plus, you'd be able to hack on CPython if you want ;) Practical aspects: Your knowledge seems to say that you are headed for web development, which I applaud, because all things exciting are happening on the web. Web development is changing. It used to be that web developers were laughed at, considered to be inferior to other programmers. It has been a few years since I've seen that opinion, and I think it has been thoroughly shown to be wrong. Web development has become, essentially, a two part system where the pretty web front end sits as an interface to a super hardcore back end. Web companies now face scaling issues that are relatively new to web development. While you may never program in C, having a strong foundation on what the underlying issues are. Either way you look at it, learn C is to get a better understanding of technology. It will certainly do that for you very well. roryokane 2747 days ago [-]

I think you should learn C only if you will be able to learn enough of it to be very comfortable with it when you get to college. If you learn that much, you can place out of the courses where you learn C. However, if you learn only part of C and still have to take the course, you will have to suffer through many lessons teaching you what you already know. I say this from experience – I learned Java in high school and was taught C++ in college (just finished my freshman year), and about half the lessons were about stuff I already know, like the difference between a value and a reference/pointer to that value, and what an object is, and how while loops work, and other exceedingly boring stuff like that. So if you can’t learn C quickly enough to place out, save yourself the trouble and just learn it in the university courses, so that the courses will be interesting, because they are teaching you something new. dgulledge 2747 days ago [-]

Absolutely! By learning to deal with pointer manipulation and memory allocation, you can learn what it is, why it is necessary and how to recognize when it is broken. One of the problems with garbage collection is that it suffers from a memory management problem at a higher level of abstraction. There was an entry in an autonomous vehicle competition a few years ago that stalled. Physical objects in the environment were represented internally as objects in the code. When the vehicle passed them, they were moved to a collection of objects that had already been identified but were out of the field of view. That collection grew unbounded even with garbage collection because every one of those objects was still referenced. adamtj 2748 days ago [-]

Yes. You won't really know python or javascript until you learn C. You may gain some empirical knowledge about how various parts of those languages operate, but without knowing C, you won't understand the "why". If you understand the "why", you'll occasionally be able to intuitively see solutions that would never have occurred to you otherwise. Those are the sorts of key problems that can make all the difference in the success of the project and of your career. Any language you learn will make learning additional languages easier and faster. But, the boost you get from learning C is arguably greater than for other languages. It's also the single most powerful backup language you can know. msg 2747 days ago [-]

Here's where C is taking you. After you understand pointers and structs and have futzed around in the Unix command line for a while, you probably have enough to go on to something like Linux Programming by Example. This book walks through GNU implementations of Unix utilities and the system calls that make them possible. You don't just want to run ls, you want to know enough that you can write ls by yourself. You want to learn how to manipulate the operating system with it. You will learn a mental model for how operating systems work in a deep, detailed way, which will serve you well no matter where you go. danieldk 2747 days ago [-]

Definitely, and keep W. Richard Steven's 'Advanced Programming in the UNIX Environment' close by. horofox 2747 days ago [-]

Yes you should! It's also important to know how basic data structures work(you will learn it in college). I studied before college on a good book of data structures in C which introduce from the basics(like binary numbers and so on) that let you learn C and also improve a lot in algorithms. The book name is "data structures using C". Here is the amazon link: http://www.amazon.com/Data-Structures-Using-Aaron-Tenenbaum/... Have much success in your degree! kristiandupont 2747 days ago [-]

Since everybody in here more or less agree, I will allow myself to counter just a little bit. There is no doubt that C programming is a very good skill and if you see yourself programming a lot in the future, it is more or less a no-brainer. BUT it is still a trade-off. It will cost you time and this is time that you could have spent having fun, making money or learning some other skill instead. You could ask people in any field if X-basic-skill in their field is worth studying, and you would get similar answers. But yeah, you should learn C :-) pan69 2747 days ago [-]

While you're at it you might want to pick up a copy of "Code: The Hidden Language of Computer Hardware and Software" by Charles Petzold. One of the most compelling and well written books on the subject I've read. Reading this along side learning C and Assembly language will make it all "click". http://www.amazon.com/Code-Language-Computer-Hardware-Softwa... watmough 2748 days ago [-]

Absolutely yes. There's no downside in learning C, and there's not much fluff in the language core to complicate things, or slow things down. I'd suggest you get a copy of K&R: The C Programming Language and just work through the text and examples. You might also want to pick an existing C-based project and work on bugs in it, maintenance programming being one of the best ways to get to grips with using the key tools, gcc and gdb. This way you'll get a feel for the language, and also for what you'll need to debug and fix code. prodigal_erik 2747 days ago [-]

One downside to learning C is that you will have to resist the temptation to use C on projects where much safer and more productive languages are feasible. Being able to use it speaks well of you, but actually using it is rarely a good decision these days. watmough 2747 days ago [-]

I get your point, but there's a lot of pretty solid apps running just fine on iOS that are primarily written in (objective-)C. evilthinker 2747 days ago [-]

Yes learn it, you should also learn at least one language per paradigm, it will give you a wider perspective on programming and a flexible mind. IMHO one should learn at least: Haskell(or something ML based like OCaML or F#), C++(regardless of what anyone says it will be an useful insight), Java or C#(also check D if you want), something Lisp based(Scheme is small and simple), perhaps some Prolog, Erland and Ada. Oh and see something of Forth if you like the looks of it and some assembly. perlsys 2748 days ago [-]

It's better if you dont ask! I don't believe that Linus ever asked (someone else) if he should learn C. Or that Damien Katz (couchdb creator) ever asked if he should learn Erlang. Or if Brad Fitzpatrick (Livejournal & Danga) ever asked if he should learn Perl! Just learn what you (from looking around) believe will make you a better or smarter, what is even more important use what you learn. Don't just learn to learn! lukeqsee 2748 days ago [-]

"A penny saved is a penny earned." Just as a minute saved is a minute gained. I asked to save myself time. Hindsight is 20/20, and a whole lot of people on here have hindsight. heatdeath 2747 days ago [-]

Maybe they did. It's not like you'd know. zweinz 2747 days ago [-]

I don't know what college you're going to, but you probably won't be able to graduate without taking some sort of course in C. If for some reason your Comp Sci major leaves it out, do Stanford's CS107 course: http://see.stanford.edu/see/courseinfo.aspx?coll=2d712634-2b... marvel 2747 days ago [-]

There is no wasted knowledge, C is a primitive language, but could teach you things that many other languages cannot. Consider proper memory management, et al. There are other languages that implement similar features that C does, but ANSI C is a macro-assembler in the truest sense of the word. Pick up a copy of "The C Programming Language, by Kernighan and Ritchie" and do the exercises. Good luck. forgottenpaswrd 2747 days ago [-]

No, if you want it to be "more profitable" just spend your time learning marketing(what the people that uses the software need) or how money works. If you want to understand how computers work, of course you will need to know assembler and c. This will give you the option to do things that other people can't. If you want short term profit, you should choose other options. thenduks 2747 days ago [-]

Personally I'd say the answer to any question that starts with "Should I learn..." is almost always yes. Keyframe 2748 days ago [-]

C is lingua franca of programming languages. Even if you don't find yourself programming with it, it will still be useful. ecaron 2748 days ago [-]

No, you should learn Java instead. The leap from Python to C would be atrocious, but the leap from Python to Java would be feasible. (And if, after feeling comfortable with Java, the leap from Java to C becomes reasonable too). You'd want to learn C to get a feeling for how the computer works at the core, but more important than that you should be seeking a rock-solid foundation in proper coding methods and structures that has potential off-branches into your courses and your career. From Java, you could pursue Android development or even Objective-C for iOS development. From C, that transition would be frustrating to say the least. (Other points behind pursuing Java is you'd find it quicker to start testing on your local box without needing to seek help, it'd give you great insight into what an IDE is and why it is your best friend, and there are more community projects surrounding Java than C that you could start to participate in when you're ready.) In the end, any language you want to learn would be a good language to learn (even Fortran), but you should go after a language that you can go from 0-to-novice on your own in a short time where you'll end having built a nice repertoire, and I think Java would best suit that need for you. chriseidhof 2747 days ago [-]

Yes, learn C. I've tried to avoid it for years, but it's actually a beautiful and simple language. It's very powerful and low-level, which means that it's easy to create ugly programs, but that's another problem. If you ever have to do low-level programming or Mac/iOS development it will definitely be of great use. gte910h 2748 days ago [-]

C yes, C++ no. Make sure you're using a C compiler, not a C++ compiler Here is why not C++: http://news.ycombinator.com/item?id=1463592 and why not java Edit: Was there something wrong with my comment? Or were you downvoting merely because you disagree? evilthinker 2747 days ago [-]

Those are not reason on not to use C++, but reason on why some people shouldn't be using C++ in the first place. Yes you can do it in python unless you want speed, if I am to interface my python code with C or C++ why can't I write them in C++ in the first place? Also if I were to interface any scripting language code with C I would probably go with Lua. gte910h 2747 days ago [-]

I'd say "It doesn't work well in most shops" is a damn good reason to not use something. In general, very little of the program needs to be written in C to get great performance gains. Additionally, python is vastly different from LUA. Lua is still a scripting language, ruby and python have moved past that. For someone at age 18 or so, I'd say C is a much much better level of complexity to be tackling that C++ queensnake 2746 days ago [-]

You're going to be learning C and / or Java in your first year so, you're just getting a bit of a leg up. If you have a strong preference for Java go for it first, but, I'll say uselessly (cuz everyone else already has) that you'll learn more about computers with C. brianobush 2747 days ago [-]

Yes, it is worth learning C even though most CS programs do not use C now. C is an excellent abstraction of the actual machine. Python is great, but many of the constructs used in python do not map directly to the CPU. Like many have said, C is portable assembly. d0m 2747 days ago [-]

In my opinion, instead of asking and spending time reading the comments of everyone saying why you should learn C, you should have actually learned C. It's a great language and learning it will surely help you in your career. Think of it this way: Why not learning it? lukeqsee 2747 days ago [-]

I asked this question for two reasons: 1) I had already started learning C. It is low-level, and I was getting disinterested. I wanted to know if it'd really be worth the work to learn it. (The answer is absolutely.) 2) So that other people, when wondering if they should learn C, would have a great list of hacker recommendations. (That has happened.) ssp 2747 days ago [-]

If you are getting disinterested, do some project that C would be good at, like graphics, or a hardware driver, or an OS kernel. bleepster 2747 days ago [-]

C is a good starting point. Its "strengths" and "weaknesses" made me appreciate/discover other programming languages' "strengths" and "weaknesses" :) 0bfusct3 2747 days ago [-]

Get a hardware book and read up on how computers actually work. This will help an immeasurable amount to understanding why C is the way it is. mathgladiator 2747 days ago [-]

Yes, because one day you may be tempted to write a windows driver to hack games (how I helped a friend write a WoW bot). jscore 2747 days ago [-]

Yes, it definitely. A good way to build your fundamental knowledge of computer science. strlen 2747 days ago [-]

Yes! In general, when asked "should I learn X | X is something that gives you a different perspective" the answer should be yes. In particular, C is excellent as it teaches you things must be understood even if you work with higher level languages: dealing with pointers, dealing with raw memory (allocation, deallocation, finding leaks), dealing with the I/O and VM sub systems of your operating system, understanding abstract data types. On the educational side, you will learn about hardware works. Some will argue that there are better languages to learn these things and I'll agree: Forth could be better for learning about raw memory addresses and systems programming. Scheme could better for learning about data abstraction. However, C has several salient things going for it: C is UNIX (for good or bad, majority of serious non-embedded -- and even great deal of embedded -- programming outside of Microsoft or of Windows Desktop Application development targets UNIX) and C is the lingua franca of programming languages. From the practical side, you will have an advantage too. Higher level languages generally still have pointers (Quiz: is Java pass by value or pass by reference? Answer: It's pass by value, just the value of anything other than the primitive types is a pointer). Higher level languages have built abstractions around I/O and VM but they typically fall under two categories: thin wrappers around C and POSIX APIS (Perl, Python, Ruby) or leaky abstractions that occasionally force you to use FFI to C (JVM based languages). In either case, if you are able to program C you have a competitive advantage against coders brought up purely on those languages. C is also a good language to learn about data structures: partly because learning data structures in C is really about the data structures, abstract data types and algorithms and not (as C++ and Java centric courses often make it out to be) about OO. This is the book I recommend for data structures in C: http://www.amazon.com/Data-Structures-PseudocodeApproach-C/... (I'm biased as I learned from it myself and have had classes taught by Professor Forouzan). Note, I never said anything about performance. Just like it's nearly impossible to hand-write assembly that beats "gcc -O3" (not to say "gcc -O4" or icc) performance wise on modern hardware (out of order execution, NUMA, specialized instruction sets), I am pretty confident that languages will emerge that will beat C even for things like inner numeric loops by being able to reason more about mutability, side effects or lack thereof, exploiting parallelism and caching available in hardware. You won't be writing in C to make computation faster, you'll be writing in C to deal with I/O, memory and the like more efficiently: many times that will mean your code will run faster, but it won't specifically due to being written in C (to be blunt, it will be due to implements of runtimes and programming languages sheltering the languages/runtimes from the hardware/OS; that may not always be the wrong thing to do). See http://pl.atyp.us/wordpress/?p=2947 for a great discussion on this. Finally in terms of C++: don't study it before knowing C and a non-C++ object oriented language. I was lucky enough to learn C before learning C++, but it was the first object oriented language I tried to learn. Because of that, I thought of OO as a black art. Oddly enough I truly learned about OO in Perl: I was writing Perl 5 (loosely adhering to Damian Conway's "Perl Best Practices") and despite OO in Perl being an ugly hack (it's similar to Python's, but without even the syntactic sugar that hides __dict__ away) the Perl code I was writing was far more OO than any C++ I wrote up until then. I then learned Python and Java; when I came back to writing C++, I was much better at it. Josh Bloch (along with Doug Lea, the author of Java's collections) in "Coders at Work" spoke of a similar experience (in his case, he didn't do any OO programming before Java) and likewise speaks very favourably about C. I strongly recommend you do the same: learn C and do a non-trivial project in it (writing a compiler for subset of C in C did the trick for me) to truly grok it; continue building projects in Python (or another OO language e.g., Ruby, Java, Scala, Smalltalk, ObjC, Common Lisp+CLOS; pick as many of these as you'd like) to make sure you have a firm grasp of OO before you go after C++. brianm 2747 days ago [-]

Yes. unwantedLetters 2747 days ago [-]

Yes. I'm sure there are many reasons to know C/Assembler. But I felt like learning things like why: obj.getField().setFirst("random"); obj.getField().setSecond("random"); is worse than Field field = obj.getField(); field.setFirst("random"); field.setSecond("random"); Another reason I used to like C was that it always made me want to make my code run as fast as it was possible to run. When I write code in Java, I'm looking to make the code work. I'm not saying either is better, they just each have their plus points, but I enjoyed C more due it's challenges and feel I'm a much better programmer for knowing it. jc-denton 2747 days ago [-]

Short answer: yes. Long answer maybe you also want to learn some assembler to see how the machine really work (I would recommend programming a simple microcontroller or the lego NXT things). If you manage to learn C. It will be easier later to learn an object oriented language later. (Java, C# or C++) The problem (and the frustrating thing) will be that you first probably wont achieve much by using pure c. Therefore you can also start with toolkits like processing.org which can teach you basics about algorithmic thinking. jc-denton 2747 days ago [-]

Ah just saw that you did Python and JS first. So yes I suggest learning C or C++ (maybe C first, because it's easier)

Applications are open for YC Summer 2018 Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search:

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.