JavaZone Java versus .NET english - Brodwall.com

quaggahooliganInternet and Web Development

Feb 5, 2013 (4 years and 6 months ago)

117 views


Copyright © 200
3

Systek AS








brodwall@systek.no

Java versus .NET

The Heavyweight Championship
Showdown


Johannes Brodwall
-

Systek AS


Copyright © 200
3

Systek AS








brodwall@systek.no

Background


Many ask themselves if it is about time to switch
technologies


From Java to .NET


Java and .NET are more than programming
languages.


I have good experience from both Java and .NET
projects


This presentation is based on my experience (it is
subjective, and personal, but real)


Copyright © 200
3

Systek AS








brodwall@systek.no

Overview


Technical comparison


Blow by blow feature comparison


Service
-
level factors


Non
-
technical factors


Summary


what platform should you choose?


Copyright © 200
3

Systek AS








brodwall@systek.no

In the blue corner: the Challenger .NET™


Heir to heavyweights like COM, MTS, ASP!


Developed at the laboratories of the most powerful
organization in the world


Generated enormous interest


Has the challenger learned from the mistakes of its
predecessors?



Object
-
oriented model


Powerful class libraries


Designed for enterprise applikations


Copyright © 200
3

Systek AS








brodwall@systek.no

In the red corner: The Champion Java


Years of proven robustness


Thousands of successful projects


Hundreds of industrial standards


Broad industry support from many companies


The most popular choice in the academic world



Object
-
oriented model


Powerful class libraries


Designed for enterprise applikations


Copyright © 200
3

Systek AS








brodwall@systek.no

Technical issues


Benchmarking


Programming languages


Architecture


Desktop


Mobile


Server


Service
-
level factors


Integration


Portability


Security

Round ONE


Copyright © 200
3

Systek AS








brodwall@systek.no

Status


Java and Windows have been leapfrogging each
other through the nineties


For example:


DCOM


Java RMI

.NET Remoting


ASP


JSP


MTS


EJB


.NET is Microsoft’s next leap


and a long one!


Java is a little behind, but is likely to catch up with
Java 1.5 (Tiger)


2004Q2


Copyright © 200
3

Systek AS








brodwall@systek.no

Benchmarks


There are many benchmarks out there


Most known: Java Pet Store versus .NET Pet Shop


Benchmarks are FUD!


Most benchmarks:


Only tests a few number of things


Can be improved arbitrarily with work


Causes pointless discussions about their validity


Copyright © 200
3

Systek AS








brodwall@systek.no

Language differences


Makes most sense to compare C# and Java


In addition to Java’s features, C# has:


Struct and enum
-
typer


Events, delegators, properties


Operator overloading (Java omits for a reason)


Attributter (enables much good magic)


Autoboxing


Most serious subtraction from Java: Anonymous
inner classes


Copyright © 200
3

Systek AS








brodwall@systek.no

Language differences: Properties


Equivalent to getters and setters in Java


But built into the language

public class MyClass {



public string Name {



get { return (string)properties[”Name”]; }



set { properties[”Name”] = value; }


}




private Hashtable properties = new Hashtable();

}


MyClass obj;

obj.Name += ”, Esq.”;


Copyright © 200
3

Systek AS








brodwall@systek.no

Language differences: Events


Equivalent to Java’s observer idiom


But built into the language

public delegate MyEventHandler(object sender, EventArgs e);


public class MyClass {


public event MyEventHandler MyEvent;



public void FireEvent() {



if ( MyEvent != null ) MyEvent(this, new EventArgs());


}




public static void Main() {



MyClass myObj = new MyClass();



myObj.MyEvent += new MyEventHandler(MyEventHandlerImpl);



myObj.FireEvent();


}



private static void MyEventHandlerImpl(object sender, EventArgs e) {



Console.WriteLine(”In event handler”);


}

}


Copyright © 200
3

Systek AS








brodwall@systek.no

Language differences: Events


Events in Java

public class MyClass extends Observable {


public void fireEvent() {



notifyObservers();


}




public static void Main() {



MyClass myObj = new MyClass();




myObj.addObserver(new Observer() {




public void update(Observable sender, Object arg) {





MyEventHandlerImpl(sender, arg);




}



});



myObj.fireEvent();


}



private static void MyEventHandlerImpl(object sender, object e) {



System.out.printLn(”In event handler”);


}

}


