SlideShare uma empresa Scribd logo
1 de 54
Java vs. .Net
Bent Thomsen
bt@cs.auc.dk
Department of Computer Science
Aalborg University
A typical .NET Enterprise Solution

IIS on W2k Server
Browser

Windows
Client

ASP
.NET

.NET
managed
component

SQL
Server
A typical J2EE Enterprise Solution

Java App
Server
Servlet
EJB
JSP

Browser

Java
Client

DB
Server
Java vs .Net Solutions

– 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.
– Very difficult to compare and qualify the comparison
because each has its own advantages &
disadvantages.
The TMC Petshop Performance Case Study
•

Java Pet Store is Sun’s primary blueprint application for J2EE
–
–
–

•

The .NET Petshop is a port of the J2EE Java Pet Store to .NET
–
–
–

•

Source: http://java.sun.com/j2ee/blueprints
Illustrates best coding practices for J2EE
Ships as a sample application in IBM Websphere, Oracle Application
Server 9i, Sun iPlanet, and
BEA WebLogic
Source: http://www.gotdotnet.com/compare
Implements the same functionality as Java Pet Store
Illustrates best coding practices for .NET Framework

In the TMC Petshop Performance Case Study, The Middleware
Company implemented both the Java Pet Store and the .Net
Petshop.
–
–

The J2EE version ran on two different application servers
All versions used the same hardware and OS
Java Pet Store Components
– The Storefront presents the main user interface in a
Web front-end. Customers use the Storefront to place
orders for pets.
– The Order Processing Center (OPC) receives orders
from the Storefront.
– The Supplier fulfills orders from the OPC from
inventory and invoices the OPC.
– The Admin presents the administrator interface in a
JFC/Swing front-end. Administrators use the Admin
to examine pending orders and approve or deny them.
Java Pet Store vs. .Net Pet Shop
Porting Java Pet Store to .NET
15500

14,273

Lines of Code Required

14000

.NET Petshop
11500

Java Pet Store

9000

7500

5,891

5,404

4,410
5000
2,865

2,566
710

2500

Total Lines
of Code

User
Interface

Middle Tier

761

412

74

Data Tier Configuration
TMC Pages per Second
TMC Max Supported Users
How Microsoft interprets the data
–
–
–

Based on Oracle-published data for tuned version of Java Pet Store
Using Oracle’s test scripts from their “9i App Server Challenge”
Run on equivalent hardware

Supporting 6 times more users
Response Time (Seconds)

1.0
0.8
0.6

2800% Better performance
0.4
0.2
0

0

500

1000
1500
2000
User Load Level

2500

2750
The “Conclusions”
• Microsoft concludes: ".NET is 28 times faster than J2EE"
–
–
–
–

Because:
“Java PetShop” is Sun’s “best practice” example
Numbers compared with published Oracle results
Identical functionality, all code published and documented

• Can we believe the raw numbers? Yes!
– Why? Microsoft delivers full docs on the entire scenario

• But 28 times really?
The Shootout afterwards
• Java PetShop: J2EE blueprint application
– Built by Sun to show "best practice" design
– Implementation by TMC missed quite a few optimizations

• .NET PetShop
– Built by TMC (with help from MS) with different design
• Plain classes instead of container managed components
• Middle tier moved into ASP.NET
• Using stored procedures instead of ad-hoc SQL
• Uses server-side caching of ASP.NET
• Many performance optimizations applied

• Most Java devotees find this highly unfair
TMC revisits the Pet Shop
• Re-implementation of J2EE version
– 17 times performance increase
– Second version showed some J2EE implementation equal .Net
– Second version is a testimony to performance tuning
What does the comparison tell us?
•
•
•
•

It is very difficult to make such comparisons
That .Net has gained maturity extremely fast
That the two frameworks are very similar
The Devil is in the detail

So let’s look at some details
Comparing the stacks

…

…

Enterprise solutions

Phoenix, Tiles, Java Faces

ASP.Net

JSP

C#

Base Class Library

J2EE Class Library
Java runtime

Win32

J2EE App Servers
Websphere, Weblogic, Tomcat, etc.

MSMQ, COM+, IIS,
WMI, AD, ADAM,
Indexing, UDDI, etc.

JMS

Apache

Win32, Unix, Linux

BEA Weblogic

C++

JDBC

CLR

