Jazyk C - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

Jazyk C

Description:

NPRG 035 (2/1 Zk/Z) Jazyk C# a platforma .NET (zima) Predn ka ... Object Pascal (in latest Borland Dephi) PHP (project Phalanger - www.php-compiler.net) ... – PowerPoint PPT presentation

Number of Views:80
Avg rating:3.0/5.0
Slides: 30
Provided by: SON147
Category:
Tags: borland | jazyk

less

Transcript and Presenter's Notes

Title: Jazyk C


1
Jazyk C a platforma .NET
  • Pavel Jeek

2
Struktura predmetu
  • NPRG 035 (2/1 Zk/Z) Jazyk C a platforma .NET
    (zima)
  • Prednáka
  • Cvicení (SW2 - jednou za 14 dní) treba se
    prihlásit v SISu
  • Po 1040 Pavel Jeek
  • Út 1220 Pavel Jeek
  • Ct 1040 Ondrej erý
  • Pá 900 Tomá Poch
  • POZOR Prihlaování skrz UNIX
  • NPRG 038 (0/2 Z) Pokrocilé programování pro
    .NET (léto)
  • Prednáka

3
Poadavky na zápocet/zkouku
  • NPRG 035 (2/1 Zk/Z) Jazyk C a platforma .NET
    (zima)
  • Zkouka (asi písemne)
  • Splnené povinnosti ze cvicení
  • Zápoctový program (kontrolují cvicící) (lze
    uznat)
  • Praktický zápoctový test v pocítacové laboratori
    (lze uznat)
  • Naprogramovat a odladit jeden jednoduchý príklad
  • Casový limit 3 hodiny
  • Maximálne 3 pokusy
  • Dostatek termínu v zimním zkoukovém období
    pribline 2 v letním
  • NPRG 038 (0/2 Z) Pokrocilé programování pro
    .NET (léto)
  • Zápoctový program (kontrolují cvicící z NPRG 035
    pokud máte zápocet z NPRG 035 z minulého roku,
    tak kontroluje PJ)

Zápocet
4
Povinnosti ze cvicení
  • Docházka (max. 2 absence)
  • Pri vyí absenci navíc jeden teký domácí úkol
  • Domácí úkoly (v CodExu)
  • 3-4 povinné
  • 1-2 náhradní

5
Zápoctový program
  • Termíny NPRG 035 (zima) i NPRG 038
  • Specifikace 22. 5. 2009 (konec LS)
  • Predvedení finální plne funkcní verze 3. 7. 2009
    (vcetne uivatelské a programátorské dokumentace)
  • Poadavky na program z NPRG 035
  • Predvedeno v termínu minimálne 30 kB zdrojového
    kódu v jazyce C
  • Predvedeno po termínu minimálne 60 kB zdrojového
    kódu v jazyce C
  • Poadavky na program z NPRG 038
  • Predvedeno v termínu minimálne 60 kB zdrojového
    kódu v jazyce C
  • Predvedeno po termínu minimálne 120 kB
    zdrojového kódu v jazyce C
  • Netriviální pouití nekteré z technologií
    probíraných v NPRG 038 (ADO.NET, .NET Remoting,
    XML, Web Services, Reflection, LINQ, C/CLI,
    .NET Security)
  • Poznámka Kadý zápoctový program, který splnuje
    poadavky NPRG 038, splnuje i poadavky NPRG 035
    (tj. lze odevzdat jeden program za oba predmety)

Nevygenerovaný (rucne psaný) rozumný kód
6
What is the output the following program?
  • class Program
  • static void Main(string args)
  • int j 0
  • for (int i int.MaxValue - 10 i lt
    int.MaxValue i)
  • j
  • Console.WriteLine(j)
  • A 10
  • B 11
  • C 0
  • D nothing
  • E it will generate a runtime error

7
What is the output the following program?
  • class Program
  • static void Main(string args)
  • int j 0
  • for (int i int.MaxValue - 10 i lt
    int.MaxValue i)
  • j
  • Console.WriteLine(j)
  • A 10
  • B 11
  • C 0
  • D nothing an infinite cycle
  • E it will generate a runtime error

