Monday 26 December 2005

Learning Java or C# as a Next Language?

Learning Java or C# as a Next Language?: "Re:Just Pick One and Learn it Well
(Score:5, Informative)
by Trepalium (109107) Alter Relationship on Friday December 23, @04:57PM (#14329446)
Yes, you were just lazy. They're called assemblies in C#, and you can dynamically load them via the" System.Reflection.Assembly.Load() [microsoft.com] method. It'd be pretty silly to be missing something like dlopen or LoadLibrary in C#, wouldn't it? You typically have to combine that with an application domain so you can unload the assemblies.

.Net's reflection capabilities are quite a bit more extensive than Java's (there is native support for outputting byte-code and even entire classes [msdn.com] at run time). If you want to pick on C#/.Net, pick on it's limited exception handling (unchecked exception handling only makes 'black box' use of objects more difficult), or simply the fact that C#'s feature set is obviously derived from Java.

As for features that C# offers that Java doesn't... Wikipedia has a list [wikipedia.org] and links to other sites with more. Whether or not you find these features useful or painful is a matter of taste, though. Many of the features of C# were created to make Visual Basic-style GUI creation easy and painless. C# offers operator overloading, true multidimensional arrays, delegates and unsigned types. Unless you have the pleasure of running in an entirely Java/managed environment, those unsigned types are a life saver (or at least a sanity saver). Delegates (multicast function pointers) make wiring up event-based GUIs a little easier. True multidimensional arrays are either invaluable or useless, depending on the kind of software you write. Operator overloading can also be useful, provided it's used carefully (and can cause no end of confusion if it's not).

--
$ apt-get moo

==============================

Re:Just Pick One and Learn it Well

(Score:4, Insightful)
by WaterBreath (812358) Alter Relationship on Friday December 23, @11:12PM (#14330973)
"It'd be pretty silly to be missing something like dlopen or LoadLibrary..." Just like missing checked exceptions? Yeah that would be silly.

I'm pretty sure dynamic class loading has been around longer than Java, or even unchecked exceptions. So I say it would be sillier to be missing a way to dynamically load classes.

Out of curiosity, how many "major" languages have checked exceptions? Java is the only one I can think of off the top of my head.

It's been a while since I worked with Java, and I'm far from an expert. But when I was dinking around with it, I found it extremely annoying that I had to label every function that could possibly throw an exception. The compiler needed to be smart enough to detect whether a function might throw an exception, in order to tell me that I had forgotten to label it... So if the compiler can tell this without me telling it so explicitly, that pretty much relegates the label to syntax-enforced documentation.

Not to mention people got so sick of being required to write pointless code to handle pointless exceptions, that they figured out a ways to hack around it, making the checking useless:
http://www.oreillynet.com/pub/wlg/5559 [oreillynet.com]

All of that seems silly to me. But that's just MHO.

Or maybe it's not just mine. This guy, and many others, seem to agree that checked exceptions in general are kind of silly:
http://www.mindview.net/Etc/Discussions/CheckedExc eptions [mindview.net]
===================