Learning Java or C# as a Next Language? 817
AlexDV asks: "I'm currently a second-term, CIS major at DeVry University. This coming term, I will have the choice of studying either Java or C# for my Object Oriented Programming class. Now I'm a diehard Linux user, so I'm slightly conflicted here. Which should I take?"
"I know C#.NET is primarily a Microsoft language, but, with Mono gaining momentum, it could very well become a major development platform for Linux as well. Novell has really been pushing it lately, and there seems to be a lot of very cool Linux apps being developed with it.
Java, on the other hand, is inherently more Linux-friendly due to its intentional cross-platform nature, but at the same time it doesn't really seem to be inspiring the same kind of developer enthusiasm as Mono. However, it's clearly not an insignificant OSS development language, with the recent news that Java has surpassed C++ as the #1 language for SourceForge projects.
Anyway, I though I'd toss that out there and get some opinions from other Slashdot readers. Any thoughts, advice, and/or rants are appreciated :)"
Re:Just Pick One and Learn it Well (Score:5, Informative)
It doesn't matter too much (Score:5, Informative)
The language (whether C# or Java) is just how you express what it is you're trying to accomplish.
Now - With all that said: I'd take Java, for one simple reason: It's been around longer and there are more free resources out there to help you with it.
But remember - as much as 90% of what you learn in Java will apply to C# and vice versa, as long as you focus on the base language (and not API's like SWT, Swing, or WinForms).
Re:Just Pick One and Learn it Well (Score:3, Informative)
You can download them for free here. [microsoft.com] You can also get SQL 2005 Express Edition on the same page.
Learn the concepts not the Language. (Score:2, Informative)
Re:Just Pick One and Learn it Well (Score:3, Informative)
Re:Java.. (Score:5, Informative)
The exact opposite, actually. .NET has an excellent framework for web services.
Wish I got to use C# instead (Score:3, Informative)
C# has goto, unsigned data types, all data types treated as objects,
It already wins in my book.
Unless I could choose Python instead. :D
Re:Just Pick One and Learn it Well (Score:3, Informative)
I agree.
I've been using Java since 1996, and it's served me well. But Sun are being way to proprietary about lots of bits of the language and libraries, and it isn't really an open source system. Same is true of C#, no better, not significantly worse. It's also really wrong to think of these as two different languages - they're /much/ more similar than dialects of LISP, for example.
Obviously learn Java (Score:3, Informative)
I'm assuming you're more productive with Linux than Windows. Since you're a student, it seems obvious to me that you should learn Java. Why? Because it's easier to develop (and compile) Java code on a linux machine than it is to develop (and compile!) C# code on a linux machine. I'm assuming you want to be sitting at a linux box when doing your assignments (whether at home or in the computer lab), since you'll be more productive, and can concentrate on programming rather than on the idiosyncrasies of the OS/GUI you are using.
Purely to make this learning experience as fruitful as possible, I recommend sticking with Java on Linux. In the future, support for C# coding on Linux may be better... but you need to learn now!
Re:What I did myself (Score:1, Informative)
Re:Just Pick One and Learn it Well (Score:5, Informative)
The biggest problem with leaning Java is the class libraries. Eclipse makes it easy to learn them, especially with the ctrl-space completion.
choice (Score:2, Informative)
it is not about the language
imho java 5.0 (or 1.5, whatever you prefer) is the better language, but this does not matter at this point. what matters is the whole environment: the java community process (which btw led us to ejb3.0), some kind of openness (no vendor lock-in, take whatever application server and implementation you like), industry acceptance and a community microsoft does not dare to dream of (remarkable because sun is by a lot of geeks *1 considered "a little bit" evil).
so learn whatever language you like, but gain experience in the important frameworks/ specs and learn about abstraction, and learn why things like pattern insantity and metametameta-models are a bad thing.
*1: and in the end of the day, it is geeks that run the whole software development business, tell me what you want
Learn algorithmization well first (Score:2, Informative)
The processing that goes down to cpu is always the same, its all about algorithmization and data management.
Programming language is only a tool, its like a pen in the hands of a writer.
You may have various types of pen or nice handy language tools, but that doesnt prevent you from writting lame and inefficient code.
Good programmer can use any of todays programming languages. The only thing you need to learn is to pickup the syntax of that particular language.
Object oriented languages like Java, C#, C++ are so similar, and most of the "learning" time you spend
remembering the common library functions these languages interface with.
I use C++ on regual basis, I had to write some PHP stuff on the server recently. All I needed was to look up the delarations,
syntax for condition stataments, pointers and array handling.
In a hour I was set, and in the next hour the job was done.
Visual Studio is Free! (Score:5, Informative)
Windows 2000 (or was it 2k3?)
Windows XP Pro
Microsoft Office Pro
Microsoft Visio
Microsoft Visual Studio
and something else.
Price is not an issue in this.
Re:Just Pick One and Learn it Well (Score:4, Informative)
Also, it won't work whjen the comeout of the next
Express editions are NOT compatible with different
So, the first hit is free.
Re:Just Pick One and Learn it Well (Score:5, Informative)
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).
Re:Java.. (Score:2, Informative)
using System;
using System.Web;
using System.Web.Services;
namespace GtkWebservice
{
[WebService (Description="Our first web service")]
public class RemoteWebService : System.Web.Services.WebService
{
[WebMethod (Description="Adds two numbers")]
public int Add (int firstNumber, int secondNumber)
{
return firstNumber + secondNumber;
}
}
}
These lines of code will be able to generate all the plumming neccesary to expose a web service (automagically creating WSDL files and such).
Consuming services is also extremely easy. See http://www.mono-project.com/Web_Services [mono-project.com] for an example of creating a proxy class from a WSDL file.
Re:Java - Duh. (Score:3, Informative)
It's funny you say that, given the sprawling
Re:Java - Duh. (Score:2, Informative)
The reason is that currently immutable collection classes must either forsake using the Collection interface (thus giving up compatibility with existing objects that demand a Collection, such as Collections.binarySearch() (okay, the latter takes a List, but same idea)) or must provide dummy implementations of functions such as add() and remove(). The latter functions can do nothing (so just public void add(Object o) { } essentially) or throw an exception. (Okay, so there are other options too, but those are probably the most appealing ones, and, in fact, the Java API says [sun.com] that "The 'destructive' [mutating] methods contained in this interface
The reason that it's important that the objects throw an exception in these methods is that if you call a method that calls, say, add(), that method probably depends on add() succeeding. If add() doesn't succeed and doesn't signal its failure, the calling method might break, enter an infinite loop, etc.
However, this leads us into the situation of having a method that always throws an exception. My claim is that this is a bad state to be in, and that that method would be better off implemented. The reason is that if the method isn't present then the compiler can detect the problem. If I write someImmutableCollection.add(foo), the compiler will yell and say "ImmutableCollection doesn't have a method add." But if I write someCollection.add(foo) where someCollection is a type that implements add() as a throw-only method, the compiler will happily accept it. (At least probably; in this case it's possible to detect it statically. However, in the following case it isn't.) Note that it's still a bug; if that line runs the app will break.
But it gets worse. Because if a method bar() takes a Collection as a parameter, it might call add(). In that case, you can't call bar() with an immutable collection. But the compiler will let you. And, unlike in the last case, it's essentially completely impractical for a compiler to try to detect this.
What this all comes down to is that something that the compiler could tell you easily with a better design has been moved so that it won't be detected until you either run the code (and maybe not always -- perhaps it's a transient bug!) or review it, and neither of those are guranteed to happen. (It's the same reason programs such as Lint have been developed, and why compilers give you warnings.)
(One other comment I have goes back to the JFrame.add() method that originally brought this up. I was working on a program and ran into that design issue. But problem was that it works in 1.5, which is what I was using to develop with. But 1.5 binaries are backward compatible with the JRE 1.4 runtime, so I sent out the binary to other people in my group who then hit the bug. They still would have hit it if it were a compile-time thing because they would have probably had to recompile, but it goes back to a sure thing vs. a not sure thing. Stuff like the library incompatibilities decrease the chance, however small, that these bugs will be found.)
Finally is just the documentation aspect. If I call a method that takes an ImmutableCollection, I *KNOW* it won't add anything to the collection. I know that there isn't a bug in the method that will add something; I know that the documentation in that regard is up-to-date because the documentation IS The code, etc.
(I'll also point out that the particular case I'm talking about could also be rectified by providing something akin to C++'s const. Then ImmutableCollection becomes const Collection, size() and the other non-mutating functions are marked const, add() and the other mutating functions are not marked const, and voila. However, there are still other places where this principal can be applied. There are places where the cost of applying them is prohibitive compared to the benefits though.)
Re:Java. (Score:3, Informative)
In summary, it is indeed patented, but also standardized. As a result, licenses must be given on a reasonable and nondiscriminatory manner. That means they can't decide who gets to have a license and the license terms have to be the same for everyone. Furthermore, they have to follow ISO and ECMA's licensing rules, which prevents overly constrictive licensing. Furthermore, the companies involved have agreed to provide the licenses on a royalty free basis. That's right, they can't even charge a billion dollars for it.
Actually, this places it in almost the _exact same_ legal position as Java. Java is a standard, but Sun holds many patents on java technology. They've agreed to let anybody have a license, and not to charge royalties on people who build their own VMs.
Re:Java. (Score:2, Informative)
The C# language is very well defined. [microsoft.com] Unencumbered? What, pray tell, is encumbering about C#? It's almost exactly like Java. Sure, there are probably a few more keywords to throw around, but all of them have a pretty well-defined place. I find the language quite the opposite of cumbersome.
What numbers are you looking at? In Dallas at least, there is extremely high demand for C#/.NET developers.
By default, you can't even use unsafe code without explicitly telling the compiler to allow it. Unsafe code is rarely used throughout the actual framework itself, but when it is, it's primary purpose is performance. I suppose that they should have bit the bullet and used a slower method, so you could complain about performance instead?
This may be somewhat true for any non-object oriented language, but their claim does hold: the runtime can, theoretically, support any language -- it all compiles to what basically amounts to assembler code. But, I'd rather the runtime support a language style that is highly used than anchor the thing down because want their [insert obscure programming language here] to compile just as efficiently. In light of that, the efficiency of the compiler is probably more related to how much work is put into making it efficient in IL code. C may be a better language, but code written in BASIC will run faster if the C compiler sucks. Not surprisingly, people are more interested in optimizing C code.
Which is unfortunate, I've had occasion to want to use Mono, and I'd love to run ASP.NET 2.0 code on a linux box (I still think Apache > IIS).
Re:Just Pick One and Learn it Well (Score:5, Informative)
Re:Java. (Score:3, Informative)
So
The
Just because you hate Microsoft doesn't mean everything they do is bad. Maybe in twenty years we would even like them as much as IBM today.
b4n
C# is liked by even a C/Unix programmer (Score:2, Informative)
To me language is a Tool only--I have no religion about it (I am pretty religious about OSs though) and to that end this is my liking.
C - started on it, so natually like it
C++ - hated it, very complex language
PERL - great one but it is too similar to C and I have difficulty coding in it.
Java - too heavy and too much bullshit programmers blaming everything other than their own code and Sun is hoping that they will just spec out the classes and someone else will do the hardwork of coding it while they retain the control--yeaaah right! I hated it
C# - Very nice language. I wish they did not get rid of "printf" type routines, other than that, this is a very good tool.
This is just my perception. MSFT may be evil for now, but if being evil does not increase their profit margin, they will come around and be saint! And when that happens, I bet they will smell and look like Linux and the old unix whore will happly work on that ...
Re:Just Pick One and Learn it Well (Score:3, Informative)
If you're programming in Java, Eclipse's code assist can be linked to the source code and the documentation for not just the standard library but ANY library that the project uses. IIRC, you can do this with Visual C# Express but it's a pain in the ass and it makes you jump through hoops for everything other than the standard library.
I must say that I'm talking out of my ass here, but I can't see this as being true. You need to include the library in the project in Eclipse to get it to give you code assist (or run), and I can't see it taking much more in VC#. But I could be wrong because I don't have any 3rd party libraries to test...
Eclipse also has a wonderful Javadoc engine which can make writing good Javadocs extremely simple and less time consuming.
I don't remember exactly what all Eclipse has, but Visual C# does the couple things I tested. (Specifically, if you're writing a function int foo(int i) it will insert the returns and param lines for you.)
That said, after a quick experimentation can't figure out how to get from the generated XML files (which aren't generated by default) to something like a webpage, but I'm sure there's a way.
And while I'm at it, let me add that the project configuration is completely different in VC# and VC++. Why is that?
Eclipse has very nice database integration plug-ins available. Including plug-ins that generate diagrams, UML etc.
At least the professional versions of VS will generate class diagrams for you. Don't know how close they are to being fully UML compliant (but they look pretty good), how easy it is to use, etc. The help files indicate that the ability SHOULD be in the Express editions, but I can't find it.
(BTW, I found this when looking for how to refactor stuff in C++, since they are trumping that as a big feature. Turns out it's pretty limited, but you can rename things from the class diagram.)
In any case, VC++ Express will give you call graphs. (Though not very nice ones; they're set up just using a standard tree control. But it works)
Finally, I have one gripe about the Eclipse UI. This is based off of 3.0 I think, so it's possible it's been fixed in 3.1. But for things where you right click and do something to an entitiy, say right click - refactor - rename or right click - find references, the basis for what the action is done to is not what you clicked on but the text cursor location. This is a pretty minor thing in comparison to most of the benefits, but it's still maddening.
Also (okay, I lied about the finally before), Eclipse is decidedly less snappy in terms of response than the Visual Studio Express editions. It's not a big thing, but the computers I've used it on (which are aged but still more than fine for most things) have ever-so-slight delays when opening menus and whatnot.
Re:If you are at DeVry (Score:3, Informative)
CIS majors don't deal with embedded microprocessor programming.
That's brilliant. You completely defeated the insult. Well done.