48

Click here to load reader

Introduction to .net framework

Embed Size (px)

DESCRIPTION

A simple document emphasizing the reasons behind evolution of .Net technology and how it simplified the yester-decade's technology issues. This document is simplified and teaches a lame man as why & how .net framework gained importance and how it is ruling the roost.

Citation preview

Page 1: Introduction to .net framework

Introduction to .Net Framework

Nithya Vidhyaarthi

Page 2: Introduction to .net framework

Before .NETWindows GUI development: Win32 API, MFC,

Visual Basic, COMWeb development: ASPJava – “Write once, run anywhere.”Embrace and extend: Visual J++

Page 3: Introduction to .net framework

Life As a C/Win32 API ProgrammerTraditional software development for the

Windows.C developers are forced to contend with complex

memory management and pointer arithmetic. It lacks the benefits provided by the object-oriented

approach

When you combine the thousands of global functions and data types defined by the Win32 API to an already formidable language, it is little wonder that there are so many buggy applications floating around today.

Page 4: Introduction to .net framework

Life As a C++/MFC ProgrammerC++ is an object-oriented layer on top of C.

Programmers benefit from the famed “pillars of OOP” (encapsulation, inheritance, and polymorphism).

Microsoft Foundation Classes (MFC) provides a set of C++ classes that facilitate the construction of Win32 applications. It wraps a “sane subset” of the raw Win32 API behind a number of

classes, magic macros, and numerous code-generation tools (wizards).

Regardless of the helpful MFC, programming for Windows using C++ remains a difficult and error-prone experience

Page 5: Introduction to .net framework

Visual Basic 6.0 ProgrammerAbility to build complex user interfaces, code

libraries, and data access logic with minimal fuss and bother. VB6 hides the complexities of the raw Win32 API

from view using integrated code wizards, intrinsic data types, classes, and VB-specific functions.

Not fully object-orientedNo “is-a” relationships between types (i.e., no

classical inheritance)No multithreaded applications unless you are

willing to drop down to low-level Win32 API calls (which is complex at best and dangerous at worst).

Page 6: Introduction to .net framework

Life As a Java/J2EE ProgrammerObject oriented with syntactic roots in C++.

Java cleans up many unsavory syntactical aspects of C++.

Java provides programmers with a large number of predefined “packages” that contain various type definitions.

Limited ability to access non-Java APIs.Little support for true cross-language integration.

Not appropriate for many graphically or numerically intensive applications.

A better approach for such programs would be to use a language such as C++ where appropriate.

Page 7: Introduction to .net framework

Life As a COM ProgrammerMicrosoft’s previous application development

framework.reusable binary code.C++ programmers can build COM classes that

can be used by VB6. Delphi programmers can use COM classes built using C.

COM’s language independence is limited. COM has no support for classical inheritance).

COM is extremely complex under the hood.The Active Template Library (ATL) provides a

set of C++ classes, templates, and macros to ease the creation of COM types.

Page 8: Introduction to .net framework

Windows DNA ProgrammerMicrosoft has been adding more Internet-

aware features into its family of operating systems and products. COM-based Windows Distributed interNet

Applications Architecture (DNA) is quite complex.

Due to the simple fact that Windows DNA requires the use of numerous technologies and languages (ASP, HTML, XML, JavaScript, VBScript, COM(+), and data access API like ADO).

Page 9: Introduction to .net framework

The complete maze…Completely unrelated syntaxes. JavaScript has a syntax much like C, while

VBScript is a subset of VB6. The result is a highly confused mishmash of technologies.

Each language and/or technology has its own type system:

An “int” in JavaScript is not quite the same as an “Integer” in VB6.

Page 10: Introduction to .net framework

.Net, the Rescuer

.NET

OOP JVM

GUIWeb

component-based design n-tier design

Page 11: Introduction to .net framework

.Net, the Rescuer

Page 12: Introduction to .net framework

.Net providesIntegrated environment

Internet, Desktop , Mobile devices

consistent object-oriented

To provide a portable environment

A managed environment

Page 13: Introduction to .net framework

What Is .NET.NET is a framework

New programming methodology

.NET is platform independent / cross