Copyright © 200
3

Systek AS








brodwall@systek.no

Language differences: Attributes


Used like deployment descriptor info


But built into the language


Decorates reflection
-
information with ”metadata”


Requires a middle layer to implement functionality


On my project: Used for a very neat authorization facility

[Transaction(TransactionOption.Required)]

public class Account : ServicedComponent

{


[AutoComplete]


static void Main() {}

}


Copyright © 200
3

Systek AS








brodwall@systek.no

Languages difference


verdict


Many new C# features are good, especially


Autoboxing


Events, Properties


Attributter


C# is more complex


many left C++ because of complexity.


Most important differences compensated in Java 1.5 (Tiger)


but probably not events, properties, and operators.


Both next C# version and Java 1.5: generics


The opponents circle each other and gets in a few blows
each, but there is no real blood yet


Copyright © 200
3

Systek AS








brodwall@systek.no

Enterprise frameworks


Introduction to n
-
tier architecture


Each layer in Java


Each layer in .NET


Comparison, layer by layer


Copyright © 200
3

Systek AS








brodwall@systek.no

N
-
tier architecture

Database

Server

Web
-

server

Application

server

Web Browser

Rich clients

WAP

Rich
client


Copyright © 200
3

Systek AS








brodwall@systek.no

Presentation

Enterprise Architecture

Client

Logic

Resource

Integration

Prepares
data for
display on
client


Web
-
server,
or merged
with client

Interaction
between
user and
physical
system


Web
-
browser,
windows
-
client, mobile
telephone

Business
logic.


Enforces
scalability,
fault tolerance,
security, and
transactions

Database,
message
queue,
mainframe


Normally
outside
system
scope

Handles
communication
to other
systems


Comms to
databases,
mainframes,
message
queues, web
services ...


Copyright © 200
3

Systek AS








brodwall@systek.no

Presentation

Java on a page

Client

Logic

Resource

Integration

Servlets/JSP

Web
browser

Database

JDBC

Swing/AWT

Enterprise
Java Beans:



Stateless
session
beans


Stateful
session
beans


Entity
beans

Other
systems

Web
Services
client

Java 2 Micro Edition


MIDP

WAP
telefon

Message
Queue

JMS

Mainframe
etc

JCA

Java Web Start


Copyright © 200
3

Systek AS








brodwall@systek.no

Presentation

.NET on a page

Client

Logic

Resource

Integration

ASP.NET Web
Forms

Internet
explorer

ASP.NET
Web
Services

Database

ADO.NET

Mobile
Internet
Toolkit

Windows Forms

COM+
Enterprise
Components

Web
Services

Other
systems

Web
Services
client

.NET Compact Framework

WAP
telefon

Message
Queue

MSMQ

Autodeployment


Copyright © 200
3

Systek AS








brodwall@systek.no

Desktop clients


.NET: native ”look and feel”


VS.NET: decent visual
designer


Swing’s APIs are better


E.g.: JTree versus
TreeView


.NET needs third party
libraries to have all you need


Copyright © 200
3

Systek AS








brodwall@systek.no

Windows Forms Designer


Copyright © 200
3

Systek AS








brodwall@systek.no

Mobile clients


Browser
-
based:


Java: No special tools


.NET
: Mobile Internet Toolkit =
hetrogenous clients


Rich clients:


Java: MIDP (J2ME)


Available on many phones


Not very powerful


.NET Compact Framework:


Much less widespread


Much more powerful


Copyright © 200
3

Systek AS








brodwall@systek.no

Some MIDP phones


Copyright © 200
3

Systek AS








brodwall@systek.no

ASP.NET versus Servlets


Both are framework for
generating web apps


ASP.NET: Visual design


First time I have seen visual
design for web pages!


Implemented with
advanced ”taglibs”


Uses a runtime model of
the HTML tree structure

ASP.NET starts where JSP ends


Copyright © 200
3

Systek AS








brodwall@systek.no

The ASP.NET mode

