ICS 215 Ed Meyer What Is a Scripting Language?

ICS 215 Ed Meyer What Is a Scripting Language?

Introduction to Scripting FA16 – ICS 215 Ed Meyer What is a scripting language? 2 What is the difference between a scripting language and a system programming language? 3 System Programming Languages • From scratch – build data structures – algorithms • Strongly typed to manage complexity 4 Scripting Languages • Designed for gluing • Automate the execute of tasks • Typeless to simplify connections among components 5 System Programming: Beginning • An alternative to assembly – Very low-level – Each statement is a single machine instruction ;; To output a CR, LF crlf macro push ax push dx mov ah, 2 mov dl, 0dh int 21h mov dl, 0ah int 21h pop dx pop ax endm 6 System Programming: Beginning • An alternative to assembly – Very low-level – Each statement is a single machine instruction • Use a compiler to translate higher-level languages to binary instructions 7 System Programming vs Assembly Language Higher-Level Languages • Means many details are handled automatically – Can write less code to get the same job done • Such details are – Register allocation, handled by the compiler – Procedure calling sequences – Simple keywords such as while and if for control structures • 1 system program line ≈ 5 instructions 9 Procedure Calling Sequences 10 if-else statement Suppose we want to do something like: if (ax < bx) { X = -1; } else { X = 1; } it would look like this: mov ax, 5 ; put the value 5 in register ax mov bx, 7 ; put the value 7 in register bx cmp ax, bx jl axLess ; go to 'axLess' if ax < bx mov word [X], 1 ; This is the 'else part jmp Both ; skip the 'then' part axLess: mov word [X], -1 ; This is the 'then' part Both: 11 Read in and Compare 2 Numbers (in C) ~18 Lines of code 12 Read in and Compare 2 Numbers (Assembly) 13 ~54 Lines of code 14 Comparison 18 lines in C : 54 lines in Assembly 1 line in C : 3 lines in Assembly To run C programs, just install C Assembly is restricted to machines hardware Much easier to install software than replace hardware. 15 Typing (System Prog.) • Need to declare how each piece of information will be used String output = new String(); • Each variable must be used in ways that are appropriate for that type 16 String output = "Hello World!" / 5; 17 Typing (System Prog.) • Need to declare how each piece of information will be used String output = new String(); • Each variable must be used in ways that are appropriate for that type • Data and code are segregated • Objects have well-defined structure – With procedures or methods to manipulate them – An object of one type cannot be used in place of another 18 Advantages of Typing • Large programs more manageable – Clarifies how things are used and treated • Catch errors before runtime – Using a string value as a pointer – Compile error vs Runtime error • Improves performance – Mainly via the compiler 19 Scripting Languages Some Examples 21 Typing (Scripting) • Actually, computer are fundamentally typeless – Memory can hold an integer, floating-point, a pointer, or instruction • Meaning of information is determined by the way it is used • No declaration of variable type – Declare a variable and use it! • Easy to glue components together 22 Typing Example (Scripting) • In Java String output = new String(); • In PHP $output = "Hello World!"; $output = 5 + 3; 23 Typing Example (Scripting) • Creating a button in Tcl button .b -text Hello! -font {Times 16} -command {puts hello} 24 Typing Example (Scripting) • Creating a button in C++ CFont *fontPtr = new CFont(); fontPtr->CreateFont(16, 0, 0, 0, 700, 0, 0, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Times New Roman"); buttonPtr->SetFont(fontPtr); 25 Scripts are Interpreted • Not compiled • Rapid turnaround • Increases productivity • Generate code on the fly • Less efficient resource wise – Not really an issue 26 A comparison of various programming languages based on their level (higher-level languages execute more machine instructions for each language statement) and their degree of typing. 27 When should you use…??? 28 A Scripting Language… • Is the application’s main task to connect preexisting components? • Will the application manipulate a variety of different things? • Does the application include a GUI? • Does the application do a lot of string manipulation? • Will the application’s functions evolve rapidly over time? • Does the application need to be extensible? 29 A System Prog. Language… • Does the application implement complex algorithms or data structures? • Does the application manipulate large datasets, for example, all the pixels in an image, such that execution speed is critical? • Are the application’s functions well defined and slow to change? 30 In Comparison… Scripting System Programming • Interpreted • Best suited for complex • Higher productivity systems • Weakly typed • Code is compiled • Higher level than system • Strong typing programming • Reuse is high • Machine instructions per statement is high 31 Trend • Faster machines • Better scripting languages • Growth of Internet • Expand the applicability of scripting languages 32 Additional Readings • On Laulima – "Scripting: Higher Level Programming for the 21st Century" by John K. Ousterhout, IEEE Computer, 31(3) 1998, pp. 23-30, – "Are Scripting Languages Any Good? A Validation of Perl, Python, Rexx, and Tcl against C, C++, and Java" by Lutz Prechelt, Advances in Computers, 57 (Ed.: M. Zelkowitz), Academic Press, 2003, pp. 205-270. 33 More Recently… • ACM Blog July 7, 2014 – Python is Now the Most Popular Introductory Teaching Language at Top U.S. Universities 34.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    34 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us