Introduction to C - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

Introduction to C

Description:

... current products without passing Sun's compatibility tests beyond bug fixes ... interoperability: C# have better backward compatibility with C or C code ... – PowerPoint PPT presentation

Number of Views:67
Avg rating:3.0/5.0
Slides: 28
Provided by: muX
Category:

less

Transcript and Presenter's Notes

Title: Introduction to C


1
Introduction to C
  • What is C
  • C Programming
  • Comparison among C, C and Java

2
Why C
  • Competitive threats need shorter cycle time and
    incremental version for a program.
  • Embrace emerging web programming standards, like
    HTML, XML and SOAP.
  • Combination of the power of C and VBs high
    productivity and ease of use

3
Why C
  • C Microsoft answer to Java
  • The lawsuit (settled in late 2001)
  • Microsoft was forced to drop Java license for
    future development
  • Microsoft retains its right to distribute its
    current products for seven years
  • Microsoft cannot update their current products
    without passing Suns compatibility tests beyond
    bug fixes

4
C Features
  • As a .NET programming language
  • -.NET, designed by Microsoft, is a new framework
    to accomplish many programming tasks.
  • -.NET is a set of Microsoft software technologies
    for connecting information, people, systems and
    devices. It enables an unprecedented level of
    software integration through the use of XML web
    services.

5
Basic Elements of .NET
  • Microsoft .NET platform provides a suite of
    developer tools, client applications, XML web
    services, and servers necessary to participate in
    the connected world

6
C Features (cond)
  • As an Object Oriented Language
  • -C is not language interoperable, you need
    access to the header files from the original
    source code in order to be able to inherit
    classes.
  • -C provides real cross-language code reuse using
    true object-oriented principles, your classes can
    be inherited from and used by other .NET-aware
    code without requiring access to your source
    files.

7
C Features (Cond)
  • As an Intermediate Level Programming Language
  • -Level of language available to Windows
    developer
  •   Lowest Assembly Language        
    C, C             C, J        
            VB Highest         VBA,
    scripting languages
  • Note Higher level, easier to learn and quicker
    to develop, but less efficient code.

8
C Features (Cond)
  • As an Intermediate Level Programming Language
  • -fill a perceived gap between VB and C.
  • -C has a syntax that is very similar to C, and
    supports many C language features.
  • -C mostly takes the VB path on memory management
    - the language itself takes responsibility for
    handling it.

