In my programming class we had a mix class. Programming 1 (C++) and Programming 2 (Java). I noticed while talking to my teacher and browsing in .Net that there is J#, which is supposed to be Microsofts version of Java, he said something like its Visual Basic meets Java.
My question being, out of pure curiosity since one day I may learn Java, has anyone spent time with J# and if so or have some knowledge of it, what are the difference between Java and J#.
Thanks
-MBane_Agahnim
http://www.javaworld.com/javaworld/jw-11-2001/jw-1121-iw-jsharp.html? (http://www.javaworld.com/javaworld/jw-11-2001/jw-1121-iw-jsharp.html?) is a good article on the differences and similarities.
Java and J# are basically the same thing, except that Microsoft made J# really ghetto. It is not portable and only works on Microsoft operating systems.
Quote from: DaRk-FeAnOr on March 16, 2004, 12:26 AM
Java and J# are basically the same thing, except that Microsoft made J# really ghetto. It is not portable and only works on Microsoft operating systems.
Thus defeating the main advantage of Java....
That is why J# is a ghetto form of Java. ;)
Quote from: DaRk-FeAnOr on March 16, 2004, 12:26 AM
Java and J# are basically the same thing, except that Microsoft made J# really ghetto. It is not portable and only works on Microsoft operating systems.
If you choose to use J# with console applications (what you will mostly be doing in a CS class), then you can use it and it will be completely portable to the JDK.
A few things to note:
In the Microsoft implementation, you can only use up to the JDK version 1.2.1, because Microsoft settled a suit with Sun and they aren't allowed to implement beyond that version of the class library.
Also, the Microsoft standard is a little bit different from the Java standard for nomenclature. Because the .NET platform allows you to use Properties (methods on a class that look like public fields), they decided that in order to do so, they would do something special:
JDK-standard Nomenclature:
public class MyClass
{
// code ...
public String getName() { return m_name; }
public void setName(String value) { m_name = value; }
}
Microsoft Nomenclature, enabling properties:
public class MyClass
{
// code...
/** @property */
public String get_Name() { return m_name; }
/** @property */
public void set_Name(String value) { m_name = value; }
}
Now, with properties, what we can do with C# or VB is something along the lines of:
[C#]
MyClass mc = new MyClass();
//...
string theName = mc.Name;
[VB]
Dim mc As New MyClass()
' ...
Dim theName As String
theName = mc.Name
The nice thing about properties is that they provide the convenience of fields with the power of encapsulation; you can prevent illegal values from being passed in as a parameter.
Events are treated in much the same way; in J# version 1, you can't declare your own typed event-handlers (delegates), but you can consume them. You use syntax similar to add_Handler(
delegate-type-instance); and remove_Handler(
delegate-type-instance);. Delegates are essentially safe function pointers, because they are checked at compile-time to ensure that the function to which they point matches the appropriate parameter type list.
The JavaDoc-style @command commands were added to J++ and then to J# when Microsoft made J++, enabling support for various proprietary extensions. JDK compilers ignore them, so having the @property attribute will be ignored by a JDK compiler.
Cheers.