8
What is the output the following program?
  • class Program
  • static void Main(string args)
  • int START 2000000000
  • int count 0
  • for (float f START f lt START 50 f)
  • count
  • Console.WriteLine(count)
  • A 0
  • B 50
  • C 49
  • D nothing
  • E something else

9
What is the output the following program?
  • class Program
  • static void Main(string args)
  • int START 2000000000
  • int count 0
  • for (float f START f lt START 50 f)
  • count
  • Console.WriteLine(count)
  • A 0
  • B 50
  • C 49
  • D nothing
  • E something else

10
Basic Structure of .NET Framework
  • Common Language Infrastructure (CLI)
  • Common Language Runtime (CLR)
  • Base Class Library (BCL)
  • .NET Framework
  • Current version 2.0
  • Microsofts CLI implementation
  • Additional libraries
  • ASP.NET
  • ADO.NET
  • Windows Forms
  • Web Services
  • others
  • Compilers for several .NET languages

11
Languages for .NET
  • Languages (compilers developed by Microsoft)
  • C 3.0
  • Visual Basic .NET
  • JScript (ECMAScript)
  • C with Managed Extensions
  • J (Java)
  • Other languages
  • Object Pascal (in latest Borland Dephi)
  • PHP (project Phalanger - www.php-compiler.net)
  • Eiffel
  • Haskell
  • others

12
Languages for .NET
  • C
  • New language similar to Java adds a lot of
    features
  • Classes allocated on heap
  • Structures can be allocated on stack
  • Delegates safe multipointers to methods
  • Unsafe pointers
  • Properties
  • Operator overloading
  • Generics
  • Attributes metaclasses associated with classes,
    methods, assemblies
  • Documentation comments based on XML

13
Languages for .NET, cont.
  • Visual Basic .NET
  • Not compatible with older versions (6.0)
  • Import Wizard
  • Transforms VB 6.0 source code in to VB.NET source
    code
  • Not all VB 6.0 features are supported by CLR or
    present in BCL
  • Some are emulated by Microsoft.VisualBasic
    assembly
  • Some cannot be transformed
  • Syntax clean up
  • New form object model now using Windows Forms
  • C/CLI
  • Very strong support for direct combination of
    managed and unmanaged (native) code
  • To be standardized by ECMA and ISO

14
Languages for .NET, cont.
  • J
  • New in Visual Studio .NET 2003
  • Managed implementation of the Java language
  • Compiles only to MSIL (does NOT support Java
    bytecode generation)
  • Provides functionality as of JDK 1.1.4
  • Supports J extensions WFC, com.ms.com,
    com.ms.dll, com.ms.win32
  • Conversion tool from Java bytecode to MSIL

15
.NET Framework - Assembly Creation
Metadata
Source code (Visual Basic,C or Pascal)
Compiler
Metadata
Zdrojový kód (Visual Basic,C nebo Pascal)
MSIL Code (MicrosoftIntermediateLanguage)
Kód MSIL (MicrosoftIntermediateLanguage)
Resources(images, localized strings, etc.)
Assembly (EXE or DLL)
Assembly metadata (references toother
assemblies, etc.)
16
.NET Framework - Assembly Launching
Assembly (EXE or DLL) MSIL
JIT compiler
Native code (x86)
Required assemblies (DLL)
Assembly (DLL)
17
Mono Project
  • www.mono-project.com
  • Open source implementation of .NET (according to
    ECMA standards)
  • Platform support Linux, Solaris, MacOS X,
    Windows
  • Contains
  • Compilers for C (some features of C 2.0),
    MonoBasic (extension of Visual Basic .NET)
  • Common Language Runtime with JIT compiler
  • BCL implementation
  • ADO.NET
  • Implementation of ASP.NET, Web Services for
    Apache web server
  • GUI library GTK (based on GTK)
  • Windows Forms
  • Integrated development environment
  • Help browser

18
What is not .NET? GDI
  • GDI
  • Object oriented library for C programmers
  • Wraps existing GDI API functions into classes
  • Adds new functionality, e.g
  • Gradient brushes
  • Matrix transformations
  • Alpha blending
  • Support for additional graphics formats BMP,
    GIF, JPEG, PNG, TIFF, ICO, WMF, EMF
  • Included in Windows XP and Windows 2003 Server
    (available as redistributable for Windows 98, Me,
    NT, 2000)

