what is scripting
play

What is Scripting? ! Yes! The name comes from written script CSCI: - PDF document

What is Scripting? ! Yes! The name comes from written script CSCI: 4500/6500 Programming such as screenplay, where dialog is repeated verbatim for every performance Languages Scripting Languages Chapter 13 1 2 Maria Hybinette, UGA Maria


  1. What is Scripting? ! Yes! The name comes from written script CSCI: 4500/6500 Programming such as screenplay, where dialog is repeated verbatim for every performance Languages Scripting Languages Chapter 13 1 2 Maria Hybinette, UGA Maria Hybinette, UGA Origin of Scripting Languages Higher-level Programming ! Scripting languages originated as job control ! Scripting languages provide an even higher- languages level of abstraction than languages we have » 1960s: IBM System 360 had the Job Control Language seen previously (JCL) » The main goal is programming productivity » Scripts used to control other programs – Performance is a secondary consideration – Launch compilation, execution » Modern SL provide primitive operations with greater – Check return codes functionality ! Scripting languages evolved in the UNIX world ! Scripting languages are usually interpreted » Shell programming: AWK, Tcl/Tk, Perl » Scripts used to combine component ( “ programming in » Interpretation increases speed of development the large ” ) – Immediate feedback – Gluing applications [ Ousterhout 97 ] » Compilation to an intermediate format is common ( e.g., Perl). Glue that puts components together 3 4 Maria Hybinette, UGA Maria Hybinette, UGA Contemporary Scripting Languages What is Scripting Language Again? ! Unix shells: sh, ksh, bash ! Favor rapid development over efficiency of execution » job control ! Perl » Code can be developed 5-10 times faster in a scripting language but will run slower at a 10th/20th » Slashdot, bioinformatics, financial data processing, CGI of the speed of a systems language such as C, C++ ! Python [Ousterhout] » System administration at Google ! Coordinates multiple programs ! Ruby » Strong at communicating with program » Various blogs, data processing applications components written in other languages ! PHP ! Hard to put a finger on -- difficult to define » Yahoo web site exactly what makes language a scripting ! JavaScript language » Google maps 5 6 Maria Hybinette, UGA Maria Hybinette, UGA

  2. Designed to support “ quick programming ” Common Characteristics “ Typing ” and Productivity ! Batch and interactive use ! Economy of expression (readability?) We will talk ! Weakly typed more about » meaning is inferred (no declaration required) types later… » => less error checking at compile time – run time checking is less efficient (strict run type checking by Python, Ruby, Scheme). » Increases speed of development – more flexible – fewer lines of code ! High-level model of underlying machines ! Easy access to other programs ! Sophisticated pattern matching and string manipulation ! High-level data types (sets, bags, lists, dictionaries and [Ousterhout, 97] tuples) 7 8 Maria Hybinette, UGA Maria Hybinette, UGA Design Philosophy Design Philosophy Often people, especially computer engineers, focus on the Often people, especially computer engineers, focus on the machines. They think: machines. They think: " By doing this, the machine will run faster. " By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will run more effectively. By doing this, the machine will something something something. " By doing this, the machine will something something something. " They are focusing on the machines. But in fact we need to They are focusing on the machines. But in fact we need to focus on humans, on how humans care about doing focus on humans, on how humans care about doing programming or operating the application of the machines. programming or operating the application of the machines. We are the masters. They are the slaves. We are the masters. They are the slaves. Yukihiro “ Matz ” Matsumoto Yukihiro “ Matz ” Matsumoto Creator of Ruby Creator of Ruby 9 10 Maria Hybinette, UGA Maria Hybinette, UGA http://www.cs.uga.edu/~maria/classes/4500- Spring-2006/4500-hw.html Application Domains We will use Ruby here, but easy (and similar) in most scripting languages ! Shell scripts ! Macro ! Application specific ! Web programming ! Text processing ! Extension/Embedded ! Others 11 Maria Hybinette, UGA

  3. Demo: Getting due dates of homework #!/usr/bin/ruby require 'uri'; require 'net/http' uri= URI.parse( ARGV[0] ) ! What if I don ’ t want to go to the web site to h=Net::HTTP.new(uri.host,80) see if I have CSCI 4500/6500 homework? resp,data = h.get(uri.path) hwk = {} ! What if I don ’ t want to launch a heavy duty if resp.message == "OK" data.scan(/Homework (\d*) \(due (\d*)\/(\d*)\)/)\ web browser? {|x,y,z| hwk[x] = Time.local(2006,y,z)} end ! Write a script to check for me! hwk.each{| assignment, duedate| if duedate < (Time.now - 60 * 60 * 24) puts "Hwk #{assignment} was due on #{duedate.strftime("%A, %B %d")}." {saffron} check http://www.cs.uga.edu/~maria/classes/4500-Spring-2006/4500-hw.html else Hwk 6 is due on Thursday, April 13. puts "Hwk #{assignment} is due on #{duedate.strftime("%A, %B %d")}." Hwk 1 was due on Tuesday, January 10. end Hwk 2 was due on Tuesday, January 31. } Hwk 3 was due on Wednesday, February 15. Hwk 4 is due on Thursday, March 09. Hwk 5 is due on Thursday, March 30. 13 Maria Hybinette, UGA “ Shebang ” useful libraries #!/usr/bin/ruby #!/usr/bin/ruby require 'uri'; require 'net/http' require 'uri'; require 'net/http' uri= URI.parse( ARGV[0] ) uri = URI.parse( ARGV[0] ) h=Net::HTTP.new(uri.host,80) h = Net::HTTP.new(uri.host,80) resp,data = h.get(uri.path) resp,data = h.get(uri.path) hwk = {} hwk = {} if resp.message == "OK" if resp.message == "OK" data.scan(/Homework (\d*) \(due (\d*)\/(\d*)\)/)\ data.scan(/Homework (\d*) \(due (\d*)\/(\d*)\)/)\ {|x,y,z| hwk[x] = Time.local(2006,y,z)} {|x,y,z| hwk[x] = Time.local(2006,y,z)} end end hwk.each{| assignment, duedate| hwk.each{| assignment, duedate| if duedate < (Time.now - 60 * 60 * 24) if duedate < (Time.now - 60 * 60 * 24) puts "Hwk #{assignment} was due on #{duedate.strftime("%A, %B %d")}." puts "Hwk #{assignment} was due on #{duedate.strftime("%A, %B %d")}." else else puts "Hwk #{assignment} is due on #{duedate.strftime("%A, %B %d")}." puts "Hwk #{assignment} is due on #{duedate.strftime("%A, %B %d")}." end end } } #!/usr/bin/ruby #!/usr/bin/ruby require 'uri'; require 'net/http' require 'uri'; require 'net/http' Associative Powerful regular uri = URI.parse( ARGV[0] ) uri = URI.parse( ARGV[0] ) arrays: expression h = Net::HTTP.new(uri.host,80) h = Net::HTTP.new(uri.host,80) Keys & Values support resp,data = h.get(uri.path) resp,data = h.get(uri.path) hwk = {} hwk = {} if resp.message == "OK" if resp.message == "OK" data.scan(/Homework (\d*) \(due (\d*)\/(\d*)\)/)\ data.scan(/Homework (\d*) \(due (\d*)\/(\d*)\)/)\ {|x,y,z| hwk[x] = Time.local(2006,y,z)} {|x,y,z| hwk[x] = Time.local(2006,y,z)} end end hwk.each{| assignment, duedate| hwk.each{| assignment, duedate | if duedate < (Time.now - 60 * 60 * 24) if duedate < (Time.now - 60 * 60 * 24) puts "Hwk #{assignment} was due on #{duedate.strftime("%A, %B %d")}." puts "Hwk #{assignment} was due on #{duedate.strftime("%A, %B %d")}." else else puts "Hwk #{assignment} is due on #{duedate.strftime("%A, %B %d")}." puts "Hwk #{assignment} is due on #{duedate.strftime("%A, %B %d")}." end end } }

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend