gavi's picture
From gavi rss RSS  subscribe Subscribe

C# Vs Java 



 

 
 
Tags:  C#  Java  Microsoft  .Net 
Views:  3068
Downloads:  76
Published:  August 11, 2007
 
0
download

Share plick with friends Share
save to favorite
Report Abuse Report Abuse
 
Related Plicks
Microsoft .Net vs. J2EE

Microsoft .Net vs. J2EE

From: emily
Views: 5111 Comments: 1

 
Raybiztech Microsoft .Net Competency Document

Raybiztech Microsoft .Net Competency Document

From: raybiztech
Views: 112 Comments: 0
Raybiztech - Microsoft .Net Competency Document - Case Study - Microsoft Technologies, ASP.net, C#
 
Microsoft-Business- Solutions-Products -Great-Plain49

Microsoft-Business-Solutions-Products -Great-Plain49

From: Whatitat616
Views: 75 Comments: 0

 
Platform Comparison Java and .NET

Platform Comparison Java and .NET

From: emily
Views: 6454 Comments: 1
Java was created by Sun in 1992 
Microsoft introduced .NET and C# in 2000
both platforms are object-oriented, type safe, and have automatic garbage collection
the two platfo (more)

 
Java vs. .NET

Java vs. .NET

From: gavi
Views: 2893 Comments: 0
Java vs. C#
Swing vs. WinForms
 
Comparing .NET and Java

Comparing .NET and Java

From: emily
Views: 23965 Comments: 1
NET
The .NET Framework
Java
Java application servers
Products include:
IBM WebSphere Application Server (more)

 
Java vs. .Net

Java vs. .Net

From: emily
Views: 6556 Comments: 1
Both multi-tiered, similar computing technologies
Both support “standards”
Both offer different tools & ways to achieve the same goal.
A lot of parallelism can be seen. (more)

 
See all 
 
More from this user
Microsoft Office Business Scorecard Manager 2005

Microsoft Office Business Scorecard Manager 2005

From: gavi
Views: 3387
Comments: 0

Google Earth

Google Earth

From: gavi
Views: 4658
Comments: 1

Comparing J2EE with .NET

Comparing J2EE with .NET

From: gavi
Views: 3852
Comments: 0

flash

flash

From: gavi
Views: 2435
Comments: 0

Evolution Of Soa - Gartner

Evolution Of Soa - Gartner

From: gavi
Views: 3933
Comments: 0

MPII Quickstart Chinese

MPII Quickstart Chinese

From: gavi
Views: 1956
Comments: 0

See all 
 
 
 URL:          AddThis Social Bookmark Button
Embed Thin Player: (fits in most blogs)
Embed Full Player :
 
 

Name

Email (will NOT be shown to other users)

 

 
 
Comments: (watch)
 
 
Notes:
 