VB

ADO.NET

Java

Servlets

Webshpere Studio

Visual Studio.net

Struts

Eclipse

Perl

Extensions:

P&P blocks

Python

Third party extensions
Java vs. C#
–
–
–
–

C# is an object oriented language of the C++/Java flavor
Syntax similar to Java and C/C++.
Quite an impressive design and care for details
Java developers will feel comfortable
• most of the time and frustrated when things are different
– MS says: “C# combines the power of VC++ with the ease of
usage of VB”
• Not really true:
– C# is really powerful BUT
– It is not easy to learn for non C++/Java programmers
– It is the language to learn if you are serious about .NET!
Java vs. C#
// This is a comment in Java code
class HelloWorld{
public static void main(String[] args){
for(int i= 1; i<= 100; i++)
System.out.println("Hello!");
}
}
// This is a comment in C#
using System;
class HelloWorld{
static void Main(){
for(int i=1; i<=100; i++)
Console.WriteLine("Hello");
}
}
}
Primitives
• Java
–
–
–
–

int, float, double, etc.
Allocated on stack
Not an Object
Not extensible

// C#
struct Point
{
int x;
int y;
Point(int x, int y)
{
this.x = x;
this.y = y;
}
}

• C#
–
–
–
–
–
–

int, float, double, etc.
structs
Allocated on stack
Inherited from object class
structs can implement interfaces
Cannot inherit from another
class
Classes – Overriding Methods
• Java
– All methods are implicitly
virtual

• C#
– Explicitly use ‘virtual’ and
‘override’ keywords

class B
{
public void foo() { }
}

class B
{
public virtual void foo() { }
}

class D extends B
{
public void foo() { }
}

class D:B
{
public override void foo() { }
}

// D’s foo() overrides B’s foo()

// D’s foo() overrides B’s foo()
Exceptions
• Java
– C++-style try/catch blocks
– finally– action done even after
an exception is caught
– throws – methods identify what
exceptions they throw

• C#
– C++-style try/catch blocks
– finally – same as Java
– Does not support throws clause

// Java – throws an IOException
public void myFunc(int a) throws IOException
{
// Work…
}

// Java and C#
try {
// Stuff…
}
catch {
// Ack!
}
finally {
// Always!
}
Java vs. C#
Java vs. C# vs. C++ vs. VB
Java vs. C# in High-performance computations
C# Features not in Java
•
•
•
•
•
•
•
•
•

No automatic fall-through from one case block to the next
Strongly-typed enums
By reference calls are explicit at caller AND callee
Method overrides are explicit
Supports versioning
Structs (value types)
Integrated support for properties and events
Can still use pointers with RAD language
Can share data and use functionality with components written
in many different languages
CLR vs JVM
C#

VB
.Net

Managed Lots of other
C/C++
Languages

Java

MSIL

Byte Codes

CLR
CTS GC Security
Runtime Services

JRE (JVM)
GC Security
Runtime Services

Windows OS

Mac

Win Unix Linux

Both are ‘middle layers’ between an intermediate
language & the underlying OS
.Net on other platforms
•

ECMA standardisation
– ECMA 334 and 335

•

The Mono Project
–
–
–
–

•

Shared Source Common Language Runtime
CLI, C# and Jscript
FreeBSD and Windows implementations
Linux port underway

DOT GNU project
– Portable .Net implementation
– C# for both CIL and JVM
JVM vs. CLR
– JVM designed for platform independence
• Single language: Java (?)
• A separate JVM for each OS & device
– CLR designed for language independence
• Multiple languages for development
– C++, VB, C#, (J#)
– APL, COBOL, Eiffel, Forth, Fortran, Haskel, SML, Mercury,
Mondrian, Oberon, Pascal, Perl, Python, RPG, Scheme, SmallScript, …
– Impressive usage of formal methods and programming language
research during development
– Impressive extensions for generics and support for functional languages
underway
• Underlying OS: Windows (?)
Java Byte Code and MSIL
•
•
•

Java byte code (or JVML) is the low-level language of the JVM.
MSIL (or CIL or IL) is the low-level language of the .NET Common
Language Runtime (CLR).
Superficially, the two languages look very similar.
JVML:

•
•

MSIL:
iload 1
iload 2
iadd
istore 3

ldloc.1
ldloc.2
add
stloc.3