ASP.NET
framework
Bruker
Web Form
Web Browser
Go to page
HTTP Get
OnPageLoad
Label.Text = “Hello World”
Submit.Click += Submit_OnClick
Serialize HTML tree
Return page
Display Page
Change text field
Press submit
HTTP Post
OnPageLoad
Submit_OnClick
Label.Text = “Hi, “ + TextField.Text;
Serialize HTML tree
Return page
Display Page

Copyright © 200
3

Systek AS








brodwall@systek.no

Server
-
based


Transactions: Session Beans versus COM+
Components


Both plattforms:


Scale


Supports security


Supports transactions


Java has demonstrated scalability in many shops


.NET lets you do more with less code


Copyright © 200
3

Systek AS








brodwall@systek.no

Integration


Data access:


Java Entity
-
beans

has poor track record


ADO.NET

has a much simpler model


I like ADO.NET!


Legacy integration: JCA opens, but you need tools


Message queues: MSMQ and JMS


Web
-
services: .NET has such good support that it is
a natural alternative to remoting


Copyright © 200
3

Systek AS








brodwall@systek.no

Alternatives to both J2EE and .NET


N
-
tier does not fits everyone’s ticket


Java: Consider open
-
source frameworks:


Turbine, Prevayler, Hibernate, Struts, XMLC,
Naked Objects (and many more)


Build from scratch


Amazon


Java based (obedos)


Google


Linux
-
basered supercluster


OO
-
script
-
languages: Python, Ruby


LAMP


Copyright © 200
3

Systek AS








brodwall@systek.no

Service
-
level factors


Integration


Portability


Security


Copyright © 200
3

Systek AS








brodwall@systek.no

Integration


CORBA, Mainframes, legacy


Java has the JCA standards


requires 3
rd

party tools


Java supports IIOP


.NET does not address this, only to 3
rd

parties



.NET has
excellent

support for C/C++/COM integration


”IJW”
-
technology


I love it!



Knocks JNI out of it’s socks!



Web services:


Easier in .NET today, but Java is catching up


Copyright © 200
3

Systek AS








brodwall@systek.no

Portability


.NET supports many languages


But only one
language type well


F# may change this


Java support many platforms


For example embedded



Exceptions:


Mono, Rotor


Other languages for JVM (Jython)


But: Don’t bet your shop on it


Copyright © 200
3

Systek AS








brodwall@systek.no

Security


Java has a security model since 1.1


Microsoft has a bad reputation for security


But both consider security important:


Microsoft: “Secure Windows Initiative”


E.g. Oracle: “Can’t break it, can’t break in”



Both support:


SSL, RSA, HTTPS, code security, role based
security, etc. etc.


Copyright © 200
3

Systek AS








brodwall@systek.no

Summary: Technical part


Both platforms provide a good
framework for enterprise systems


There are small technical diffs


.NET is ahead, but this is to be
expected, since it has a more
recent major release


Java is more mature


Important differences


Portability


Copyright © 200
3

Systek AS








brodwall@systek.no

Childish complaints


.NET does not include compression libraries!


Why can’t I find a
good
JSP taglib?


Why does all Java
-
IDE’s require 1 GB RAM?!?


EJBQL!?!?!?


.NET doesn’t let you do the same thing as
anonymous inner functions


at all!



Whassup with that?!?


Copyright © 200
3

Systek AS








brodwall@systek.no

Non
-
technical factors


Cost of ownership


Development costs


Runtime costs


Training costs


Philosophical differences:


Open world or closed?


Maturity

Round
two


Copyright © 200
3

Systek AS








brodwall@systek.no

What is most expensive?

Commercial

Java

Commercial .NET

Open
-
source .NET

Open
-
source Java


Copyright © 200
3

Systek AS








brodwall@systek.no

Software options

Commercial

Open
-
source

Java development

Many, most expensive:
OptimalJ, Together ($5
-
10 000/developer)

Eclipse, NetBeans (both
very good)

J2EE runtime

Several $10,000/CPU

JOnAs, JBoss, Tomcat,
Jetty (mature)

.NET development

Visual Studio .NET ($1
-
3 000/developer)

Borland C#Buider

ISharp (leaves
something to be
wanted)

.NET runtime

Included in OS

