1 / 56

Comparing and Contrasting C#, Scheme, and T-SQL

Comparing and Contrasting C#, Scheme, and T-SQL. Joseph P. Mohr. Outline. C# Overview Scheme Overview T-SQL Overview Language Comparisons Conclusions. C# Overview. Object-Oriented Language Type-Safe Evolved from C Main application is server-side scripting in the .NET Framework

murray
Télécharger la présentation

Comparing and Contrasting C#, Scheme, and T-SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Comparing and Contrasting C#, Scheme, and T-SQL Joseph P. Mohr

  2. Outline • C# Overview • Scheme Overview • T-SQL Overview • Language Comparisons • Conclusions

  3. C# Overview • Object-Oriented Language • Type-Safe • Evolved from C • Main application is server-side scripting in the .NET Framework • Developed in 2001 • Current version is 4.0

  4. C# Advantages • C# is designed for component-oriented programming • Software Components • Increasingly used in modern software design • Self-contained and self-describing • Have their own documentation

  5. C# Advantages • Versioning • Allows the language to evolve without breaking programs in older versions. • Supports virtual and override modifiers. • Method overloading that supports versioning. • Explicit interface member declarations.

  6. C# Advantages • Virtual and Override • If a method is declared virtual, then the implementation evokes is determined at run-time. • Non-Virtual methods have the implementation determined at compile-time. • The override modifier can be used to provide another implementation for an existing virtual method.

  7. C# Program Structure • C# programs are comprised of the following: • Programs • Namespaces • Types • Members • Assemblies

  8. C# Programs • Consist of one or more source files • Source files contain the other structural elements of the program

  9. C# Namespaces • Declared at the top of the source file with the using directive • Avoid having to use the fully qualified names in the source code.

  10. C# Types • Most common types: • Classes • Interfaces • Can contain members and namespaces • Either reference or value • With reference type, two variables can affect the same object.

  11. C# Members • Most common members: • Fields • Methods • Properties • Events

  12. C# Assemblies • Made up of Intermediate Language (IL) and metadata • Use Just-In-Time (JIT) compiling • Implement applications or libraries and have the .exe or .dll file extension respectively

  13. C# Hello World Program Using System; Class Hello { Static void Main() { Console.Out.WriteLine(“Hello, World”); } }

  14. C# Grammars • C# uses two different grammars, the Lexical grammar and the syntactic grammar. • Lexical grammar defines line terminators, white space, comments, tokens, and preprocessing directives. • Syntactic grammar defines how the tokens from the lexical grammar are combined into programs.

  15. C# Performance • Compiled language results in fast execution. • High performance is a result of being derived from the C family. • Boxing and Unboxing operations are the most common detriments to performance. • Can be avoided by declaring as Object

  16. C# Readability • Pros: • Clearly defined data types • Familiar, well designed syntax • Cons: • Feature multiplicity • Operator Overloading

  17. C# Writability • Pros: • Excellent support for abstraction • Strong expressivity with control sections • Cons: • Large number of different contstructs

  18. C# Orthogonality • Classes derived from the base Object Class, which includes implementation of the primitives, can be simply combined to create very robust and diverse data structures.

  19. C# Reliability Pros • Type-Checking: • C# is considered a type-safe language and the compiler can catch type errors in almost all cases. • There are pointers supported by the language which can prevent the compiler from catching type-errors. • Exception Handling: • Highly functional and similar to Java

  20. C# Reliability Cons • Aliasing: • Reference types can be referring to the same memory location and is considered a detriment to reliability.

  21. C# Portability • The modular design considerations of C# makes the code highly portable. • Self-contained documentation in all the modules makes for easier portability amongst different software developers.

  22. C# Tools and Compilers • MS Visual C# • MS Visual Studio

  23. C# Personal Example using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication2 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Calendar1_DayRender(object sender, DayRenderEventArgs e) { EventDataContextedc = new EventDataContext(); var query = from ev in edc.Events where ev.Date == e.Day.Date select ev;

  24. C# Personal Example Contd. e.Cell.VerticalAlign = VerticalAlign.Top; e.Cell.BorderColor = System.Drawing.Color.Teal; e.Cell.BorderWidth = 1; e.Cell.BorderStyle = BorderStyle.Solid; foreach (var ev in query) { HyperLink link = new HyperLink(); link.ForeColor = System.Drawing.Color.Teal; link.NavigateUrl = "~/EventInfo.aspx?event=" + ev.EventNo; link.Text = ev.Name; Button but = new Button(); e.Cell.Controls.Add(new LiteralControl("<p>")); e.Cell.Controls.Add(link); e.Cell.Controls.Add(new LiteralControl("</p>")); } } } }

  25. C# Demo • www.myjaxcalendar.com

  26. Scheme Overview • Functional programming language • Evolved from LISP • Created in 1975 at MIT by Guy L. Steele and Gerald J. Sussman • Originally called Schemer to mimic the naming convention used by other languages evolved from LISP, such as Conniver • Considerably more minimalist than Common Lisp, but supports tools for language extension.

  27. Scheme Applications • Most commonly used for lambda calculus and as an educational tool by introductory level computer science classes. • Lambda calculus is a logical system of computation through the use of binding and substitution.

  28. Scheme Programs • Scheme programs are interpreted. • Program Elements: • Keywords • Variables • Structured forms • Constant data (numbers, characters, strings, quoted vectors, quoted lists, quoted symbols, etc.) • Whitespace • Comments • Program expressions are known as s-expressions

  29. Scheme Syntax • S-expressions are made up of structured forms and lists. • S-expressions are delineated by matching sets of opening and closing parentheses.

  30. Scheme Primitives and Variables • List-processing primitives: • car – the first element in a list • cdr – all the other elements in the list • cons – constructs lists • First-class functions (functions can be assigned to variables)

  31. Scheme Variable Scoping • Only the inner-most binding of a variable is visible in an expression. • Inner bindings are said to “shadow” the outer bindings. • This type of scoping is known as “lexical scoping”.

  32. Scheme Example Expression • Expression: • (cdr (car ‘((1 2 3) 4 5))) • Result: • (2 3)

  33. Scheme Performance • Scheme executes faster and more efficiently than Common LISP as a result of its minimalist design.

  34. Scheme Readability • Pros: • Overall Simplicity of the language, including a lack of feature multiplicity, improves the readability of the language. • Identifiers are not restricted in length. • Cons: • The dynamic variable types which aren’t explicitly declared to be of a certain data type.

  35. Scheme Writability • Pros: • The overall simplicity of the language, especially over that of Common LISP • Cons: • Weak support for abstraction • Lacking expressivity

  36. Scheme Orthogonality • Simply supports the most commonly used data structures including Strings and Enums. • Lacking in the ability to combine primitives in to complex data structures.

  37. Scheme Reliability • Pros: • Lack of aliasing • Performs run-time type checking • Cons: • Does not have a good system for exception handling.

  38. Scheme Portability • Scheme programs are highly portable between the same version of Scheme. • The very high number of versions of Scheme in use is major stumbling block to the portability of Scheme.

  39. Scheme Flavors • Some of the many flavors of scheme are: • SISC – runs off of the JVM • DrRacket – Student friendly interface • MIT Scheme – very widely used

  40. Scheme Demo

  41. T-SQL Overview • Query Language • Uses statements that are interpreted by the database server. • Used with relational databases • Relational databases are based off of first order predicate logic. • Used by MS SQL Server database and Sybase database. • Main application is the construction and manipulation of enterprise databases.

  42. T-SQL Overview • History: • Evolved from SEQUEL. • SEQUEL (Structured English Query Language) is a query language developed by IBM in the 1970’s and they later renamed it to SQL (Structured Query Language) • T-SQL (Transact SQL) is an extension to SQL developed by a partnership between Microsoft and Sybase.

  43. T-SQL Overview • Data in relational databases are comprised of entity types • Entity Types are collections of the of the entities and thought type and are represented as TABLES. • Each instance of that entity is a record or tuple and is represented as a row in the table. • Records are comprised of different attributes, and they are represented as columns in the table.

  44. T-SQL Overview • T-SQL is technically a data-sublanguage • The T-SQL sublanguage is comprised of the following: • Data Definition Language (DDL) • Data Manipulation Language (DML)

  45. T-SQL DML • The DML is used to define database structure, integrity rules, and user privileges. • Includes the following commands: • CREATE TABLE, DROP TABLE, ALTER TABLE • CREATE VIEW, DROP VIEW • CREATE INDEX, DROP INDEX

  46. T-SQL DML • The DML is used to manipulate the data within the database. • DML Commands Include: • SELECT • INSERT • UPDATE • DELETE

  47. T-SQL Extensions • T-SQL extends SQL to include: • Procedural Programming • Local Variables • Support functions for processing various data types • The extensions included in T-SQL grant it equivalent capabilities to other programming languages.

  48. T-SQL Extensions • Flow control in T-SQL: • Begin • End • Break • Continue • GOTO • IF • ELSE • RETURN • WHILE • WAITFOR

  49. T-SQL Exception Handling • T-SQL contains try-catch blocks, unlike SQL • Example: BEGIN TRY //STATEMENTS END TRY BEGIN CATCH //STATEMENTS TO HANDLE EXCEPTION END CATCH

  50. T-SQL Demo

More Related