Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Network programming: Python vs. C for a complete beginner [closed]

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?

like image 659
gsin Avatar asked Dec 11 '09 23:12

gsin


2 Answers

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.

like image 136
John Millikin Avatar answered Oct 14 '22 05:10

John Millikin


It depends on what purposes for network programming you have. You'd have to do some testing to be sure, but if performance is critical and depending on the load you might want to go with C.

If it doesn't depend on speed, I would use Python, since it tends to be easier to use and less error prone as a result of being a high-level language. It also has a great set of libraries for network related programming and in general.

Since you are new, here are some links that might be of interest:

  • Python Recipes
  • Hidden Features
  • Code Like a Pythonista

And some books:

  • Dive Into Python (Free)
  • Learning Python
  • How to think like a Computer Scientist (Free)

And just for fun, some Python-related comics:

  • Fly with Python
  • From C to Python
  • New Pet (Hamster Ball)
like image 27
Joschua Avatar answered Oct 14 '22 03:10

Joschua