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

Could you elaborate on connection between C and designing things that scale? I don't get it and I think I may be missing something.

I support C too. While I don't use it everyday (actually I avoid using it) I think it is important to do some low level and system programming - and C is here important. Every programmer should code e.g. a simple binary tree from scratch (with manual memory management) just to see what it is like.

Also as a matter of fact someone recommended C but it's buried down with 0 votes.



There are a few things you can take away from having some C experience that I think are related to building scalable systems:

* Managing your own memory. If you want to build a distributed system, being able to fit more instances of your program onto a single box is going to save you a lot of money/headaches. Removing unused objects from memory is a valid optimization in most languages.

* Avoiding dynamic memory allocations. In languages like Python all memory allocation is dynamic. However, unloading/loading the same object over and over is something I've seen a lot of.

* Understanding pointer arithmetic and pointer passing usually leads to better understanding of how other languages pass data around. This leads to avoiding doing lots of copying of data structures in memory.

* More of a systems programming thing, but understanding temporary file systems, RAM disks, OS file caching and when to implement your own caching system.

* Better understanding of low-level concurrency implementations and its limitations. Most scripting languages have little support for concurrency (PHP has none, Perl and Python are pretty limited).

* Understanding of the stack and how expensive it is to make even a trivial call vs inlining code.

* Better understanding of network protocols, when to use TCP/IP vs UNIX sockets, how to arrange for connection pooling, etc.

* A general mindset of minimalism when it comes to allocating resources.


>* Avoiding dynamic memory allocations. In languages like Python all memory allocation is dynamic. However, unloading/loading the same object over and over is something I've seen a lot of.

I don't think that C really teaches you to avoid dynamic allocation. In a lot of situations, it's unavoidable, especially if the program needs more memory allocated than the stack will allow.

What C teaches, as you said in the first point, is memory management. You don't use mallocs without knowing exactly when the memory is free'd, don't allocate new memory unless you actually need to, etc. C forces you to make decisions about how you're using the memory, whether you can stack allocate it, if it needs to be heap allocated, and when it needs to be destroyed.




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

Search: