views:

318

answers:

8

Hi, I am looking for a few pointers, I got pointed to this site.

My primary interest is network programming. I have done quite a bit of reading and experimenting and am familiar with mechanisms of most protocols. Now I want to start writing code. I read introductory stuff on python and grasped it well too. I had just started playing with the python modules, when I met somebody(with a tall reputation) at the local lug meeting who told me that I could always learn python very easily later but C was the language I must know, specially given my interest on network programming. I did some research and thought maybe the guy is right. So I've been with a k&r for 4 weeks now. It didn't intimidate me but I am progressing very very slowly and maybe that's why also slacking a bit. I am posting this because I'm at the stage where it's even worrying me now. I'm always thinking that in python i could be building stuff right now. I know python won't teach me low level things like memory management etc, but my progress is pain-stakingly slow in C.

Question: Should I continue battling with C like i'm now and write some working code in it or switch to python where i'll be at a bit more ease? Will a high level language spoil me too much to come back to C later?

+12  A: 

Just use Python. You'll have access to the same low-level socket APIs as in C, without having to learn about indirection and memory management at the same time.

Later, if you find that Python is too slow for your purposes, you can rewrite some parts in C. But don't do it to begin with.

John Millikin
+1  A: 

As a python programmer, I would give you the opposite advice. Learn python first. At least until you learn the limitations and possibilities it has compared to what you can do in C. Then use C for those far out problems you can't fix in Python. :)

Tor Valamo
+4  A: 

Depending on what level(s) of the networking stack you want to work, C may be indispensable, useful, or hardly relevant. But if trying to tackle C first is wearing down your motivation, by all means go back to Python and get some success and therefore incentive -- you can come back to C later. Learning an easier language first, a harder one later, is a perfectly natural progression! MIT, for example, uses Python for some "programming 101" courses -- and yet, most definitely, that doesn't turn students off harder languages such as C (or even C++, which is harder yet!) in later courses.

Alex Martelli
+4  A: 

Hello, it depends on what purposes for network programming you have. Do you want to have a very stable, secure but also slower high-level language or do you want to work with exhausting (my opinion) but fast low-level language.

When it not depends on speed, I would take python. You can do a lot of things with it. And anything you need is already there. Python is built on C, so you also have access to the same API.

In Python it's just easy but also powerful. Since you are new, I have some links, that may help you:

There are a lot of books:

And just for fun, some comics:

I hope that this is helpful for you.

Joschua
+3  A: 

Twenty years ago, even ten, you couldn't live without it.

Now many do.

It's possible (probable, actually) that more than half the programmers in the world don't know C. It's completely unnecessary for Web work and for most app work. I'm being gracious with this--if you really were to include web, hobby, overseas consultants and the like, the percent who have used C is probably pretty low at this point.

Embedded often uses C, but I've worked on 2 embedded platforms (a waveform analyzer and cable box) where I've done nothing but Java work.

Honestly a basic understanding of C is nice for writing drivers and understanding pointers, but these days you can easily get through an entire career without ever needing C. I personally would completely skip C++, although it's used quite a bit, I don't see any big advantages to learning it now.

Bill K
+1  A: 

I would recommend Python as the best choice for any complete beginner in programming. And I think for networking, Python will work out very well.

In networking, you have to wait quite a while (in computer terms) for messages to be sent and received. Even if your language is much slower than C, you may not notice any difference. And the low-level guts of the Python networking libraries are probably written in C anyway; Python isn't very slow when you are using it as a way to invoke C code.

Also, as a beginner, you would be amazed at how much work it is in C to handle all the possible error conditions. In Python, you can use the exception handling to easily handle the errors. It really is better.

And finally, in the unlikely event that your application works well but is too slow in Python, you can pretty easily write a C "module" that will replace the performance-critical part of your Python application. Get a working prototype, figure out the part that must be fast, and just replace that part with C. A lot less work than doing the whole thing in C.

At the moment I write C as my day job and I write Python for fun. I can get a lot done in a few lines of Python. You will find it easier to learn with Python, you will get more done, you will have fewer bugs, and you will enjoy it more.

I suggest starting with the book Learning Python.

Good luck, and have fun!

steveha
+1  A: 

I would recommend starting with Python, unless you absolutely need the speed. It's often said that programming languages are just tools in your toolbox, and certain ones are going to be able to accomplish a given task better than others. If you don't need the speed, Python is going to accomplish the task you're looking to accomplish with less code and will be easier to learn.

I am entirely self-taught and went from Apple II BASIC to assembly language to scripting languages (Perl, PHP, Ruby) and now am using mostly C. C is a relatively small language, but I believe that had I started out with C, I probably would've lost my motivation. Start out with Python - you'll learn the gist of programming, then if you have the need or the want to learn C later, it will be easier to pick up.

+2  A: 

I would recommend using Python. Because it is a higher level language than C, you can concentrate more on the "what" rather than the "how". This means that you can avoid the level of detail required by C in order to achieve what you need to get done right now.

This isn't to say that a low level of detail is never required. It certainly is, but at this time I'd recommend you ignore it and pick it up in the future, should you need to.

Rik Wade