One difference is that MSIL is designed only for JIT compilation.
The generic add instruction would require an interpreter to track the
data type of the top of stack element, which would be prohibitively
expensive.
JVM vs. CLR at a glance
JVM

CLR

Managed execution
environment

X

X

Garbage Collection

X

X

Metadata and
Bytecode

X

X

Platformabstraction class
library

X

X

Runtime-level
security

X

X

Runs across
hardware platforms

X

?
J2EE 1.5
• J2EE (1.5) preview of 26.4.2004
– Focus on ease of development
• Generics and metadata as in J2SE 1.5 (more like C#)
• Java Studio Creator tool (in beta from April 2004) (more
like Visual Studio .Net)
– Timeframe
• To be discussed at JavaOne in June
• Finalized in approximately one year
– IBM push for truly open source Java
– Others hesitate (even Open Source JBoss)
What about mobile?
• Web Services are fine as n-tier applications with UI
provided through browser, but …
• On mobile devices WAP hasn’t really caught on
• Even iMode hasn’t caught on in Europe
• Renewed Thin/Thick client discussion
• Java applications on Mobile devices are reasonably
successful
• Now Microsoft is moving fast into the field with .Net
Compact Framework
Two Devices

Nokia 6600

Orange SPV E200
Two Devices
Building Mobile Solutions is harder
• Mobile device
– Software infrastructure, hardware requirements

• Communication technology
– On-/Offline scenario
– Wireless Wide Area Networks/ Wireless Local Area Networks
– Communication protocol

• Application architecture scenario
– Thin/fat client

• Data management
– Synchronisation
– On-/offline capabilities

• Security issues
– Dangers for mobile devices
– Threats of communication technology
– Danger of exposing enterprise data
Therefore ...
The Java vs. Net discussion goes mobile
• Java 2 Micro Edition (J2ME) is not ONE Java edition
• An J2ME compliant application consists of
–
–
–
–

Configuration
Profile (e.g. Personal, Mobile Information Device Profile (MIDP))
Application code
Vendor specific UI

• 3 Contenders to compare
– Java 2 Micro Edition – Connected Device Configuration (CDC)
– Java 2 Micro Edition – Connected Limited Device Configuration
(CLDC)
– Microsoft .NET Compact Framework
Student Project
• Group of Master Level Students (Hovedfag)
–
–
–
–

Bjørn D. Rasmussen
Casper S. Jensen
Jimmy Nielsen
Lasse Jensen

• Collaboration with DEIF
• Project Goals
– Build end-to-end mobile client, wireless, webservices based
application with back-end interface to SCADA
– In Java (J2ME/J2EE) and in .Net
– Compare the two solutions on a set of criteria
Basis of comparison
Objective measurements
• Lines of code
• Development tools
• Documentation
• Infrastructure
• Performance
• Architectural pattern
• Security
• Price
• Development time

Subjective measurements
• Developer satisfaction
• End-user satisfaction
DEIF M-Vision
(SCADA up and running in 30 minutes)
SCADA on SmartPhones
Development tools and Documentation
• Server-side is well supported by both Java and .NET IDEs
• On the client-side .NET IDEs benefit from the fact that .NET CF
is so close to .NET (With Java there are separate IDEs for
desktop and mobile application development)
• Compatibility problems between Java vendors
• Java IDEs are slow!
• C# is a richer/more complex language than Java
• Both Java and .NET have well documented API
• Web service documentation
– .NET - MSDN
– Java – Google

• Support for encryption of web services
– .Net CF: HTTPS and SOAP extensions
– J2ME: HTTPS, but only in CDC & MIDP 2.0
Performance
• Server-side web service performance study with:
– Microsoft Application Server (v. 5.1)
– Sun ONE Application Server (v. 7.0)

• Tested for:
– Throughput
– Failure rate
– Average response time
Performance - Throughput
Performance – Average response time
Performance – Failure rate
Development time
• Slow start-up when developing in Java
– Jungle of web service implementations
– IDE incompatibility problems
• Emulators
• kSOAP

• Trouble-free implementation in .NET
Subjective Measures
• Developer satisfaction
– VS.NET integrates web service and mobile application
development far better than any Java IDE
– A subset of an API is a better solution for mobile devices
instead of an entirely new API

• End-user satisfaction
– DEIF would choose a .NET based solution since startup time
is very important
– DEIF only needs a limited number of IDE licenses
– Extra price for a SmartPhone 2003 is insignificant compared
to the value it gives
– The SmartPhone 2003 is more ”fancy” than the Java phones
Students Conclusions
• We see .NET as a better designed framework because:
– it eliminates the language barrier while also being platform
independent
– it makes only little distinction between desktop and mobile
application development
• Sun’s application server performance is very poor compared to
IIS.
• License fees for a Java based solution are cheaper but .NET might
catch up when considering development time
• We tried a combined .NET and Java solution but this has shown
to be very troublesome!
My conclusions
• The two worlds are becoming more and more similar
– But it seems that you have to work harder in Java than in .Net
– .Net is currently driving technology transfer from Research to
Product

• Windows generation at University now
• Watch-out in the mobile world
• Vodafone to offer Microsoft Smart phones
– http://msmobiles.com/news.php/2504.html
– Fed-up with Nokia promoting own brand, rather than operator
brand
What do these comparisons tell us?
•
•
•
•

It is very difficult to make such comparisons
That .Net has gained maturity extremely fast
That the two frameworks are very similar
You will not be sacked for choosing the right J2EE
application server ;-)
• The Devil is in the detail
–
–
–
–

