Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would suggest to learn C. It might sound a little bit strange, but when you consider it, it's probably one of the best things you could do. Most of the modern languages you will need are somewhat based on C. That is especially true for compiled languages, but most script languages take their fair share of C too.

You will learn about pointers, which is important in ANY language, binary trees and stacks are good to know about too.



I can't imagine how learning C as a first language will be of much value, other than it will be so hard and confusing and slow it will make other options later on seem light and easy. C is a fine language for when you need to do very low-level work, but it lacks most of the abstractions that make modern programming languages so easy to learn and work with.

I must say (not for the sake of picking a fight, but because this is the answer to a real person's question) that I think this is not good advice. If you get into programming, sooner or later you might want to learn C, but for now it will only make the experience frustrating for you.


I learned C as my first language, and there was nothing "confusing" about it. I find C to be quite direct - here's a variable, there's a loop, a function, a struct. Even pointers are straightforward one you know about memory and addresses, and you will need to understand them (conceptually) sooner or later anyway.

In fact, the abstractions you mention are what might be confusing for the beginner: Classes, objects, inheritance, polymorphism, iterators, high-order functions, closures, monads, generators, etc. all require as much book- and code-staring as either void or function pointers do for the first time.

I do however agree with you that C is harder and much less useful to learn than a "batteries-included", modern language like Python or Ruby as a first language.


A lot of people learned C as a first language and a lot of these people suggest others to do the same. "It worked for me" syndrome.

However, that does NOT make it a _good_ first language. Sure, it can be good enough, but I'd argue that you'd get MORE out of learning a language like Python. Python is, IMHO, a great beginner language because it has all the abstractions, but (unlike Java) does not FORCE you to use them until you're ready to do so. It eases you into the complex concepts. It also shields you from buffer overruns and manual memory management. It gives much more useful errors when things crash and finally, an interactive shell is the best thing ever when learning.

You already know that though, since you agreed ;-)


I did not learn C first, I learned BASIC first. Then I learned Pascal because C was "too hard" as a beginner language. All my intro classes in college used Pascal because it was a "good beginner language." I first learned C in a half-assed, self-taught sort of way and the experience was painful. I hated using C in my last few years of college. I didn't understand it properly because I hadn't chosen good books to learn from and hadn't had any good teachers. I was stuck thinking in Pascal/Basic terms and because I didn't understand some key fundamentals of C. I didn't even really understand the difference between C and C++.

But C is still a _good_ first language. And I don't mean "good enough" I mean that it has specific advantages and advantages relative to other languages including Python.

