Java vs. .Net Livslang Uddannelse August 20th, 2004 - PowerPoint PPT Presentation

About This Presentation
Title:

Java vs. .Net Livslang Uddannelse August 20th, 2004

Description:

Title: To .Net or not to .Net Author: Bent Thomsen Last modified by: psteknik Created Date: 1/16/2002 7:13:17 PM Document presentation format: On-screen Show – PowerPoint PPT presentation

Number of Views:133
Avg rating:3.0/5.0
Slides: 59
Provided by: Bent58
Category:

less

Transcript and Presenter's Notes

Title: Java vs. .Net Livslang Uddannelse August 20th, 2004


1
Java vs. .NetLivslang UddannelseAugust 20th,
2004
  • Bent Thomsen
  • PhD, DIC, Cand.Scient, EurIng, CEng, FBCS, MACM,
    MIEEE
  • bt_at_cs.auc.dk
  • Department of Computer Science
  • Aalborg University

2
What is Microsoft .Net?
  • It is a vision
  • The platform for the digital future
  • .NET is Microsofts platform for a new computing
    model built around XML Web ServicesMicrosoft
    Corporation Annual Report, 2001
  • It is a brand name
  • Applied to many things
  • It is a set of products and technologies
  • Infrastructure
  • Tools
  • Servers
  • Services
  • .Net is Microsofts core business Strategy

3
A Unified Programming Model
4
.NET Technologies
  • The .NET Framework
  • The CLR with support for XML Web services and
    more
  • Supporting Visual Basic.NET, C, C, and more
  • The .Net development tools
  • Visual Studio.Net
  • The .NET Enterprise Servers
  • BizTalk Server 2003, SQL Server 2003, Commerce
    Server 2003 and more
  • The .Net Services
  • Passport, My Services, bCentral, expedia and more

5
Microsoft .NET
Web services support across the Microsoft
platform
6
The Core of .NET Framework FCL CLR
  • Common Language Runtime
  • Garbage collection
  • Language integration
  • Multiple versioning support (no more DLL
    hell!)
  • Integrated security
  • Framework Class Library
  • Provides the core functionality
  • ASP.NET, Web Services, ADO.NET, Windows Forms,
    IO, XML, etc.

7
.NET Framework Common Language Runtime
  • CLR manages code execution at runtime
  • Memory management
  • Kills entire classes of bugs (e.g., memory
    corruption, ref counting)
  • Thread management, etc.
  • Auto-versioning, no more DLL Hell

Common Language Runtime
Operating System
8
.NET Framework Base Class Library
  • Object-oriented collection of reusable types
  • Collections, I/O, Strings,

.NET Framework (Base Class Library)
Common Language Runtime
Operating System
9
.NET Framework Data Access Layer
  • Access relational databases
  • Disconnected data model
  • Work with XML

ADO .NET and XML
.NET Framework (Base Class Library)
Common Language Runtime
Operating System
10
.NET Framework ASP.NET Windows Forms
  • Create applications front-end Web-based user
    interface, Windows GUI, Web services,

ASP .NET Web Forms Web Services Mobile Internet
Toolkit
Windows Forms
ADO .NET and XML
.NET Framework (Base Class Library)
Common Language Runtime
Operating System
11
.NET Framework
System.Web
System.Windows.Forms
  • Services
  • Description
  • Discovery
  • Protocols
  • UI
  • HTML Controls
  • Web Controls

Design
Component Model
System.Drawing
Security
Cache
Drawing 2D
Printing
Session State
Configuration
Imaging
Text
System.XML
System.Data
SQL Client
ADO.NET
XML Document
Serialization
SQL ServerCE
Design
Xslt/XPath
Reader/Writers
System
IO
Collections
Configuration
  • Runtime
  • Interop Services
  • Remoting
  • Serialization

Net
Security
Service Process
Reflection
Text
Diagnostics
Resources
Globalization
Threading
12
.NET Framework Programming Languages
  • Use your favorite language

C
C
VB.NET
Perl
J

Common Language Runtime
Operating System
13
.NET Framework Common Language Specification
Common Language Specification
Common Language Runtime
Operating System
14
Common Type System (CTS)
  • All .NET languages have the same primitive data
    types. An int in C is the same as an int in
    VB.NET, COBOL.Net, Haskell,
  • When communicating between modules written in any
    .NET language, the types are guaranteed to be
    compatible on the binary level
  • Types can be
  • Value types passed by value, stored in the
    stack
  • Reference types passed by reference, stored in
    the heap
  • Strings are a primitive data type now