C# is not Java
ADO.NET is not JDBC
CLR is not JVM
CF.Net smartphones are very different from Java Smartphones
Choosing between Java and .Net
• The ultimate choice usually depends not on
technical superiority, but on:
–
–
–
–

cultural/”religious”/political preferences
Skill set of your developers
Customer preference
Vendor relations
The future of Java and .Net
• The two frameworks are becoming more and more alike
• However:
– .Net is Microsoft’s core strategy
• .Net will be part of OS in the next generation of Windows
• Lot’s of innovation in Longhorn – Avalon, indogo, WinFS
– Is Java in Sun’s core strategy?
• Java 1.5 SE is very close to C# 2.0/.Net CLR
• Sun Java Studio Creator somewhat close to VS.Net
• Some talk of JVM as multi-language platform, but not
really so far …
• Sun in “Java as Open Source” battle with IBM
Sun vs. Microsoft Stock Prices

53
Choosing between Java and .Net
• You are most likely to be developing in both
environments for the foreseeable future
– Gartner Group: 30+% of all enterprise applications will have both J2EE
and .Net code
– Often IIS in front of J2EE infrastructure
– Interoperability issues
• Web Services (often too slow or doesn’t support …)
• J2EE/.Net bridge (IL -> JBC or JBC ->IL)

• Look out for “The third way”
– Linux, Apache, MySQL, PhP, …

• Look out for disruptive technologies
–
–
–
–

It only takes one guy to get the right idea
and a small team to implement a completely new platform
and One large company to productise it
or a lot of grassroots …
54

Mais conteúdo relacionado

Mais procurados

.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Java Lover
 
Introduction to ,NET Framework
Introduction to ,NET FrameworkIntroduction to ,NET Framework
Introduction to ,NET FrameworkANURAG SINGH
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)citizenmatt
 
Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5Jeff Blankenburg
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operatorkamal kotecha
 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentationdhananajay95
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)Sujit Majety
 

Mais procurados (19)

.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
HTML for beginners
HTML for beginnersHTML for beginners
HTML for beginners
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Introduction to ,NET Framework
Introduction to ,NET FrameworkIntroduction to ,NET Framework
Introduction to ,NET Framework
 
.Net language support
.Net language support.Net language support
.Net language support
 
Java1
Java1Java1
Java1
 
Inside JVM
Inside JVMInside JVM
Inside JVM
 
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
The how-dare-you-call-me-an-idiot’s guide to the .NET Standard (NDC London 2017)
 
Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5Migrating To Visual Studio 2008 & .Net Framework 3.5
Migrating To Visual Studio 2008 & .Net Framework 3.5
 
basic core java up to operator
basic core java up to operatorbasic core java up to operator
basic core java up to operator
 
Advance java prasentation
Advance java prasentationAdvance java prasentation
Advance java prasentation
 
Programming in c#
Programming in c#Programming in c#
Programming in c#
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Core java
Core javaCore java
Core java
 
Java unit 1
Java unit 1Java unit 1
Java unit 1
 
130700548484460000
130700548484460000130700548484460000
130700548484460000
 
