Transcript Document
This is delicious cookie you must eat.
:O~
Problem Domain
• Designed to be
Reliable, high-performance and secure
Comfortable and familiar to Java-language
developers
Assist in the transition to .NET framework
• Developed solely to write software for
Windows, using the .NET framework
Historical Context
Developed by Microsoft from 1998 to 2002.
Named after Java / J++
# marking it as one of the .NET languages (C#,
F#,…)
Recycled from earlier attempt: Visual J++
Historical Context: J++
Windows-specific implementation of Java
J++ programs only capable of running on
Microsoft’s special interpreter, optimized for
Windows.
Sun Microsystems had originally licensed Java
to Microsoft but sued over failure to fully
implement Java specifications.
As part of the settlement, Microsoft ceases
distribution of the interpreter.
J++ developers marooned.
Evolution of the Language
Run-time libraries frozen at the JDK 1.1.4 level
JDK compatibility largely irrelevant due to coverage
elsewhere by the .NET framework.
J# integrated into releases of Visual Studio
Announcements in January 2007:
J# upgrade for 64-bit runtime support, compatibility
with next version of Virtual Studio
J# being retired from future versions of Virtual
Studio, with support for the existing version ending
2015
New Concepts
Same syntax as java
Access to both java API and .NET Framework
library (BCL - Base Class Library)
Cross-language capabilities
method written in one language can be overriden in
another language
Familiar Java Syntax
import System.*;
public class Hello
{
public static void main(System.String[] args)
{
System.out.println("Hello.");
}
}
Familiar Java Syntax cont.
For Java
To Compile - javac Hello.java
To Run - java Hello
For J#
To Compile - jc Hello.java
To Run - Hello
Access to both java API and .NET
Framework library
package ConsoleApp;
import java.io.*;
public class ReadString
{
public static void main(String[] args)
{
String firstName = null;
String lastName = null;
System.Console.WriteLine("Enter your first name: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
firstName = br.readLine();
} catch (IOException ioe) {
System.out.println("IO error");
System.exit(1);
}
System.out.println("Enter your last name: ");
lastName = System.Console.ReadLine();
}
}
System.out.println("Hello " + firstName + " " + lastName);
System.Console.WriteLine("Hello {0} {1}", firstName, lastName);
Cross-language capability
//J# class
import System.*;
public class JLanguage
{
public void
getMessage()
{
System.Console.W
riteLine("J#");
}
}
//C# class
using System;
class CLanguage:JLanguage
{
public static void Main()
{
CLanguage c = new CLanguage();
JLanguage j = new JLanguage();
j.getMessage();
c.getMessage();
}
public override void getMessage()
{
Console.WriteLine("C#");
}
}
Google Search
String
J#
C#
java
Google results
.4M
5M
64M
(not all are re the language, of course)
JAVA vs. J#/.NET
Advantages and Disadvantages
J# offers the following features:
•Generates platform-neutral code
•Support for class libraries of VJ++, JDK 1.1.4
•Brings cross-language capabilities into Java language
•Simultaneously supports both JDK 1.1.4 and BCL (Base Class Library) of .NET
Framework
•Accesses platform-native resources
•Generates XML documentation
•Writes ASP.NET applications
•Writes web services
•Retains the majority of Java-like syntax and features
J#'s disadvantages:
Programs can't run under the umbrella of JVM
No support for the Java Native Interface or Remote
Method Invocation
No operator overloading
Minimal support to convert binaries making J/Direct
calls
Automatic generation of proxy classes for web services
Cannot call WebService methods using Enum types
Cannot add reference to .exe files