module 3: using microsoft .net- based languages

17
Module 3: Using Microsoft .NET- Based Languages

Upload: pisces

Post on 15-Jan-2016

37 views

Category:

Documents


0 download

DESCRIPTION

Module 3: Using Microsoft .NET- Based Languages. Overview. Overview of the .NET-Based Languages Comparison of the .NET-Based Languages. Lesson: Overview of the .NET-Based Languages. Multiple Language Support The Common Language Runtime The Common Language Runtime Components - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Module 3: Using Microsoft .NET- Based Languages

Module 3:Using Microsoft .NET-

Based Languages

Page 2: Module 3: Using Microsoft .NET- Based Languages

Overview

Overview of the .NET-Based Languages Comparison of the .NET-Based

Languages

Page 3: Module 3: Using Microsoft .NET- Based Languages

Lesson: Overview of the .NET-Based Languages

Multiple Language Support The Common Language Runtime The Common Language Runtime

Components Runtime Compilation and Execution

Page 4: Module 3: Using Microsoft .NET- Based Languages

Multiple Language Support The .NET Framework is designed to support

many languages• More than 20 languages currently supported

• Microsoft provides Visual Basic .NET, C#, Visual J# .NET, and JScript .NET

Benefits of multiple-language support• Code modules are reusable• API access is the same for all languages• The right language is used for the right task• Performance is roughly equal between all

languages

Page 5: Module 3: Using Microsoft .NET- Based Languages

The Common Language Runtime

One runtime for all . NET-Based Languages Manages threads and memory

- Garbage collection Enforces code security

- No uninitialized variables

- Exception Handling Eliminates DLL versioning problems

- Multiple versions of a DLL can run simultaneously

- Applications can specify a version of a DLL to use

Page 6: Module 3: Using Microsoft .NET- Based Languages

The Common Language Runtime Components

.NET Framework Class Library Support.NET Framework Class Library Support

Thread SupportThread Support COM MarshalerCOM Marshaler

Type CheckerType Checker Exception ManagerException Manager

MSIL to NativeMSIL to NativeCompilersCompilers

CodeCodeManagerManager

GarbageGarbageCollectorCollector

Security EngineSecurity Engine Debug EngineDebug Engine

Class LoaderClass Loader

Page 7: Module 3: Using Microsoft .NET- Based Languages

Runtime, Compilation and Execution

Nativecode

C# code Visual Basic .NET code

Which language?

Visual Basic .NETcompiler

C#compiler

MSILJITcompiler

default.aspx

Runtime

HTM

L

Page 8: Module 3: Using Microsoft .NET- Based Languages

Runtime, Compilation and Execution

Language Compilation- A web browser request a Web page from a Web server that is running IIS. - The requested Web page, default.aspx, is compiled with the appropriate language compiler, depending on the language that is used to write the page. - The application is compiled to MSIL

Page 9: Module 3: Using Microsoft .NET- Based Languages

Runtime, Compilation and Execution

JIT Compilation

- The MSIL is handled by the runtime.

- The runtime uses a JIT compiler to compile the MSIL to native code.

- After the application is JIT compiled, it is cached so that it does not need to be recompiled for each request.

Page 10: Module 3: Using Microsoft .NET- Based Languages

Runtime, Compilation and Execution

Application Execution

- After the application is compiled , the runtime executes the application on the Web server and then generates the HTML and script that is returned to the client.

Page 11: Module 3: Using Microsoft .NET- Based Languages

Lesson: Comparison of the .NET-Based Languages

Visual Basic .NET C# Choosing a Language

Page 12: Module 3: Using Microsoft .NET- Based Languages

Visual Basic .NET

Visual Basic .NET is the latest version of Visual Basic True object-oriented language

Visual Basic Scripting Edition (and JScript) are still used for client-side script

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i As Integer = 0Dim x As Double = TextBox1.TextFor i = 0 To 4 x *= 2 Label1.Text = Label1.Text & x & ","Next

End Sub

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i As Integer = 0Dim x As Double = TextBox1.TextFor i = 0 To 4 x *= 2 Label1.Text = Label1.Text & x & ","Next

End Sub

Page 13: Module 3: Using Microsoft .NET- Based Languages

C#

C# is a new language Similar to Java, Visual C++, and

Pascal

protected void Button1_Click(object sender, EventArgs e){ int i = 0; double x = Convert.ToDouble(TextBox1.Text); for (i=0; i<=4; i++) { x *= 2; Label1.Text = Label1.Text + x + ","; }}

protected void Button1_Click(object sender, EventArgs e){ int i = 0; double x = Convert.ToDouble(TextBox1.Text); for (i=0; i<=4; i++) { x *= 2; Label1.Text = Label1.Text + x + ","; }}

Page 14: Module 3: Using Microsoft .NET- Based Languages

Choosing a Language .NET Framework class library is the same regardless of

language Performance

• All languages are compiled to MSIL

• Only performance difference is how each language compiler compiles to MSIL

• The runtime compiles all MSIL the same, regardless of its origin

Development experience• C# is similar to Java, C, Visual C++, and Pascal• Visual Basic .NET is similar to Visual Basic

Browser compatibility

• ASP.NET code is server-side code, so browser compatibility is not an issue

Page 15: Module 3: Using Microsoft .NET- Based Languages

Review

Overview of the .NET-Based Languages Comparison of the .NET-Based

Languages

Page 16: Module 3: Using Microsoft .NET- Based Languages

Exercise

What role does the CLR play in running ASP.NET page?

What is the role of JIT compilation? List FOUR languages that are currently

supported by .NET. What is garbage collection and why is it

so useful in the .NET Framework?

Page 17: Module 3: Using Microsoft .NET- Based Languages

~ End of Module 3 ~