History of Java 1/2
History of Java 1/2History of Java 1/2
History of Java 1/2
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 

Semelhante a Sadiq786

Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsQuontra Solutions
 
Net Framework overview
Net Framework overviewNet Framework overview
Net Framework overviewMohitKumar1985
 
Csharp dot net
Csharp dot netCsharp dot net
Csharp dot netEkam Baram
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5David Voyles
 
Introduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutionsIntroduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutionsQUONTRASOLUTIONS
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net frameworkArun Prasad
 
Modified.net overview
Modified.net overviewModified.net overview
Modified.net overviewFaisal Aziz
 
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav TulachJDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav TulachPROIDEA
 
dot net technology
dot net technologydot net technology
dot net technologyImran Khan
 
Microsoft dot net framework
Microsoft dot net frameworkMicrosoft dot net framework
Microsoft dot net frameworkAshish Verma
 
.Net overview
.Net overview.Net overview
.Net overviewmadydud
 

Semelhante a Sadiq786 (20)

10 Sep08 2003ver
10 Sep08 2003ver10 Sep08 2003ver
10 Sep08 2003ver
 
Manas
ManasManas
Manas
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutions
 
Net Framework overview
Net Framework overviewNet Framework overview
Net Framework overview
 
DOT Net overview
DOT Net overviewDOT Net overview
DOT Net overview
 
Net overview
Net overviewNet overview
Net overview
 
.Net overview
.Net overview.Net overview
.Net overview
 
Csharp dot net
Csharp dot netCsharp dot net
Csharp dot net
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
 
Introduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutionsIntroduction to .NET by QuontraSolutions
Introduction to .NET by QuontraSolutions
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
Modified.net overview
Modified.net overviewModified.net overview
Modified.net overview
 
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav TulachJDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
JDD2015: Java Everywhere Again—with DukeScript - Jaroslav Tulach
 
Csharp dot net
Csharp dot netCsharp dot net
Csharp dot net
 
dot net technology
dot net technologydot net technology
dot net technology
 
Microsoft dot net framework
Microsoft dot net frameworkMicrosoft dot net framework
Microsoft dot net framework
 
.Net overview by cetpa
.Net overview by cetpa.Net overview by cetpa
.Net overview by cetpa
 
Introduction to .net
Introduction to .netIntroduction to .net
Introduction to .net
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
.Net overview
.Net overview.Net overview
.Net overview
 

Último

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 

Último (20)

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 

