Upload
khairitkr
View
224
Download
0
Embed Size (px)
Citation preview
7/29/2019 using .net basic language
1/24
Module3:Using Microsoft .NET-
Based Languages
7/29/2019 using .net basic language
2/24
Module 3:
Using MS .NET-Based LanguagesIntroduces the different languages that areavailable for use when developing .NET-based
web applicationsLater, youll be able to identify the languagesthat support the .NET Framework and be able tochoose an appropriate development languagefor your needs
VB.NET @ C#
7/29/2019 using .net basic language
3/24
OverviewOverview of the .NET-Based Languages
Comparison of the .NET-Based Languages
7/29/2019 using .net basic language
4/24
Lesson: Overview of the .NET-
Based LanguagesMultiple Language Support
The Common Language RuntimeThe Common Language Runtime Components
Runtime Compilation and Execution
7/29/2019 using .net basic language
5/24
Multiple Language SupportThe .NET Framework is designed to support manylanguages
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 languagesThe right language is used for the right task
Performance is roughly equal between all languages
7/29/2019 using .net basic language
6/24
VB.NET
MS Jscript.NET
Perl
Haskell
Mercury
SmallTalk
APLC#
Oberon
Python
Pascal
Eiffel
CAML
C
MS J#.NET
Scheme
COBOLML
ADA
MV C++
7/29/2019 using .net basic language
7/24
MS .NET-Based Language.NET Framework is designed to support an
unlimited number of development languages
It allows developers to use their preferredlanguage when developing .NET applications
7/29/2019 using .net basic language
8/24
The Common Language RuntimeOne runtime for all . NET-Based Languages
Manages threads and memory
When objects are no longer used by a .NET application, theruntime perform garbage collection, which frees up thememory that was used by those objects
Enforces code security
Eliminates (dynamic-link library) DLL versioningproblemsMultiple versions of a DLL can run simultaneously
Applications can specify a version of a DLL to use
7/29/2019 using .net basic language
9/24
The Common LanguageRuntimeComponents
.NET Framework Class Library Support
Thread Support COM Marshaler
Type Checker Exception Manager
MSIL to NativeCompilers
CodeManager
GarbageCollector
Security Engine Debug Engine
Class Loader
7/29/2019 using .net basic language
10/24
Component Description
Class
Loader
Manages metadata, in addition to the loading and layout of
classes
MSIL to
native
compiler
Converts MSIL to native code (just-in-time [JIT]
compilation)
Code
manager
Manage code execution
Garbage
collector
Provide automatic lifetime management of all of your
objects. This is a multiprocessor, scalable garbage
collector
Security
engine
Provides evidence-based security that is based on the
origin of the code and the user
Debug
engine
Allows you to debug your application and trace the
execution of code
7/29/2019 using .net basic language
11/24
When an object is no longer used by an
application, the GC cleans up the memory
GC prevents memory leaks caused byapplication that do not release all resources
7/29/2019 using .net basic language
12/24
Component Description
Type
checker
Will not allow unsafe casts or uninitialized variables. MSIL
can be verified to guarantee type safety
Exception
manager
Provides structured exception handling, which is
integrated with MS Win structured exception handling
(SEH)
Thread
support
Provides classes and interfaces that enable multithreaded
programming
COM
marshaler
Provides marshaling to and from COM
.NET
Framework
Class
Library
support
Integrates code with the runtime that supports the .NET
Framework Class Library
7/29/2019 using .net basic language
13/24
Runtime, Compilation and Execution
Native
code
C# code Visual Basic .NET code
Which language?
Visual Basic .NET
compiler
C#
compiler
MSILJITcompiler
default.aspx
Runtime
7/29/2019 using .net basic language
14/24
Runtime, Compilation and ExecutionLanguage 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
7/29/2019 using .net basic language
15/24
Runtime, Compilation and ExecutionJIT Compilation
The MSIL is handled by the runtime.
The runtime uses a JIT compiler to compile the MSILto native code.
After the application is JIT compiled, it is cached so
that it does not need to be recompiled for eachrequest.
7/29/2019 using .net basic language
16/24
Runtime, Compilation and ExecutionApplication Execution
After the application is compiled , the runtime
executes the application on the Web server and thengenerates the HTML and script that is returned to the
client.
7/29/2019 using .net basic language
17/24
Lesson: Comparison of the .NET-
Based LanguagesVisual Basic .NET
C#
Choosing a Language
7/29/2019 using .net basic language
18/24
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 AsSystem.EventArgs) Handles Button1.Click
Dim i As Integer = 0
Dim x As Double = TextBox1.Text
For i = 0 To 4
x *= 2
Label1.Text = Label1.Text & x & ","
NextEnd Sub
7/29/2019 using .net basic language
19/24
C#C# is a new language
Similar to Java, Visual C++, and Pascalprotected void Button1_Click(object sender, EventArgs e){
int i = 0;double x = Convert.ToDouble(TextBox1.Text);for (i=0; i
7/29/2019 using .net basic language
20/24
Choosing a Language
VB.NET @ C#
7/29/2019 using .net basic language
21/24
Choosing a Language.NET Framework class library is the same regardless oflanguagePerformance
All languages are compiled to MSIL
Only performance difference is how each language
compiler compiles to MSILThe runtime compiles all MSIL the same, regardless of itsorigin
Development experienceC# is similar to Java, C, Visual C++, and PascalVisual Basic .NET is similar to Visual Basic
Browser compatibility
ASP.NET code is server-side code, so browser
compatibility is not an issue
7/29/2019 using .net basic language
22/24
ReviewOverview of the .NET-Based Languages
Comparison of the .NET-Based Languages
7/29/2019 using .net basic language
23/24
ExerciseWhat 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?
7/29/2019 using .net basic language
24/24
~ End of Module 3 ~