Beyond C/C++/C#/Java

Started by
66 comments, last by antareus 20 years, 7 months ago
Great quote from my comparative languages teacher: "I''m here to try to teach you to not take computer languages seriously." Now when I heard that I knew I was one of the ones that takes them seriously. It borders on religious wars with a lot of people. You get it ingrained that "C++ is the way" and you lock yourself into imperative/half-assed OO (single dispatch comes to mind) constructs, when in reality all you''ve done is buy into the popular opinion that C/C++ is the way to go on most projects. No, it isn''t hype, but at the same time it isn''t much better. I can only hope that the time I''ve spent in C++ does not hinder me greatly when it comes to learning ML and Prolog. The past few days I''ve (outside of class) looked at various different languages such as Eiffel and O''Caml. Eiffel looks really neat and amazingly clean, as does O''Caml''s blend of imperative/functional/OO into one language with decent syntax. I noticed they were both garbage collected, yet O''Caml''s performance is said to be very competitive with raw C. Has anyone worked on either of these languages? I''d be interested to know what you thought of them for larger projects.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Advertisement
I believe the only way to hinder learning of one language is if you start with a higher level language and go to a lower level language. There is always a significant increase in requisite complexity. For example, if you start with Java and go to C++ the fact that memory management is now a requisite part of a program will be a hinderance in learning C++. On the other hand, going from C++ to Java is completely trivial. Outside of some cute perks, Java is a simplified version of C++.

I believe this is even more true when you get to very high level languages like Prolog. I used Prolog for a discrete mathematics class and the language was extremely simple to learn. My only hinderance would have been that at times it felt like a glorified database interface language rather than an actual and independant programming language. I have not used Eiffel or O'Caml.

EDIT: And, yes, this does imply if you were to master assembly you would be easily able to pick up any other language and I completely believe this. As much as people dwelve on things such as the OO, XP, whatever.. They are nothing except abstractions of the lowest level code -- assembly. If you understand what it is exactly abstracting then it is naturally trivial to understand its purpose.

[edited by - haro on September 3, 2003 3:19:18 PM]
quote:As much as people dwelve on things such as the OO, XP, whatever.. They are nothing except abstractions of the lowest level code -- assembly.

This is true for C++, but not necessarily for languages meant to run on virtual machines that optimize specificly for OOP style programming.

One thing that C++ programmers do over and over in Java is to try to optimize their code by removing method calls, manually inlining methods. This instead tends to slow down the code because the optimizations of the VMs, such as Hotspot's JIT compilation, were designed for clean OOP code with many small methods rather than monolithic blocks of code.

Instead of knowing how the processor works, you need to learn how the VM works to become a good programmer in a language like Java or C#.

quote: I noticed they were both garbage collected, yet O'Caml's performance is said to be very competitive with raw C.

Garbage collection has little effect on the performance of optimized application. Anyone who knows how a garbage collector works can often optimize away its impact.

[edited by - HenryAPe on September 3, 2003 4:08:33 PM]
quote: "I'm here to try to teach you to not take computer languages seriously."


Why?

If you want to play the quote game, here one from a guy I met that works for IBM's Transarc Labs:
quote: "If you can do [learn] C, you can do [learn] anything."


I don't think C++ is going to hinder you.

----
I think, therefore I''m annoying.
http://www.downfromearth.com

[edited by - HarryPawedHer on September 3, 2003 4:18:59 PM]
----I think, therefore I'm annoying.http://www.downfromearth.com
quote:Original post by HenryApe

quote: I noticed they were both garbage collected, yet O''Caml''s performance is said to be very competitive with raw C.

Garbage collection has little effect on the performance of optimized application. Anyone who knows how a garbage collector works can often optimize away its impact.


To expand on this, a garbage collected system can even be more effecient than manual memory allocation. Why is that? Well, with a garbage collected system,
new 
just has to move a stack pointer, whereas in c++ you have to search the free list, etc. Furthermore, your objects are more likely to be allocated contiguously, which in some applications will result in better cache coherency.
quote:Original post by haro
I believe the only way to hinder learning of one language is if you start with a higher level language and go to a lower level language. There is always a significant increase in requisite complexity. For example, if you start with Java and go to C++ the fact that memory management is now a requisite part of a program will be a hinderance in learning C++. On the other hand, going from C++ to Java is completely trivial. Outside of some cute perks, Java is a simplified version of C++.


I think the reverse also holds true. While someone going from a lower level language to a higher level language will probably be able "pick it up" quickly, it may take them quite some time to grasp the higher level constructs, and un-learn old behaviors. A classic example of this was/is people going from C to C++ and having trouble really understanding how to implement good OO constructs.

It''s all just stuff to learn

-John

- John
quote:Original post by haro
EDIT: And, yes, this does imply if you were to master assembly you would be easily able to pick up any other language and I completely believe this.
Even chinese, for example? Actually I''m sort of serious with that, because some computer languages do have very different approaches to programming -- so different that mastering Asm helps you as much with learning Lisp as it helps you with learning chinese. Nobody learning Lisp would try to learn it by figuring out how the expressions are turned into assembly code.
Functional programming languages like ML are very different from imperative languages like C++ in terms of the way you have to think about problems. I think it''s beneficial to learn them because they do give you a very different perspective on things if you''re used to imperative languages. Learning a language like ML will also help you understand C++ template metaprogramming which is very functional in style. I don''t think knowing C++ is necessarily a hindrance to learning ML as long as you don''t assume that everything you''ve learnt about C++ can be directly applied to ML. Keep an open mind and be prepared to learn the ML style rather than trying to write ML in a C++ style and you won''t have a problem.

Game Programming Blog: www.mattnewport.com/blog

quote:Original post by sjelkjd
To expand on this, a garbage collected system can even be more effecient than manual memory allocation. [...]

Google The Measured Cost of Conservative Garbage Collection.
quote:Original post by haro
EDIT: And, yes, this does imply if you were to master assembly you would be easily able to pick up any other language and I completely believe this.

Generally, HLLs imply abstract virtual machine semantics within their language specification which has little relation to the semantics of the actual machine. That means there would be very little transferrable knowledge going from assembly to HLL or vice-versa. To prove that point, consider that you can write Java programs which ultimately execute on either Intel or IBM z800 architectures, yet the architectures of those machines are very different to one another.
quote:
As much as people dwelve on things such as the OO, XP, whatever.. They are nothing except abstractions of the lowest level code -- assembly. If you understand what it is exactly abstracting then it is naturally trivial to understand its purpose.

OK, so how would having knowledge of assembly make it trivial to understand, for example, the multiple-inheritance model of C++ or the method resolution system of CLOS?

This topic is closed to new replies.

Advertisement