platform

.NET is language-insensitive

Page 14: Introduction to .net framework

.NET is cross-platform

APP.exe

?Win64 Win32

(XP,2K,98)

WinCE

Page 15: Introduction to .net framework

Narrow view of .Net applications

Operating System + Hardware

.NET Framework

.NET Application

Page 16: Introduction to .net framework

.Net Framework

Page 17: Introduction to .net framework

.Net Architecture.NET architecture is:

multi-languagecross-platformbased on the CLR, FCL, and JIT

technology.NET components are packaged as

assemblies

Page 18: Introduction to .net framework

.Net Architecture

Page 19: Introduction to .net framework

.Net Technical Architecture

Base Class Library

Common Language Specification

Common Language Runtime

ADO.NET: Data and XML

VB C++ C#

Visu

al Stu

dio

.NE

TASP.NET: Web Servicesand Web Forms

JScript …

WindowsForms

WindowsForms

Page 20: Introduction to .net framework

Common Language RuntimeA common runtime for all .NET languages

Common type systemCommon metadata Intermediate Language (IL) to native code compilersMemory allocation and garbage collectionCode execution and security

Over 15 languages supported todayC#, VB, Jscript, Visual C++ from MicrosoftPerl, Python, Smalltalk, Cobol, Haskell, Mercury, Eiffel,

Oberon, Oz, Pascal, APL, CAML, Scheme, etc.Rational is working on Java compiler for CLR

Page 21: Introduction to .net framework

The CLR Architecture

Class Loader

MSIL to NativeCompilers (JIT)

CodeManager

GarbageCollector (GC)

Security Engine Debug Engine

Type Checker Exception Manager

Thread Support COM Marshaler

Base Class Library Support

Page 22: Introduction to .net framework

CLR Execution Model (Narrow)Code in VB.NET Code in C#

Code in another .NET Language

VB.NET compiler C# compilerAppropriate

Compiler

IL(IntermediateLanguage) code

CLR just-in-timeexecution

Page 23: Introduction to .net framework

CLR Execution ModelVBSource

codeCompiler

C++C#

CompilerCompiler

AssemblyIL Code

AssemblyIL Code

AssemblyIL Code

Operating System Services

Common Language Runtime

JIT Compiler

Native Code

Managedcode

UnmanagedComponent

Page 24: Introduction to .net framework

How CLR works?

Page 25: Introduction to .net framework

CLR based executionAPP.exe

other FCL components

CLR

JIT Compiler

obj code

OS Process

Underlying OS and HW

Core FCL

Page 26: Introduction to .net framework

Common Language RuntimeExecution Engine

Compiles Microsoft Intermediate Language (MSIL) into native code

Handles garbage collectionHandles exceptionsEnforces code access securityHandles verification

Managed v. Unmanaged

Page 27: Introduction to .net framework

Implications of CLR execution model1. Clients need CLR & FCL to run .NET apps

available via Redistributable .NET Framework

2. Design trade-off…+ managed execution (memory

protection, verifiable code, etc.)+ portability:– slower execution?

Page 28: Introduction to .net framework

CLR and JIT compiling.Indirect execution of .Net applications.All .NET languages compile to the same CIL.The CLR transforms the CIL to assembly

instructions for a particular hardware architecture.This is termed jit’ing or Just-in-time compiling.Some initial performance cost, but the jitted

code is cached for further execution.The CLR can target the specific architecture in

which the code is executing, so some performance gains are possible.

Page 29: Introduction to .net framework

Advantages of CLRSupport for developer services (debugging)

Interoperation between managed code and

unmanaged code (COM, DLLs).

Managed code environment

Improved memory handling

Improved “garbage collection”

Page 30: Introduction to .net framework

Advantages of CLRJIT allows code to run in a protected environment as

managed code.

JIT allows the IL code to be hardware independent.

CLR also allows for enforcement of code access security.

Verification of type safety.

Access to Metadata (enhanced Type Information)

Page 31: Introduction to .net framework

Common Language Infrastructure

Page 32: Introduction to .net framework

CLI

Page 33: Introduction to .net framework

Common Language InfrastructureCLI allows for cross-language development.