9
A Simple C Program
  • // Namespace Declarationusing System//
    Program start classclass WelcomeCSS    //
    Main begins program execution.    public static
    void Main()            // Write to
    console        Console.WriteLine("Welcome to the
    C Station Tutorial!")    

10
Four Primary Elements in C Program
  • I A Namespace Declaration
  • -Namespaces contain groups of code that can be
    called upon by C programs.  With the "using
    System" declaration, you are telling your
    program that it can reference the code in the
    "System" namespace without pre-pending the word
    "System" to every reference.

11
Four Primary Elements in C Program (Cond)
  • II A Class Declaration
  • -Contains the data and method definitions that
    your program uses to execute.
  • -This particular class "class WelcomeCSS" has no
    data, but it does have one method.  This method
    defines the behavior of this class
  • III. Main Method
  • -Reserved for the starting point of a program.

12
Four Primary Elements in C Program (Cond)
  • IV A Program Statement
  • -"Console" is a class in the "System" namespace.
  • -"WriteLine(...)" is a method in the "Console"
    class.
  • -We could also write this statement as
    "System.Console.WriteLine(...)".
  • The program can be compiled with the following
    command line csc Welcome.cs. This produces a
    file named Welcome.exe, which can then be
    executed.

13
C vs. Java
  • I. Similarities
  • -a single rooted class hierarchy, where all
    classes in C are subclasses of System.Object the
    same way all Java classes are subclasses of
    java.lang.Object.
  • -Virtual Machines and Language Runtimes. Just
    like Java is typically compiled to Java byte code
    which then runs in managed execution environment
    (the Java Virtual Machine or JVM), so also is C
    code compiled to an Intermediate Language (IL)
    which then runs in the Common Language Runtime
    (CLR).

14
C vs. Java (Cond)
  • I. Similarities
  • -Similar Keywords

15
C vs. Java (Cond)
  • I. Similarities
  • -No Global Methods Just like Java and unlike
    C, methods in C have to be part of a class
    either as member or static methods.
  • -Interface C, like Java, supports the concept
    of an interface which is akin to a pure abstract
    class. Similarly C and Java both allow only
    single inheritance of classes but multiple
    implementations of interfaces.
  • -Array Declaration

16
C vs. Java (Cond)
  • I. Similarities
  • -Main method In C, it is Main, but in Java,
    it is lower case main. It is typically
    recommended that one creates a main method for
    each class in an application to test the
    functionality of that class besides whatever main
    method actually drives the application.

17
C vs. Java (Cond)
  • II. Differences
  • -Inheritance Syntax C uses C syntax for
    inheritance, both for class inheritance and
    interface implementation, while Java uses the
    extends and implements keywords.
  • C Code Java Code
  • using System class B extends A
    implements Comparable
  • class BA, IComparable

18
C vs. Java (Cond)
  • II. Differences
  • -Namespaces A C namespace is a way to group a
    collection of classes and is used in a manner
    similar to Java's package construct.
  • -Constructors, destructors The syntax and
    semantics for constructors in C is identical to
    that in Java. C also has the concept of
    destructors which use syntax similar to C
    destructor syntax but have the mostly the same
    semantics as Java finalizers.

19
C vs. Java (Cond)
  • II. Differences
  • -Assess Modifier

20
C vs. Java (Cond)
  • II. Differences
  • -Declare constant
  • C const int i10
  • Java final int i10
  • -Nested classes C has the equivalent of Java's
    static nested classes but has nothing analogous
    to Java's inner classes.

21
C vs. Java (Cond)
  • II. Differences
  • -Collections A number of popular programming
    languages contain a collections framework which
    typically consists of a number of data structures
    for holding multiple objects as well as
    algorithms for manipulating the objects within
    the aforementioned data structures. The C
    collections framework consists of the classes in
    the System.Collections namespace. The Java
    collections framework consists of a large number
    of the classes and interfaces in the java.util
    package.

22
C vs. Java (Cond)
  • II. Differences
  • -goto unlike Java, C contains the goto
    statement which can be used to jump directly from
    a point in the code to a label. goto can be
    used in certain situations to reduce code
    duplication while enhancing readability.
  • -interoperability C have better backward
    compatibility with C or C code than Java

23
C vs. C
  • C is Cs closest relative. C statements are
    quite similar to C statements. C builds on the
    syntax and semantics of C, allowing C
    programmers to take advantage of .NET and the
    common language runtime.
  • C is a low-level platform-neutral
    object-oriented programming language. C is a
    somewhat higher-level component-oriented
    language. With the managed environment of .NET,
    C give up that level of control. While .NET
    framework is available to any .NET language, C
    is a language that's well-designed for
    programming with the framework's rich set of
    classes, interfaces, and objects.

24
C vs. C (Cond)
  • C code does not require header files. All code
    is written inline.
  • the use of pointers in C is much less important
    than in C. Pointers can be used in C, where
    the code is marked as 'unsafe', but they are only
    really useful in situations where performance
    gains are at an absolute premium.
  • C distinguishes between value types and
    reference types. Simple types (int, long, double,
    and so on) and structs are value types, while all
    classes are reference types, as are Objects.

25
C vs. C (Cond)
  • Properties
  • Most C programmers try to keep member variables
    private. This data hiding promotes encapsulation
    and allows developers to change implementation of
    the class without breaking the interface the
    clients rely on.
  • In C, properties are first-class members of
    classes. To the client, a property looks like a
    member variable, but to the implementor of the
    class it looks like a method. This arrangement
    allows the total encapsulation and data hiding
    while giving developer clients easy access to the
    members.

26
C vs. C (Cond)
  • Arrays
  • C provides an array class which is a smarter
    version of the traditional C/C array. For
    example, it is not possible to write past the
    bounds of a C array. In addition, Array has an
    even smarter cousin, ArrayList, which can grow
    dynamically to manage the changing size
    requirements of your program.
  • Arrays in C come in three flavors
    single-dimensional, multidimensional rectangular
    arrays (like the C multidimensional arrays),
    and jagged arrays (arrays of arrays).

27
References
  • http//msdn.microsoft.com/vstudio/techinfo/article
    s/upgrade/Csharpintro.asp
  • http//www.csharp-station.com/Tutorials/Lesson01.a
    spx
  • http//www.simonrobinson.com/IntroCSh.htm
  • http//216.239.39.100/search?qcacheJmxDra9zDjcC
    www.25hoursaday.com/CsharpVsJava.htmlC23hlzh-C
    NieUTF-8
  • http//www.microsoft.com/net/basics/
  • http//genamics.com/developer/csharp_comparative.h
    tm
  • http//www.softsteel.co.uk/tutorials/cSharp/lesson
    2.html
  • http//msdn.microsoft.com/msdnmag/issues/01/07/cto
    csharp/default.aspx
Write a Comment
User Comments (0)
About PowerShow.com