Sunday, October 25, 2009
The perils of using Managed Languages for young programmers
Although I'm not really a young programmer per say (since I've been programming since 2002), I still feel young due to my inexperience with programming. The majority of my programming has been with managed languages such as Java and C#. Now I love using managed languages because they make programming so much easier since you don't have to deal with memory; that's the whole point of managed languages is to manage memory. I have always been curious about unmanaged languages such as C/C++, but I never got the opportunity to work with them until now. I'm currently looking into using a network modeler written in C++ and I am starting to understand how complicated memory management could be. The main thing that I learned is that local objects to a function are allocated on the stack instead of the heap. Since both Java and C# uses the "new" keyword for declaring objects, I was always under the impression that the heap was always used for all objects, and only generic types such as int, char, and so on were stored on the stack. It turns out that in C++, objects can also be declared on the stack and that using the stack is much faster than the heap. C++ provides two ways of declaring an object, with the new keyword that requires using the "delete" keyword to reclaim the memory, or without it and it gets auto-managed. Nobody ever told me there was auto-management in C++. I also learned about auto_ptr and so on. Anyways, my point is that just using managed languages is great and I would use them for my application development projects, but being oblivious to C/C++ can be a great disservice. It's sad that noone emphasizes learning C/C++ and everyone is depending on Java/C# to do the dirty work.
Subscribe to:
Post Comments (Atom)
I disagree with you Pierre. While I think it is important for someone who plans to work in developing compilers or perhaps computer architecture to become very familiar with assembly and C, I don't think most programmers should.
ReplyDeleteIn my view, it is like saying you need to really understand electrodynamics before you use a CPU. Sure understanding electrodynamics is useful if you want to understand how transistors and memory devices work, but if we are to build bigger and bigger systems, we have to be content to learn a simple model, and go on, knowing that if we wanted to learn more about that subject we could.
I believe that to build large-scale reliable software, garbage-collection is essential. Average programmers cannot create modern-sized computer and reliable software if they have to manage the memory.
I think something similar is happening with threading now. I don't believe the approach of having the average programmer learn how to avoid races and deadlocks will work. I think instead we need to focus on immutable-message-passing or transactional approaches.
I guess my point is that in order to code in C++; there are many issues I need to be aware of (which I see as learning opportunities). Using C++ may ultimately not be productive in the long run, but at least in my case, it forces me to be a more conscious programmer. The more I learn about programming, the more humbled I become, and the more I try not to underestimate it. Coding in C# is great because I don't have to redeal with common programming issues, as they say ignorance is bliss. I guess sometimes I just want to run barefoot. Maybe I should do some C coding instead of C++. All in all, I'm young and confused (well not that young) and trying to figure it all out.
ReplyDelete