Slide 1: C# Vs Java ACCU Spring Conference 2002 Heritage Motor Centre 3rd-6th April 2002 Slides at www.thetestplace.com/accu2002/slides Neil B Martin PO Box 506 Milton Keynes MK7 8JD neilm@thetestplace.com 08/12/07 © MakeITso 2002 1
Slide 2: C#  C# Microsoft’s new OO language for .NET  A brief look at the features  I am no C# expert just an interested observer  Try and answer some questions – Is it a replacement for Java ? – Is it more like Java or C++ – Is it a replacement for VB 08/12/07 © MakeITso 2002 2
Slide 3: C# ECMA-334  C# (pronounced “C Sharp”) modern, OO, and type-safe programming language  Download Standard from – http://www.ecma.ch/ecma1/stand/ecma-334.htm  Standards says – It will immediately be familiar to C and C++ programmers. 08/12/07 © MakeITso 2002 3
Slide 4: Getting Started  HelloWorld.cs using System; class Hello { static void Main() { Console.WriteLine("hello, world"); } }  Uses namespaces, like C++ not packages like java  Main has an uppercase letter common in .NET  Does not use :: (not an operator) and -> is only used in unsafe code 08/12/07 © MakeITso 2002 4
Slide 5: C# Types (1) Type object string sbyte short int long byte ushort Description The ultimate base type of all other types String type; a string is a sequence of Unicode characters 8-bit signed integral type 16-bit signed integral type 32-bit signed integral type 64-bit signed integral type 8-bit unsigned integral type 16-bit unsigned integral Example object o = null; string s = "hello"; sbyte val = 12; short val = 12; int val = 12; long val1 = 12; long val2 = 34L; byte val1 = 12; type ushort val1 = 12; 08/12/07 © MakeITso 2002 5
Slide 6: Type uint ulong Description 32-bit unsigned integral type 64-bit unsigned integral type C# Types (2) float double bool char decimal Single-precision floating point Double-precision floating point type Boolean type; a bool value is either true or false Character type; a char value is a Unicode character Precise decimal type with 28 significant digits Example uint val1 = 12; uint val2 = 34U; ulong val1 = 12; ulong val2 = 34U; ulong val3 = 56L; ulong val4 = 78UL; type float val = 1.23F; double val1 = 1.23; double val2 = 4.56D; bool val1 = true; char val = 'h'; decimal val = 1.23M; 08/12/07 © MakeITso 2002 6
Slide 7: Keywords (1)  C# has 77 keywords  C++ has 63  Java has 48  35 are shared  13 in Java are omitted: – boolean,extends,final, implements – import,instanceof, native,package,strictfp, – super, synchronized, throws, transient 08/12/07 © MakeITso 2002 7
Slide 8: Keywords(2)           boolean has become bool No extends or implements uses C++ : syntax final has become sealed native has become extern import and package, become namespace and using super becomes base synchronized becomes lock instanceof becomes is No equivalent for transient, throws and strictfp protected is really internal © MakeITso 2002 8 08/12/07
Slide 9: Inheritance  C# like Java has no Multiple Inheritance  C# like Java allows multiple implementations via interfaces  C# has different access modifiers: C# access modifier private public internal protected internal protected 08/12/07 Java access modifier private public protected N/A N/A 9 © MakeITso 2002
Slide 10: comparison operators == and != Different semantics for different predefined types  Two int’s are considered equal if they represent the same integer value.  Two expressions of type string are considered equal if the string instances have identical lengths and identical characters in each character position, or if both are null.  – Note this is different from Java 08/12/07 © MakeITso 2002 10
Slide 11: Passing Parameters  C# allows varadic method calls, unlike C the mechanism is type checked Func(int a[]){ } Func(); Func(1); Func(2);  We can force a parameter to be passed by reference public void increment( ref int a ) { a++; }  Smacks of register ! © MakeITso 2002 11 08/12/07
Slide 12: Structs   C# has structs Structs are value types struct Point { public int x, y; public Point(int x, int y) { this.x = x; this.y = y; } } 08/12/07 © MakeITso 2002 12
Slide 13: Default Values for Structs  The default value of a struct consists of the value that results from setting all value type fields to their default value struct Point { public int x = 1; public int y = 1; } // Error, initialiser not permitted // Error, initialiser not permitted   Structs have no destructors A variable of a struct type directly contains the data of the struct, whereas a variable of a class type contains a reference to the data, the latter known as an object. 08/12/07 © MakeITso 2002 13
Slide 14: Assemblies    – – – Conceptually like jar files An assembly is the fundamental unit of code packaging in the .NET environment Assemblies are self contained and usually contain: the intermediate code from compiling classes metadata about the classes any other files needed by code to perform its task 08/12/07 © MakeITso 2002 14
Slide 15: Exceptions  Very similar in both languages using System; using System.IO; class MyException: Exception{ public MyException(string message) :base(message){ } public MyException(string message, Exception innerException) :base(message, innerException){ } }  Both languages derive from a single exception class 08/12/07 © MakeITso 2002 15
Slide 16: Reflection     The facility to reverse engineer .class files and determine the methods and fields of the class Integral to making java beans work C# has a similar facility – System.Reflection Tools such as Exemplar 08/12/07 © MakeITso 2002 16
Slide 17: Exemplar  If you compile using J# (Java for IL) then disassemble you get c#  Good tool is Exemplar – www.saurik.com/net/exemplar/ – Both source and binaries are available, though the author is no longer working on it. 08/12/07 © MakeITso 2002 17
Slide 18: Synchronization public void WithdrawAmount(int num) { lock(this) { if(num < this.amount) this.amount -= num; } } 08/12/07 © MakeITso 2002 18
Slide 19: File I/O using System; using System.IO; public class FileIOTest { public static void Main(string[] args){ FileStream inputFile = new FileStream("input.txt", FileMode.Open); FileStream outputFile = new FileStream("output.txt", FileMode.Open); StreamReader sr StreamWriter sw String str; = new StreamReader(inputFile); = new StreamWriter(outputFile); while((str = sr.ReadLine())!= null) sw.Write(str); sr.Close(); sw.Close(); } }//FileIOTest 08/12/07 © MakeITso 2002 19
Slide 20: Getter/Setter Attributes  using System; public class DemoA { private string name; public DemoA(string name){ this.name = name; } // A read-only property for a member variable public string Name{ get{ Console.WriteLine("Getting Name Attribute"); return name; } set { Console.WriteLine("Setting Name Attribute"); this.name = value; } } public static void Main(string[] args){ DemoA var = new DemoA("Joe Bloggs"); Console.WriteLine("Name: " + var.Name); var.Name = "another"; Console.WriteLine("Name: " + var.Name); } } // DemoA 08/12/07 © MakeITso 2002 20 C# has a built in facility for Attributes
Slide 21: Pre-processing Directives  C# has a pre-processing directives  Chose name for consistency with C / C++  There is no separate step during compilation  The name space for conditional compilation symbols is distinct from all others 08/12/07 © MakeITso 2002 21
Slide 22: Java Doc  C# uses XML for its documentation process  Compiler has a /doc option rather than stand alone tool 08/12/07 © MakeITso 2002 22
Slide 23: C# Documentation ///<summary>Class summary Text</summary> public class Something { ///<summary>This is the summary Text</summary> ///<param name="num">Lets us talk about the parameters.</param> ///<return>Here we describe the return value</return> public int DoSomeThing(int num){ return 0; } ///<summary>Summar for Main</summary> public static void Main(string[] args){ Something s = new Something(); int v = s.DoSomeThing(20); } } 08/12/07 © MakeITso 2002 23
Slide 24: Support for COM and .Net  It may seem obvious to say so but support for COM and .NET is one of the major reasons for C#  COM until C# lacked proper language support – Please don’t say VB 08/12/07 © MakeITso 2002 24
Slide 25: Attributes    An attribute is an object that represents declarative data with an element in your program. Once associated we can query it at run time Come in two flavours – Custom – Intrinsic – Many intrinsic attributes are used for interoperating with COM  Checked at compile time 08/12/07 © MakeITso 2002 25
Slide 26: So what can you do with Attributes ? [Serializable] // Declarative Data class x { public int x,y; }  We can query the class at run time to obtain the attribute information 08/12/07 © MakeITso 2002 26
Slide 27: The mono:: project  The Mono project, is an effort to create an Open Source implementation of the .NET Development Framework. – www.go-mono.com – Compiler and Libraries 08/12/07 © MakeITso 2002 27
Slide 28: Conclusions  C# is not a Java clone  The head developer was Anders Hejlsberg who has a few credits to his name: – Turbo Pascal – Delphi – Visual J++  C# is more like C++ than Java © MakeITso 2002 28 08/12/07
Slide 29: C# is Cool  The original project name of C# was Cool  So C# is Cool is just a statement of fact 08/12/07 © MakeITso 2002 29
Slide 30: Standards and Things  Sun could never quite release Java to be standardised  The got as far as handing out the spec in an ECMA meeting then changed their mind – Thoughts of prams and toys  Java now has the Java Community Process – Sort of open to all except Microsoft 08/12/07 © MakeITso 2002 30
Slide 31: Microsoft C#  Microsoft have chosen to standardise C# through ECMA  MS have a poor track record of paying attention to standards, – Time will tell – MS need to embrace the standard in products 08/12/07 © MakeITso 2002 31
Slide 32: ISO Fast Track  Currently an ISO Fast track for C#  Country decisions by June  Microsoft have said that they cannot guarantee that their products will meet the ECMA/ISO spec ! 08/12/07 © MakeITso 2002 32
Slide 33: Finger Pointing  We can look forward to MS pointing out how closed Sun is with Java 08/12/07 © MakeITso 2002 33
Slide 34: Finally  C# creates an interesting intersection between C++ and Java  Some smart vendor may/will/has already created a VM that runs either byte code.  Have you heard of the new language called – ASMoobs (ass moo, silent B.S.) – OO write once run no where 08/12/07 © MakeITso 2002 34

   
Time on Slide Time on Plick
Slides per Visit Slide Views Views by Location