ROTOR, Mono (not
mature)


Copyright © 200
3

Systek AS








brodwall@systek.no

Training costs


Switching technologies is
always

expensive


Learning it is pretty easy


Learning to use it
right

is very hard


Even with good developers, it can take months


Get someone experienced


Your developers must be motivated for the
switch, or it will fail



Bottom line: People factors matter


Copyright © 200
3

Systek AS








brodwall@systek.no

Productivity


J2EE is a more complex architecture than .NET


More features, more possibilities


But: Requires a lot of plumbing code


If your doing J2EE: Have a code generation strategy


Improve productivity


Improves consistency


Helps prevent mistakes


Without code generation, .NET will get you there
quicker than J2EE


Copyright © 200
3

Systek AS








brodwall@systek.no

Java’s philosophy


Not formally “standardized”,


Java Community Process


JCP creates specifications, separated companies
create tools



Many companies have influence


Java is controlled by IBM, BEA, and Oracle as mych
as by Sun


J2ME development is controlled by Nokia, Motorola,
Samsung, Ericsson, and others.


Copyright © 200
3

Systek AS








brodwall@systek.no

Microsoft’s Philosophy


Microsoft develops standards


Standards donated to EMEA


Produces standards
and

tools



.NET will always be dominated by Microsoft



I like to call .NET standardization ”Tablets
-
to
-
Moses
-
standardization”


Copyright © 200
3

Systek AS








brodwall@systek.no

Philosophy and us


Is Microsoft or Java more ”standard”?


What does it matter to us?


Java: We must deal with many vendors


Java: Tools may be late, or never


Microsoft: Hinders adoption, especially in the
mobile sphere.


Microsoft: Little real competition (bad for us)


Java: Has stimulated Open
-
Source and research


Copyright © 200
3

Systek AS








brodwall@systek.no

Open
-
source Java


Java has stimulated the open source community
much more than .NET (so far)


Why should we care about open
-
source?


Cost? (seldom important)


Reduced buraucracy


Enableds development organization to take
responsibility for
all the code in the deliveries


Example code


real big example code


Is this important to you?


Copyright © 200
3

Systek AS








brodwall@systek.no

Your existing platform


Integration is always expensive


The most important question:


What does you customers use?


What does you suppliers use?


What does your partners use?


What does your industry use?


What does your existing systems use?


What does your organization understand?


Copyright © 200
3

Systek AS








brodwall@systek.no

Adoption and maturity


You could discuss which ones will scale the most


But there are J2EE installations that have run for a
really long time:


Sense of comfort


Body
-
of
-
knowledge


Mature best practices


Skilled workforce


Copyright © 200
3

Systek AS








brodwall@systek.no

Summary


Java has the largest number of vendors


Commercial Java solutions will be the most
expensive


Switching technologies is always expensive


Java has an open process


Microsoft controls .NET absolutely


There is much Java open source


Java benefits from its maturity


Copyright © 200
3

Systek AS








brodwall@systek.no

Conclusion: When do you use .NET


If you are in the ”Windows world”


Win32, COM etc


Partners, customers, suppliers use .NET


If you need a fancy UI (web or client)


If you need high
-
end device support


If you want to avoid J2EE

complexity


Copyright © 200
3

Systek AS








brodwall@systek.no

When should you use Java?


Partners, customers, suppliers use Java


You need to industrialize a lot of code


And you have good developers


If you care about open source and multiple vendors


You don’t need to use J2EE


You have
very good

developers


You’re targeting mobile mass marked


Copyright © 200
3

Systek AS








brodwall@systek.no

The Future


Both Java and .NET has a brilliant future


J2SE 1.5 (Tiger) is expected 2004Q2


Will catch up with C#


The next generation .NET (Yukon) is unveiled on
PDC 2003


October


The competition is good for
us!


Copyright © 200
3

Systek AS








brodwall@systek.no

Summary


Java and .NET will remain two giant platforms


Technical differences are trivial


Other factors should determine your choice


Switching between platforms is expensive


.NET gives a good integration to the Windows world


Java offers a more open world


Wider cooperation between corporations


Stimulates open source development


Copyright © 200
3

Systek AS








brodwall@systek.no

So: Which platform is
best?