Valhalla Legends Forums Archive | Java Programming | Java vs J#

AuthorMessageTime
MoNksBaNe_Agahnim
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
March 15, 2004, 9:56 PM
Tuberload
http://www.javaworld.com/javaworld/jw-11-2001/jw-1121-iw-jsharp.html? is a good article on the differences and similarities.
March 15, 2004, 10:25 PM
DaRk-FeAnOr
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.
March 16, 2004, 6:26 AM
iago
[quote author=DaRk-FeAnOr link=board=34;threadid=5795;start=0#msg49691 date=1079418411]
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]

Thus defeating the main advantage of Java....
March 16, 2004, 2:32 PM
DaRk-FeAnOr
That is why J# is a ghetto form of Java. ;)
March 17, 2004, 1:36 AM
Myndfyr
[quote author=DaRk-FeAnOr link=board=34;threadid=5795;start=0#msg49691 date=1079418411]
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]

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:
[code]
public class MyClass
{
// code ...
public String getName() { return m_name; }
public void setName(String value) { m_name = value; }
}
[/code]

Microsoft Nomenclature, enabling properties:
[code]
public class MyClass
{
// code...
/** @property */
public String get_Name() { return m_name; }
/** @property */
public void set_Name(String value) { m_name = value; }
}
[/code]

Now, with properties, what we can do with C# or VB is something along the lines of:

[code]
[C#]
MyClass mc = new MyClass();
//...
string theName = mc.Name;
[VB]
Dim mc As New MyClass()
' ...
Dim theName As String
theName = mc.Name
[/code]

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.
March 26, 2004, 2:51 AM

Search