19
What is not .NET? Side-by-Side Assem.
  • Side-by-side assemblies
  • The DLL Hell solution in Windows XP a Windows
    2003 Server (not available for older Windows
    versions
  • Several versions of a same component assembly
    (usually a DLL library) can be installed at the
    same time on one computer
  • Assembly is a bunch of files indentified by a
    common name and digital signature (e.g.
    Microsoft.Windows.Common-Controls) and with
    associated version number
  • Every assembly is described by its manifest (an
    XML file)
  • Each assembly version (installed by Windows
    Installer) has its own subfolder in the system
    SystemRoot\WinSxS folder (e.g.
    x86_Microsoft.Windows.Common-Controls_6595b64144cc
    f1df_6.0.0.0_x-ww_1382d70a)
  • Any applications starts
  • Windows looks for application manifest
    describes required versions of used assemblies
    (in application.exe.manifest file or in
    RT_MANIFEST resource embedded inside executable)
  • Administrators can define assembly version
    mapping

20
Example Application Manifest
  • lt?xml version"1.0" encoding"UTF-8"
    standalone"yes"?gt
  • ltassembly xmlns"urnschemas-microsoft-comasm.v1"
    manifestVersion"1.0"gt
  • ltassemblyIdentity
  • version"1.0.0.0"
  • processorArchitecture"X86"
  • nameFirstApplication.exe"
  • type"win32"
  • /gt
  • ltdescriptiongtApplication manifestlt/descriptiongt
  • ltdependencygt
  • ltdependentAssemblygt
  • ltassemblyIdentity
  • type"win32"
  • name"Microsoft.Windows.Common-Controls"
  • version"6.0.0.0"
  • processorArchitecture"X86"
  • publicKeyToken"6595b64144ccf1df"
  • language""
  • /gt

21
Application Manifest - Results
Without application manifest (using old
version of common controls)
With application manifest (using version 6.0.0.0
of common controls)
22
What is not .NET? Aero Glass Effect
23
Aero Minimazing/Maximazing Windows
24
Aero Windows Tab
25
Desktop Window Manager (Aero)
  • New WDDM (Windows Display Driver Model) allows
    sharing of DirectX surfaces.
  • Standard Windows Vista graphics and UI stack

.NET 2.0 Application
.NET 3.0 Application
Windows Forms
System.Drawing DLL
Managed DirectX
Windows Presentation Foundation (XAML/Avalon)
Managed Code
Native Code
Win32 Application
User32
GDI
Media Integration Layer
Win32 Game
GDI
DirectX
WDDM
Graphics Driver
26
DWM Glass Effect in Client Area
27
Uniform Type System
Types
Value Types
Reference Types
Pointers
Simple Types
Enums
Structs
Classes
Interfaces
Arrays
Delegates
bool char
sbyte short int long
byte ushort uint ulong
float double decimal
User-defined Types
blue types are missing from Java
All types are compatible with object
(System.Object) - can be assigned to variables of
type object - all operations of type object are
applicable to them
28
Primitive Types
  • long name in Java range
  • sbyte System.SByte byte -128 .. 127
  • byte System.Byte --- 0 .. 255
  • short System.Int16 short -32768 .. 32767
  • ushort System.UInt16 --- 0 .. 65535
  • int System.Int32 int -231 .. 231-1
  • uint System.UInt32 --- 0 .. 232 -1
  • long System.Int64 long -263 .. 263-1
  • ulong System.UInt64 --- 0 .. 264-1
  • float System.Single float ?1.5E-45 .. ?3.4E38 (32
    Bit)
  • double System.Double double ?5E-324 .. ?1.7E308
    (64 Bit)
  • decimal System.Decimal --- ?1E-28 .. ?7.9E28 (128
    Bit)
  • bool System.Boolean boolean true, false
  • char System.Char char Unicode character

29
Differences Between Classes and Structs
Structs Value types (objects are allocated on
the stack) no inheritance (but they are
compatible with object) can implement
interfaces must not declare a parameterless
constructor no destructors
  • Classes
  • Reference types
  • (objects are allocated on the heap)
  • support inheritance
  • (all classes are derived from object)
  • can implement interfaces
  • may declare a parameterless constructor
  • may have a destructor
Write a Comment
User Comments (0)
About PowerShow.com