15
Common Language Specification (CLS)
  • Any language that conforms to the CLS is a .NET
    language
  • A language that conforms to the CLS has the
    ability to take full advantage of the Framework
    Class Library (FCL)
  • CLS is standardized by ECMA

16
.NET Languages
  • Languages provided by Microsoft
  • C, C, J, VB.NET, JScript
  • Third-parties languages
  • Perl, Python, Pascal, APL, COBOL, Eiffel,
    Haskell, ML, Oberon, Scheme, Smalltalk
  • Advanced multi-language features
  • Cross-language inheritance and exceptions
    handling
  • Object system is built in, not bolted on
  • No additional rules or API to learn
  • All compile to .Net Assemblies
  • Contains MSIL and metadata

17
Intermediate Language
  • .NET languages are compiled to an Intermediate
    Language (IL)
  • IL is also known as MSIL or CIL
  • CLR compiles IL in just-in-time (JIT) manner
    each function is compiled just before execution
  • The JIT code stays in memory for subsequent calls
  • Recompilations of assemblies are also possible

18
Example of MSIL Code
  • .method private hidebysig static void Main() cil
    managed
  • .entrypoint
  • // Code size 11 (0xb)
  • .maxstack 8
  • IL_0000 ldstr "Hello, world!"
  • IL_0005 call void mscorlibSystem.Conso
    leWriteLine(string)
  • IL_000a ret
  • // end of method HelloWorldMain

19
.Net AssembliesCompilation
Source Code
C, C, VB or any .NET language
20
.Net Execution ModelCommon Language Runtime
Source code
VB
C
C
Compiler
Compiler
Compiler
Managed code
Common Language Runtime
JIT Compiler
Native Code
Operating System Services
21
Managed Code Execution
22
.NET Security
  • Role-based Security
  • What the user is allowed to do within the
    application
  • .NET Roles Windows Active Directory groups
  • Code Access Security
  • What the code is allowed to do on this machine
  • Evidence Based (Policies, Permissions, Evidence)
  • Cryptography Built In to .NET FX

23
Visual Basic .NET
  • Evolution, not revolution, of language used by
    developers worldwide
  • Builds on existing technology while adding power
  • True OOP
  • Multithreading
  • NT Services
  • Web Services
  • The fastest way to build scalable applications
    for industry

24
Visual J .NET
  • Native support for XML Web services
  • Fully integrated with Visual Studio .NET
    development environment
  • Full access to the .NET Framework
  • ASP.NET, ADO.NET, Windows Forms
  • Integration with gt20 other languages
  • Protection of existing investments
  • Use java language syntax on .NET
  • Move applications and skills forward

25
Visual C .NETContinue to provide most powerful
and flexible language
  • Better ANSI/ISO conformance
  • Enable seamless, incremental use of .NET
    Framework
  • Enhanced ATL Servers
  • Improved ATL and MFC Clients
  • Enhanced STL

26
Visual C .NET Component Oriented Language
  • C is the first component oriented language in
    the C/C family
  • Component concepts are first class
  • Properties, methods, events
  • Design-time and run-time attributes
  • Integrated documentation using XML
  • Enables one-stop programming
  • No header files, IDL, etc.
  • C heritage simplification with no unnecessary
    sacrifices
  • If you are serious about .Net you need to learn C

27
C
  • Hello world

