29
Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v. Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page An Introduction to .NET for the J2EE Programmer Jeroen Frijters Sumatra Software b.v. [email protected] http://weblog.ikvm.net/

An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

An Introduction to .NET for theJ2EE Programmer

Jeroen Frijters

Sumatra Software b.v.

[email protected]

http://weblog.ikvm.net/

Page 2: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Overview

.NET Framework overview and terminology

A Quick Look at C#

A detailed look at the important topicsClass Libraries

Component Model

Application Servers

Code Packaging / Deployment

Versioning

Security Model

Integration with Legacy Code

Portability

Page 3: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

.NET FrameworkOverview and Terminology

Source: Microsoft Corp.

Page 4: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

.NET FrameworkOverview and Terminology 2

.NET Framework

TLAs

CLI – Common Language Infrastructure

CLR – Common Language Runtime

CLS – Common Language Specification

CTS – Common Type System

VES – Virtual Execution System

CIL – Common Intermediate Language

Page 5: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Common Language Infrastructure

ECMA/ISO standard

CLR is the name for Microsoft’simplementation

Defines the Common Type System (CTS),the Virtual Execution System (VES) and theCommon Language Specification (CLS)

Page 6: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Common Language Runtime

Microsoft ships severallanguages

C#

VB.NET

C++ (with managedextensions)

JScript.NET

J#

ILasm

Third party languages

Eiffel by Eiffel Software

COBOL by Fujitsu

FORTRAN byLahey/Fujistu

Delphi by Borland

Perl by ActiveState

Many research/toylanguages

http://www.jasonbock.net/dotnetlanguages.html

Page 7: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Common Language Specification

CLS FrameworkA library consisting of CLS-compliant code

CLS ConsumerA language or tool that is designed to allow access to allof the features supplied by CLS-compliant frameworks,but not necessarily be able to produce them

CLS ExtenderA language or tool that is designed to allowprogrammers to both use and extend CLS-compliantframeworks

Page 8: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Common Type System

Page 9: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Virtual Execution System

An abstract runtime model (the equivalent ofthe Java Virtual Machine).

Common Intermediate Language (CIL)Not designed to be interpreted.

Has direct support for manipulating unmanageddata.

Has direct support for calling unmanaged code.

Provides Application Domains and Contextsand remoting support across both of theseboundaries.

Page 10: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Managed Code

VerifiablyType SafeManaged

Code

Page 11: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Java Byte Code

VerifiablyType SafeJava Byte

Code

Page 12: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Managed Data

Like Java, most code uses Managed Data.That is data that is managed by the runtimeeither on the stack or via the garbagecollector.

Unlike Java, trusted code can useunmanaged data (i.e. data outside of thecontrol of the runtime), this can be used forinteroperating with existing unmanaged codeor for efficiency.

Page 13: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

C#

Not just a copy of Java

Syntax very much like C++ and Java

Fixes some Java flaws (e.g. return fromfinally)

Additional Features (C# 1.1 vs Java 1.4)Custom Attributes, Value Types, Unsafe Code, Delegates, Enums, InternalAccess Modifier, Properties, Events, Conditional Compilation, OperatorOverloading, Boxing, Variable Argument Lists, Checked Integer Arithmetic

Java 5.0 adds some of the C# featuresAnnotations, Enums (but different), Boxing, Variable Argument Lists.

Page 14: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Class Libraries

Like Java, the .NET Framework has a rich setof class libraries.

The class library is a little bit more consistentthan in Java.

Major Parts

Base Framework

Data and XML

ASP.NET

Windows Forms

Page 15: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Class Libraries – Base Framework

System

Collections

Configuration

Diagnostics

Globalization

IO

Net

Reflection

• Emit

Resources

System

Security

ServiceProcess

Text

Threading

Runtime

• InteropServices

• Remoting

• Serialization

Page 16: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Class Libraries – Data and XML

System.Data

OleDb

Common

SqlClient

SqlTypes

System.Xml

Xslt

XPath

Serialization

Page 17: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Class Libaries – ASP.NET

System.Web

Services

• Description

• Discovery

• Protocols

UI

• HtmlControls

• WebControls

Caching

Configuration

System.Web

Security

SessionState

Page 18: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Class Libraries – Windows Forms

System.Windows.Forms

Design

ComponentModel

System.Drawing

Drawing2D

Imaging

Printing

Text

Page 19: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Component Model

Very nice component model, includingdesign time support infrastructure.

Demonstration!

Page 20: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Application Servers

ASP.NET

Web sites

Web services

Typically hosted by IIS, but can also be hostedinside other HTTP servers.

COM+

Windows Services

Like the JVM, you can host the CLR insideyour own application.

Page 21: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Packaging / Deployment

AssembliesExtension of the Windows executable file format(PE files).

Can contain both managed as well asunmanaged code.

GAC / NGEN

xcopy deploymentASP.NET sites can be deployed by copying adirectory. DLL files can be overwritten.

Many client applications can be xcopy deployedas well.

Page 22: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Versioning

Assemblies can have a “strong name” and aversion number.

Publisher can set versioning policy.

Domain/Local administrator can setversioning policy.

Multiple versions can be loaded side-by-side.

Demonstration!

Page 23: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Security Model

Code Access Security

Declaritive

Imperative

Link Demands

Isolated Storage

Partially trusted code can read/write filesthrough by using the standard file dialogs.

Demonstration!

Page 24: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Integration with Legacy Code

P/InvokeEfficient and relatively easy way to call existingnative code, without having to write glue code.

Demonstration!

Managed C++ / C++/CLIVery powerful way to write glue code forcomplex object models.

COM interopCOM interfaces and objects can be used by .NETcode and vice versa.

Page 25: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Java on the .NET Framework

J#

JDK 1.1.4 only

Primarily a migration path for J++ users

Third Party Tools

Come see my other talk!

Page 26: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Portability

CLRWindows x86/x64/IA64

Compact FrameworkWindows CE

Shared Source CLI a.k.a. RotorWindows x86, FreeBSD, Mac OS X

MonoWindows x86, GNU/Linux x86/PPC, Mac OS X

Portable.NETGNU/Linux x86

Page 27: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Future

Somewhere in 2005, version 2.0 of the .NETFramework 2.0 will be released.

Generics

C# language enhancements (generics, anonymousmethods, iterators)

Many class library enhancements

C++/CLI

The next version of Windows (Longhorn) will havean integrated CLR and many operating systemcomponents will be written as managed code.

Page 28: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Questions

Page 29: An Introduction to .NET for the J2EE Programmer · Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page C# Not just a copy of Java Syntax very much like C++ and

Colorado Software Summit: October 23 – 28, 2005 © Copyright 2005, Sumatra Software b.v.

Jeroen Frijters — An Introduction to .NET for the J2EE Programmer Page

Resources

http://www.sscli.net/

http://www.jasonbock.net/dotnetlanguages.html

http://www.mono-project.com/

http://www.dotgnu.org/

http://weblog.ikvm.net/

Microsoft has tons of interesting weblogs:http://blogs.msdn.com/