Four components:

Common Type System (CTS)

Meta-data in a language agnostic fashion.

Common Language Specification – behaviors

that all languages need to follow.

A Virtual Execution System (VES).

Page 34: Introduction to .net framework

Common Type System (CTS)A specification for how types are

defined and how they behave.no syntax specified

A type can contain zero or more members:FieldMethodPropertyEvent

Page 35: Introduction to .net framework

Common Type System (CTS)

St r i ng Ar r ay Val ueType Except i on Del egat e Cl ass1

Mul t i castDel egat e

Cl ass2

Cl ass3

Obj ect

Enum1

St r uct ur e1EnumPr i mi t i ve t ypes

Bool ean

Byt e

I nt 16

I nt 32

I nt 64

Char

Si ngl e

Doubl e

Deci mal

Dat eTi me

System-defined types

User-defined types

Del egat e1

Ti meSpan

Gui d

Page 36: Introduction to .net framework

CTS Data Types

Page 37: Introduction to .net framework

Common Data TypesCLR provides a set of primitive types that all

languages must support. The data types include:

Integer—three types 16/32/64 bitsFloat—two types: 32/64 bitsBoolean and CharacterDate/time and Time span

The primitive types can be collected intoArraysStructuresCombination of the two

Page 38: Introduction to .net framework

Common Language Specification (CLS)Not all languages support all CTS types

and featuresC# is case sensitive, VB.NET is notC# supports pointer types (in unsafe mode),

VB.NET does notC# supports operator overloading, VB.NET

does not

CLS was drafted to promote language interoperabilityvast majority of classes within FCL are CLS-

compliant

Page 39: Introduction to .net framework

Comparison to Java

Hello.java Hello.class JVMcompile execute

Hello.vb Hello.exe CLRcompile execute

Source code Byte code

CILSource code

Page 40: Introduction to .net framework

Base Class Library @ FCL

Unified Classes

Web Classes (ASP.NET)

XML Classes

System Classes

Drawing Classes

Windows FormsData (ADO.NET)

Controls, Caching, Security, Session, Configuration etc

Collections, Diagnostics, Globalization, IO, Security,Threading Serialization, Reflection, Messaging etc

ADO, SQL,Types etc

Drawing, Imaging, Text, etc

Design, Cmpnt Model etc

XSLT, Path, Serialization etc

Page 41: Introduction to .net framework

Base Class LibrarySimilar to Java’s System namespace.

Used by all .NET applications

Has classes for IO, threading, database, text,

graphics, console, sockets/web/mail, security,

cryptography, COM, run-time type

discovery/invocation, assembly generation

Page 42: Introduction to .net framework

Framework Class Library @ BCLSingle consistent set of object oriented class

libraries to enable building distributed web applications (Unified Classes)

Built using classes arranged across logical hierarchical namespaces

Work with all CLR languagesNo more “VBRun” or “MFC” divide

Page 43: Introduction to .net framework

Example

Page 44: Introduction to .net framework

Intermediate Language (IL).NET languages are not compiled to machine code.

They are compiled to an Intermediate Language (IL).

CLR accepts the IL code and recompiles it to machine code. The recompilation is just-in-time (JIT) meaning it is done as soon as a function or subroutine is called.

The JIT code stays in memory for subsequent calls. In cases where there is not enough memory it is discarded thus making JIT process interpretive.

Page 45: Introduction to .net framework

Queries?

Page 46: Introduction to .net framework

Contact me viaMail:

[email protected]@gmail.com

Social network(s) / Services:arunprasadvidhyaarthi – skype, slideshare.comArun85prasad – twitter, gmail, live, yahoo.com Arun Prasad - facebook, orkutArunprasad – scribd.com

Mobile:

+91 93446 20159

Page 47: Introduction to .net framework

Thank you !!!

Page 48: Introduction to .net framework

Disclaimer

The names of Technologies, Product(s),

Companies, Application(s), Tool(s), Utilities,

etc provided with this material are intended

to reference only. The name(s), brand

name(s), trademark(s), registered

trademark(s), logo(s), slogan(s) belong to

their respective owners in the respective

countries.