using System class HelloWorld public static
void Main() Console.WriteLine(Hello
World!") gtcsc HelloWorld.cs gtHello
World!
28
C
  • Properties

29
C
  • Parameter Passing
  • By Value

30
C
  • Pointers
  • Not recommended for use

public struct Node public int value
public unsafe Node next
public unsafe class A . . .
public class A public unsafe void B (char p)
. . .
31
C
  • Boxing / Unboxing
  • Allows value types to be converted to and from
    objects automatically

ArrayList list new ArrayList() int z
100 list.Add(1) list.Add(13.12)
list.Add(z) //integers are automatically
boxed //when they are added to the
list
32
C
  • Versioning
  • C requires developers to clearly state their
    intent
  • Use of the keyword new and override

Class Derived B new public void x () . .
.
Class Derived B public override void x ()
. . .
33
C 2.0 Language Enhancements
  • Generics
  • Anonymous methods
  • Iterators
  • Partial types

34
Generics
public class ListltTgt private T elements
private int count public void Add(T
element) if (count elements.Length)
Resize(count 2) elementscount
element public T thisint index
get return elementsindex set
elementsindex value public
int Count get return count
Listltintgt intList new Listltintgt() intList.Add(
1) // No boxing intList.Add(2) // No
boxing intList.Add("Three") // Compile-time
error int i intList0 // No cast required
35
Visual Studio .NET
  • Development tool that contains a rich set of
    productivity and debugging features
  • Supports managed and unmanaged applications
  • Supports C, C, VB.NET,
  • Many useful tools and wizards
  • Windows Forms Designer
  • ASP.NET Web Forms Designer
  • Web Services support
  • SQL Server integration with ADO.NET and XML
  • VS.NET is not part of the .NET Framework
  • Not necessary to build or run managed code
  • The .NET Framework SDK includes command line
    compilers

36
VS.NET Single Development Environment
  • From Visual Studio.NET you can
  • Write code
  • Design user interface
  • Study documentation
  • Debug
  • Test
  • Deploy
  • Same tools for all languages
  • Same tools for all platforms

37
Visual Studio .NET
38
Referencing the Framework
39
.NET Applications
  • Web Form Next Generation ASP Page
  • Win Form Next Generation Win32 App
  • Web Services Key to Interoperability
  • Others
  • Server Objects
  • Console Applications
  • Window Services
  • Mobile Clients
  • Many more

40
ASP.NET
  • Server-side Web Forms and Web Services components
    separate code from content
  • Developer productivity increases
  • Tools easily use ASP.NET
  • Any programming language full VB, JScript, C,
    COBOL, Perl, etc.
  • 40 to 70 reduction in lines of code
  • Compiled
  • No-touch deployment system
  • Intelligent state management
  • Backwards compatible with ASP
  • Controls sense client and adapt output HTML,
    DHTML, WML

41
What Is an XML Web Service?
  • A Component That Uses XML HTTP To Define and
    Deliver A Service
  • Global reach
  • Based on open set of standards
  • Reuse across platforms
  • Works with any operating system, programming
    language, or network
  • Expose legacy code
  • Different systems can actually talk

42
Web ServicesOpen Standards Protocols
  • XML
  • Universal data format
  • Standards-based integration
  • User-customizable
  • HTTP
  • Ubiquitous protocol
  • Universally understood

43
VS.NET and Web Services
  • Expose functionality as service
  • No need to learn XML, SOAP, or WSDL
  • Interface is automatically generated
  • Seamless deployment
  • Reuse existing Web Services
  • VS.NET generates the plumbing
  • Full IntelliSense support
  • Build and consume with any VS language

44
Software as a ServiceVisual Studio .Net and the
Net Framework
  • Built-in Support for Developing and Consuming Web
    Services
  • Based entirely on open standards
  • Automatically generates WSDL
  • Automatically provides test page
  • Attribute based No heavy coding needed

WebMethod
Public Function HelloWorld() as String return
Hello World End Function
45
Windows Forms
  • Rich, powerful client UI
  • Control anchoring, visual inheritance
  • Shared across all .NET languages
  • No-touch deployment
  • Secure
  • Semi-trusted browser component
  • Fully-trusted local application
  • Full Web Service integration

46
.Net on other Platforms
  • .Net Compact Framework
  • PocketPC, XScale, ARM,
  • SSCLI
  • BSD Unix, Mac OS X
  • Mono
  • Linux

47
.Net CF
  • Target mobile and embedded devices
  • Portable subset of .NET Framework
  • No new compact namespaces
  • Visual Basic .NET and C compiler support in v1
  • Leverage Visual Studio .NET
  • Run managed .EXEs and .DLLs directly
  • Debug with Visual Studio .NET
  • Peacefully co-exist with host OS
  • Run on native threads, P/Invoke to call native
    code

48
Execution Engine Commonalities
  • Verifiable type safe execution
  • No uninitialized variables, unsafe casts, bad
    array indexing, bad pointer math
  • Garbage Collection
  • No ref-counting, no leaks
  • JIT compilation
  • Error handling with exceptions
  • Common type system
  • Call, inherit, and source-level debug across
    different languages

49
Execution Engine Differences
  • No ASP.NET
  • COM Interop
  • Good support for calling native DLLs
  • P/Invoke PlatformInvoke enables calls to
    Win32 DLLs
  • Support for calling COM objects using dll
    wrappers
  • No support for writing COM/ActiveX objects
  • No Install-time JIT (nGen)
  • No Reflection Emit
  • No Remoting
  • Client web services is fully supported
  • No Generic Serialization
  • Datasets can be serialized to XML
  • No binary Serialization

50
Other Differences
  • Class libraries are a subset (about 25)
  • Different size and scalability characteristics
  • Compact Additions
  • IrDA support
  • SQL Server CE managed classes
  • Device-specific controls

51
.NET Framework
System.Web
System.Windows.Forms
  • Services
  • Description
  • Discovery
  • Protocols
  • UI
  • HTML Controls
  • Web Controls

Design
Component Model
System.Drawing
Security
Cache
Drawing 2D
Printing
Session State
Configuration
Imaging
Text
System.XML
System.Data
SQL Client
ADO.NET
XML Document
Serialization
SQL ServerCE
Design
Xslt/XPath
Reader/Writers
System
IO
Collections
Configuration
  • Runtime
  • Interop Services
  • Remoting
  • Serialization

Net
Security
Service Process
Reflection
Text
Diagnostics
Resources
Globalization
Threading
52
.NET Compact Framework
System.Web
System.Windows.Forms
  • Services
  • Description
  • Discovery
  • Protocols
  • UI
  • HTML Controls
  • Web Controls

Design
Component Model
System.Drawing
Security
Cache
Drawing 2D
Printing
Session State
Configuration
Imaging
Text
System.XML
System.Data
SQL Client
ADO.NET
XML Document
Serialization
SQL ServerCE
Design
Xslt/XPath
Reader/Writers
System
IO
Collections
Configuration
  • Runtime
  • Interop Services
  • Remoting
  • Serialization

Net
Security
Service Process
Reflection
Text
Diagnostics
Resources
Globalization
Threading
53
How to Create a Smart Device Application
  • Create a New Smart Device Application Project
  • Choose the platform and type of project
  • Add additional forms, controls, and code

54
What Are Smart Device Projects?
  • Smart Device Projects are used to develop
    applications that target the .NET Compact
    Framework
  • Supported devices include
  • Pocket PC 2000, 2002 and 2003
  • Pocket PC 2002 Phone Edition
  • SmartPhone 2003
  • Custom-designed embedded devices built with the
    Windows CE .NET 4.1 operating system
  • Supported languages are Visual Basic and C

55
.NET Framework on Linux
  • Mono Project
  • Open Source C compiler, CLR and Framework Class
    Library
  • Runs on various platforms and hardware
  • Linux, Unix, FreeBSD, Windows JIT-compiler for
    x86
  • s390, SPARC, PowerPC interpreter for these
    hardware architectures
  • Supports also
  • ADO.NET and XML
  • Windows Forms (not fully)
  • ASP.NET
  • Web Services

56
.NET Framework on Linux (2)
  • Mono Project
  • Runs .NET portable executables on Linux, e.g.
  • mono myapp.exe
  • Compiles .NET applications to portable
    executables, e.g.
  • mcs myapp.cs
  • The obtained .exe file can taken and run on
    Windows
  • DotGNU Portable.NET
  • Build and execute .NET applications on GNU/Linux,
    Windows, Solaris, NetBSD, FreeBSD, and MacOS X

57
.NET (R)Evolutionary
  • Evolutionary
  • Existing Skills Migrate Smoothly
  • Interoperates with Existing Applications
  • Extension of WinDNA Architecture
  • Revolutionary
  • Common Language Runtime
  • Deployment / Versioning (Ends DLL Hell)
  • Web Services XML Integration
  • Evidence Base Code Access Security

58
Future of .Net
  • .Net is Microsofts core strategy
  • .Net will be part of OS in the next generation of
    Windows
  • Lots of innovation in Longhorn Avalon, indigo,
    WinFS
Write a Comment
User Comments (0)
About PowerShow.com