Sadiq786

  • 1. Java vs. .Net Bent Thomsen bt@cs.auc.dk Department of Computer Science Aalborg University
  • 2. A typical .NET Enterprise Solution IIS on W2k Server Browser Windows Client ASP .NET .NET managed component SQL Server
  • 3. A typical J2EE Enterprise Solution Java App Server Servlet EJB JSP Browser Java Client DB Server
  • 4. Java vs .Net Solutions – 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. – Very difficult to compare and qualify the comparison because each has its own advantages & disadvantages.
  • 5. The TMC Petshop Performance Case Study • Java Pet Store is Sun’s primary blueprint application for J2EE – – – • The .NET Petshop is a port of the J2EE Java Pet Store to .NET – – – • Source: http://java.sun.com/j2ee/blueprints Illustrates best coding practices for J2EE Ships as a sample application in IBM Websphere, Oracle Application Server 9i, Sun iPlanet, and BEA WebLogic Source: http://www.gotdotnet.com/compare Implements the same functionality as Java Pet Store Illustrates best coding practices for .NET Framework In the TMC Petshop Performance Case Study, The Middleware Company implemented both the Java Pet Store and the .Net Petshop. – – The J2EE version ran on two different application servers All versions used the same hardware and OS
  • 6. Java Pet Store Components – The Storefront presents the main user interface in a Web front-end. Customers use the Storefront to place orders for pets. – The Order Processing Center (OPC) receives orders from the Storefront. – The Supplier fulfills orders from the OPC from inventory and invoices the OPC. – The Admin presents the administrator interface in a JFC/Swing front-end. Administrators use the Admin to examine pending orders and approve or deny them.
  • 7. Java Pet Store vs. .Net Pet Shop
  • 8. Porting Java Pet Store to .NET 15500 14,273 Lines of Code Required 14000 .NET Petshop 11500 Java Pet Store 9000 7500 5,891 5,404 4,410 5000 2,865 2,566 710 2500 Total Lines of Code User Interface Middle Tier 761 412 74 Data Tier Configuration
  • 9. TMC Pages per Second
  • 11. How Microsoft interprets the data – – – Based on Oracle-published data for tuned version of Java Pet Store Using Oracle’s test scripts from their “9i App Server Challenge” Run on equivalent hardware Supporting 6 times more users Response Time (Seconds) 1.0 0.8 0.6 2800% Better performance 0.4 0.2 0 0 500 1000 1500 2000 User Load Level 2500 2750
  • 12. The “Conclusions” • Microsoft concludes: ".NET is 28 times faster than J2EE" – – – – Because: “Java PetShop” is Sun’s “best practice” example Numbers compared with published Oracle results Identical functionality, all code published and documented • Can we believe the raw numbers? Yes! – Why? Microsoft delivers full docs on the entire scenario • But 28 times really?
  • 13. The Shootout afterwards • Java PetShop: J2EE blueprint application – Built by Sun to show "best practice" design – Implementation by TMC missed quite a few optimizations • .NET PetShop – Built by TMC (with help from MS) with different design • Plain classes instead of container managed components • Middle tier moved into ASP.NET • Using stored procedures instead of ad-hoc SQL • Uses server-side caching of ASP.NET • Many performance optimizations applied • Most Java devotees find this highly unfair
  • 14. TMC revisits the Pet Shop • Re-implementation of J2EE version – 17 times performance increase – Second version showed some J2EE implementation equal .Net – Second version is a testimony to performance tuning
  • 15. What does the comparison tell us? • • • • It is very difficult to make such comparisons That .Net has gained maturity extremely fast That the two frameworks are very similar The Devil is in the detail So let’s look at some details
  • 16. Comparing the stacks … … Enterprise solutions Phoenix, Tiles, Java Faces ASP.Net JSP C# Base Class Library J2EE Class Library Java runtime Win32 J2EE App Servers Websphere, Weblogic, Tomcat, etc. MSMQ, COM+, IIS, WMI, AD, ADAM, Indexing, UDDI, etc. JMS Apache Win32, Unix, Linux BEA Weblogic C++ JDBC CLR VB ADO.NET Java Servlets Webshpere Studio Visual Studio.net Struts Eclipse Perl Extensions: P&P blocks Python Third party extensions
  • 17. Java vs. C# – – – – C# is an object oriented language of the C++/Java flavor Syntax similar to Java and C/C++. Quite an impressive design and care for details Java developers will feel comfortable • most of the time and frustrated when things are different – MS says: “C# combines the power of VC++ with the ease of usage of VB” • Not really true: – C# is really powerful BUT – It is not easy to learn for non C++/Java programmers – It is the language to learn if you are serious about .NET!
  • 18. Java vs. C# // This is a comment in Java code class HelloWorld{ public static void main(String[] args){ for(int i= 1; i<= 100; i++) System.out.println("Hello!"); } } // This is a comment in C# using System; class HelloWorld{ static void Main(){ for(int i=1; i<=100; i++) Console.WriteLine("Hello"); } } }
  • 19. Primitives • Java – – – – int, float, double, etc. Allocated on stack Not an Object Not extensible // C# struct Point { int x; int y; Point(int x, int y) { this.x = x; this.y = y; } } • C# – – – – – – int, float, double, etc. structs Allocated on stack Inherited from object class structs can implement interfaces Cannot inherit from another class
  • 20. Classes – Overriding Methods • Java – All methods are implicitly virtual • C# – Explicitly use ‘virtual’ and ‘override’ keywords class B { public void foo() { } } class B { public virtual void foo() { } } class D extends B { public void foo() { } } class D:B { public override void foo() { } } // D’s foo() overrides B’s foo() // D’s foo() overrides B’s foo()
  • 21. Exceptions • Java – C++-style try/catch blocks – finally– action done even after an exception is caught – throws – methods identify what exceptions they throw • C# – C++-style try/catch blocks – finally – same as Java – Does not support throws clause // Java – throws an IOException public void myFunc(int a) throws IOException { // Work… } // Java and C# try { // Stuff… } catch { // Ack! } finally { // Always! }
  • 23. Java vs. C# vs. C++ vs. VB
  • 24. Java vs. C# in High-performance computations
  • 25. C# Features not in Java • • • • • • • • • No automatic fall-through from one case block to the next Strongly-typed enums By reference calls are explicit at caller AND callee Method overrides are explicit Supports versioning Structs (value types) Integrated support for properties and events Can still use pointers with RAD language Can share data and use functionality with components written in many different languages
  • 26. CLR vs JVM C# VB .Net Managed Lots of other C/C++ Languages Java MSIL Byte Codes CLR CTS GC Security Runtime Services JRE (JVM) GC Security Runtime Services Windows OS Mac Win Unix Linux Both are ‘middle layers’ between an intermediate language & the underlying OS
  • 27. .Net on other platforms • ECMA standardisation – ECMA 334 and 335 • The Mono Project – – – – • Shared Source Common Language Runtime CLI, C# and Jscript FreeBSD and Windows implementations Linux port underway DOT GNU project – Portable .Net implementation – C# for both CIL and JVM
  • 28. JVM vs. CLR – JVM designed for platform independence • Single language: Java (?) • A separate JVM for each OS & device – CLR designed for language independence • Multiple languages for development – C++, VB, C#, (J#) – APL, COBOL, Eiffel, Forth, Fortran, Haskel, SML, Mercury, Mondrian, Oberon, Pascal, Perl, Python, RPG, Scheme, SmallScript, … – Impressive usage of formal methods and programming language research during development – Impressive extensions for generics and support for functional languages underway • Underlying OS: Windows (?)
  • 29. Java Byte Code and MSIL • • • Java byte code (or JVML) is the low-level language of the JVM. MSIL (or CIL or IL) is the low-level language of the .NET Common Language Runtime (CLR). Superficially, the two languages look very similar. JVML: • • MSIL: iload 1 iload 2 iadd istore 3 ldloc.1 ldloc.2 add stloc.3 One difference is that MSIL is designed only for JIT compilation. The generic add instruction would require an interpreter to track the data type of the top of stack element, which would be prohibitively expensive.
  • 30. JVM vs. CLR at a glance JVM CLR Managed execution environment X X Garbage Collection X X Metadata and Bytecode X X Platformabstraction class library X X Runtime-level security X X Runs across hardware platforms X ?
  • 31. J2EE 1.5 • J2EE (1.5) preview of 26.4.2004 – Focus on ease of development • Generics and metadata as in J2SE 1.5 (more like C#) • Java Studio Creator tool (in beta from April 2004) (more like Visual Studio .Net) – Timeframe • To be discussed at JavaOne in June • Finalized in approximately one year – IBM push for truly open source Java – Others hesitate (even Open Source JBoss)
  • 32. What about mobile? • Web Services are fine as n-tier applications with UI provided through browser, but … • On mobile devices WAP hasn’t really caught on • Even iMode hasn’t caught on in Europe • Renewed Thin/Thick client discussion • Java applications on Mobile devices are reasonably successful • Now Microsoft is moving fast into the field with .Net Compact Framework
  • 35. Building Mobile Solutions is harder • Mobile device – Software infrastructure, hardware requirements • Communication technology – On-/Offline scenario – Wireless Wide Area Networks/ Wireless Local Area Networks – Communication protocol • Application architecture scenario – Thin/fat client • Data management – Synchronisation – On-/offline capabilities • Security issues – Dangers for mobile devices – Threats of communication technology – Danger of exposing enterprise data
  • 36. Therefore ... The Java vs. Net discussion goes mobile • Java 2 Micro Edition (J2ME) is not ONE Java edition • An J2ME compliant application consists of – – – – Configuration Profile (e.g. Personal, Mobile Information Device Profile (MIDP)) Application code Vendor specific UI • 3 Contenders to compare – Java 2 Micro Edition – Connected Device Configuration (CDC) – Java 2 Micro Edition – Connected Limited Device Configuration (CLDC) – Microsoft .NET Compact Framework
  • 37. Student Project • Group of Master Level Students (Hovedfag) – – – – Bjørn D. Rasmussen Casper S. Jensen Jimmy Nielsen Lasse Jensen • Collaboration with DEIF • Project Goals – Build end-to-end mobile client, wireless, webservices based application with back-end interface to SCADA – In Java (J2ME/J2EE) and in .Net – Compare the two solutions on a set of criteria
  • 38. Basis of comparison Objective measurements • Lines of code • Development tools • Documentation • Infrastructure • Performance • Architectural pattern • Security • Price • Development time Subjective measurements • Developer satisfaction • End-user satisfaction
  • 39. DEIF M-Vision (SCADA up and running in 30 minutes)
  • 41. Development tools and Documentation • Server-side is well supported by both Java and .NET IDEs • On the client-side .NET IDEs benefit from the fact that .NET CF is so close to .NET (With Java there are separate IDEs for desktop and mobile application development) • Compatibility problems between Java vendors • Java IDEs are slow! • C# is a richer/more complex language than Java • Both Java and .NET have well documented API • Web service documentation – .NET - MSDN – Java – Google • Support for encryption of web services – .Net CF: HTTPS and SOAP extensions – J2ME: HTTPS, but only in CDC & MIDP 2.0
  • 42. Performance • Server-side web service performance study with: – Microsoft Application Server (v. 5.1) – Sun ONE Application Server (v. 7.0) • Tested for: – Throughput – Failure rate – Average response time
  • 44. Performance – Average response time
  • 46. Development time • Slow start-up when developing in Java – Jungle of web service implementations – IDE incompatibility problems • Emulators • kSOAP • Trouble-free implementation in .NET
  • 47. Subjective Measures • Developer satisfaction – VS.NET integrates web service and mobile application development far better than any Java IDE – A subset of an API is a better solution for mobile devices instead of an entirely new API • End-user satisfaction – DEIF would choose a .NET based solution since startup time is very important – DEIF only needs a limited number of IDE licenses – Extra price for a SmartPhone 2003 is insignificant compared to the value it gives – The SmartPhone 2003 is more ”fancy” than the Java phones
  • 48. Students Conclusions • We see .NET as a better designed framework because: – it eliminates the language barrier while also being platform independent – it makes only little distinction between desktop and mobile application development • Sun’s application server performance is very poor compared to IIS. • License fees for a Java based solution are cheaper but .NET might catch up when considering development time • We tried a combined .NET and Java solution but this has shown to be very troublesome!
  • 49. My conclusions • The two worlds are becoming more and more similar – But it seems that you have to work harder in Java than in .Net – .Net is currently driving technology transfer from Research to Product • Windows generation at University now • Watch-out in the mobile world • Vodafone to offer Microsoft Smart phones – http://msmobiles.com/news.php/2504.html – Fed-up with Nokia promoting own brand, rather than operator brand
  • 50. What do these comparisons tell us? • • • • It is very difficult to make such comparisons That .Net has gained maturity extremely fast That the two frameworks are very similar You will not be sacked for choosing the right J2EE application server ;-) • The Devil is in the detail – – – – C# is not Java ADO.NET is not JDBC CLR is not JVM CF.Net smartphones are very different from Java Smartphones
  • 51. Choosing between Java and .Net • The ultimate choice usually depends not on technical superiority, but on: – – – – cultural/”religious”/political preferences Skill set of your developers Customer preference Vendor relations
  • 52. The future of Java and .Net • The two frameworks are becoming more and more alike • However: – .Net is Microsoft’s core strategy • .Net will be part of OS in the next generation of Windows • Lot’s of innovation in Longhorn – Avalon, indogo, WinFS – Is Java in Sun’s core strategy? • Java 1.5 SE is very close to C# 2.0/.Net CLR • Sun Java Studio Creator somewhat close to VS.Net • Some talk of JVM as multi-language platform, but not really so far … • Sun in “Java as Open Source” battle with IBM
  • 53. Sun vs. Microsoft Stock Prices 53
  • 54. Choosing between Java and .Net • You are most likely to be developing in both environments for the foreseeable future – Gartner Group: 30+% of all enterprise applications will have both J2EE and .Net code – Often IIS in front of J2EE infrastructure – Interoperability issues • Web Services (often too slow or doesn’t support …) • J2EE/.Net bridge (IL -> JBC or JBC ->IL) • Look out for “The third way” – Linux, Apache, MySQL, PhP, … • Look out for disruptive technologies – – – – It only takes one guy to get the right idea and a small team to implement a completely new platform and One large company to productise it or a lot of grassroots … 54

Notas do Editor

  1. &lt;number&gt;
  2. &lt;number&gt;
  3. &lt;number&gt;