C is a small, mostly consistent language. So is Python (I'm certainly not saying Python is not a good beginner language), but C is smaller.

C compiles directly to machine code. There is a very clear, exposed path from C code, to binary code on the disk, to a process loaded into memory by the operating system and executed by the machine itself. These steps allow the beginner to see and practice the process that transforms a text file into an end-user application. Python caches a bytecode file without the user knowing, then executes that bytecode in its own environment that has abstracted most of the underlying machine.

C exposes the user to the underlying machine. Beginners don't need to be shielded from buffer overruns and manual memory management. In fact going for too long without introducing those topics practically ensures the programmer will never be good at it no matter what language they use. And it's not just memory management.

For a simple example of the ways C can be worthwhile to a beginner:

Learning how to use #includes is hard in C because it requires some understanding of the operating system, the compiler, and what software interfaces are.

If you don't know what '#include "goladus.h"' means, the extent it is related (or more importantly, not related) to "goladus.c", it means you probably have some fundamental misunderstanding about how the source is compiled and linked, and where the compiler looks for the particular files. Correcting that misunderstanding will result in big knowledge and conceptual gains. You see how the OS works with the software you write. You see how to reuse code and probably have some understanding of how it works at a binary level. OS knowledge will be valuable for anything else you use that OS for. The abstract code reuse concepts apply to most languages. The C-specific knowledge can be applied whenever a higher-level language like Python is capable of C extensions, and is also applicable to other operating systems.

In python, when you say "import goladus.post" it's easy and it works but it's basically magic if you don't understand the python module system. Understanding the python module system is worthwhile, but is fairly python-specific. Why doesn't 'import goladus.post.py' work? Or 'import "goladus/post.py"' Figuring that out isn't all that hard, but also doesn't give you any greater understanding about anything but Python's import syntax.


Subsequent languages will seem easy because C exposes you to fundamental hardware and programming concepts that nearly all languages use even if only implicitly.

Sometimes experienced programmers underestimate the difficulty of learning something when there is a lot of magic involved. One thing that makes Scheme so appealing as a beginner language is that most of the language can be exposed fairly easily, all the way down to the compiler. C is similar, in that it is not too difficult to see directly how your code is manipulating the machine. When you learn C properly, you know exactly what your code is doing.

Python is a fairly small language, but under the hood it is still significantly more complicated than C. C is not an ideal choice in all situations, but for many it is really an excellent first choice if you take a good approach to learning it.


The introductory programming course's language of choice at my university was C. I have mixed feelings about learning C as a first language. I remember the people who go it right from the start benefited the most and got a good base for the rest of their programming learning/experience. But the people who had trouble grasping some concepts of C, got stuck with that and later ended up hating either C or programming altogether. (Disclaimer: this was a class full of all kinds of engineering students, not just CS).

Anyway, I think C could be an excellent second language to learn. Starting with something having a similar syntaxis like Javascript could be a good choice and pretty helpful in the future too. Plus, you won't need an IDE, a compiler, setting up a server or a database, only a browser.


I disagree.

While I think C is a valuable language to learn and I agree with your reasons for learning it, I do not think it should be someones FIRST language. It would make a great second, though. Why? Because C (and C++) has a lot of confusing cruft that a beginner just doesn't need to know about. The noise in the language is too high and too much work is involved in achieving relatively simple things. A higher level language also has quicker returns, which definitely helps keep someone whos just starting out motivated. Most high level languages have better tools to learn with too, like an interactive read-eval-print-loop.

I would recommend Python. Not Python 3, but Python 2.6 - better library support. I recommend Python because it takes very little to get working and it comes with everything a beginner would need bundled. When you're learning, you don;t need direct hardware access, you don't need direct OS interfacing, you don't need high performance (and probably wouldn't get it anyway until you learn how to write good, fast C). You DO need to get things done quickly (its hard to learn, otherwise) and you DO need an environment that doesn't require much background knowledge to work in. In Python, a simple program is simple. Theres no need to learn about "main" (and therefore functions), about includes, printf format specifiers and so on - just to write a hello world. As your skill increases, you can gradually add more language features: conditional statements, loops, I/O, functions, data structures, classes, functional programming tools, libraries, metaprogramming. You dont have to deal with manual memory management and you'll get more meaningful error messages than "segfault".

You learn a lot about PRGOGRAMMING (rather than having to deal with the low level complexities of C) which can then be applied to almost any language. If you outgrow Python (and I don't think you ever would, I know people who write some amazing stuff in Python, including HIGH PERFORMANCE CODE) you can learn C. I'd recommend it as a second language. Everything you've learned from Python will be applicable in C too. At this stage you should be well versed and pointers should come a lot more easily. You can also use Python and C together - its not even that hard.

You could easily replace Python with Ruby in the above, if you prefer. Python and Ruby are pretty much equal players.

If you don't mind going a less mainstream, I'd suggest learning Factor: a fast, powerful, very dynamic, native compiled concatenative language. It has pretty much all of lisps powerful features, with some ideas taken from Forth, Smalltalk and others, has an active community and very clean codebase. (The library code is some of the highest quality code ive seen) being stack based, it may take some effort to get into the mindset though.


All excellent points. But remember the original questioner already knew some python and some VB. C is probably an excellent choice for him, though personally I use Python for the vast majority of my code. Of course, my work has morphed to be more system and database administration than programming lately so I may be biased by that.


The poster's first language is technically VB6.

If you can make the effort, you can learn programming with C. You need good learning materials (which are available), you need to work hard, and you need to focus on learning C rather than trying to cram C into an otherwise generic introduction to programming.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: