s c r i pt i n g l a n g u a ges · 2018-01-29 · atom text editor practically every website. fa m...
TRANSCRIPT
![Page 1: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/1.jpg)
Scripting Languages
Course Information
based off notes from Dan Hood
![Page 2: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/2.jpg)
Contact Information
Bryan Wilkinson
[email protected] ITE 373 Of�ce Hours: Mondays 10:30 AM - 11:30 AM and Thursdays 3:00 PM - 4:30 PM or by appointment Website: https://www.csee.umbc.edu/courses/undergraduate/433/spring18/
![Page 3: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/3.jpg)
Tips for This Course
Be comfortable looking things up with resources I have provided, as well ascoming to me for helpStart Projects Early
Quizzes are meant to be a motivationDon't try to write down everything on a slide, use the slides provided and takenotes on top of that
![Page 4: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/4.jpg)
Example Quiz Question
Which of the following character classes matches all types of white space\w\s\S\t
![Page 5: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/5.jpg)
Example Quiz Question
What is the output of the following code and why?
case 9 in *9) echo "This ends in a nine" ;; 9) echo "This is a nine" ;; *) echo "Nothing Matched" ;; esac
![Page 6: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/6.jpg)
Example Quiz Question
Brie�y describe what bene�t AJAX provides. What type of websites andinteractions on those websites does it enable that would not be possible withoutit? (2-3 sentences)
![Page 7: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/7.jpg)
Scripting Languages
Usually interpretedRapid developmentPortability - cross platformSlower - less than in the past
Don't need a mainBut can have one
![Page 8: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/8.jpg)
Scripting Languages
Good to integerate existing programs withFlexible
Easy to extendLots of libraries available for each languageUsually a very easy way of installing them
![Page 9: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/9.jpg)
REPL
One of the most common characteristics of scripting languages is that a programknown as a REPL is providedREPL stands for
ReadEvaluatePrintLoop
This allows scripting languages to be used interactively
![Page 10: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/10.jpg)
Comparison between Scripting and "Systems" Languages
These are generalizations
Scripting Languages Systems Languages
Higher Level Lower Level
Loosely Typed Strongly Typed
Interpreted Compiled
Runs Slower Runs Faster
Faster Development Slower Development
Smaller Code Size Larger Code Size
Ousterhout, John K. "Scripting: Higher level programming for the 21st century." Computer 31.3 (1998): 23-30.
![Page 11: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/11.jpg)
Reasons to prefer scripting or systems languages
The application requires a GUIThe application involves a lot of string manipulationThe application needs to use a variety of pre-existing componentsNew features need to be added very quickly and frequently
Ousterhout, John K. "Scripting: Higher level programming for the 21st century." Computer 31.3 (1998): 23-30.
![Page 12: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/12.jpg)
Popular Applications
System AdministrationText ManipulationWeb Development
Front-end/Client-sideBack-end/Sever-side
Graphical User Interfaces
![Page 13: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/13.jpg)
Popular Applications
ProtypingAutomationHackingGluing
Using two or more existing programs together
![Page 14: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/14.jpg)
Famous Projects Using Scripting Languages
BashParts of Git
RMany internal data analytics in large companiesMany Graphics and analysis on 538.com and NYT's the Upshot
JavaScriptAtom Text EditorPractically Every Website
![Page 15: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/15.jpg)
Famous Projects Using Scripting Languages (Part 2)
PHPWordpressFacebookWikipedia
RubyHomebrewJekyll
![Page 16: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/16.jpg)
How This Class Will Help You Get a Job
Web DevelopmentClient Side ScriptingServer Side Scripting
SysAdminBackupsNetworksLog�le Rotation
![Page 17: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/17.jpg)
How This Class Will Help You Get a Job
Computer SecurityAutomated TestingLog�le Inspection
Software DevelopmentAutomated TestingPrototypingCross-Platform Code
![Page 18: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/18.jpg)
How This Class Will Help You Get a Job
ResearchAccess to existing librariesGluing existing code in multiple languagesCan share your code easily
![Page 19: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/19.jpg)
Language Tour: Perl
https://rosettacode.org/wiki/Fibonacci_sequence#Perl
sub fibRec { my $n = shift; $n < 2 ? $n : fibRec($n - 1) + fibRec($n - 2); }
![Page 20: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/20.jpg)
Language Tour: Perl
http://rosettacode.org/wiki/Tokenize_a_string#Perl
print join('.', split /,/, 'Hello,How,Are,You,Today'), "\n";
![Page 21: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/21.jpg)
Language Tour: Bash
https://rosettacode.org/wiki/Fibonacci_sequence#UNIX_Shell
fib() { local n=$1 [ $n -lt 2 ] && echo -n $n || echo -n $(( $( fib $(( n - 1 )) ) + $( fib $(( n - 2 )) ) )) }
![Page 22: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/22.jpg)
Language Tour: Bash
http://rosettacode.org/wiki/Tokenize_a_string#UNIX_Shell
string='Hello,How,Are,You,Today' (IFS=, printf '%s.' $string echo)
![Page 23: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/23.jpg)
Language Tour: R
https://rosettacode.org/wiki/Fibonacci_sequence#R
recfibo <- function(n) { if ( n < 2 ) n else Recall(n-1) + Recall(n-2) }
![Page 24: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/24.jpg)
Language Tour:
http://rosettacode.org/wiki/Tokenize_a_string#R
text <- "Hello,How,Are,You,Today" junk <- strsplit(text, split=",") print(paste(unlist(junk), collapse="."))
![Page 25: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/25.jpg)
Language Tour: JavaScript
https://rosettacode.org/wiki/Fibonacci_sequence#JavaScript
function fib(n) { return n<2?n:fib(n-1)+fib(n-2); }
![Page 26: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/26.jpg)
Language Tour: JavaScript
http://rosettacode.org/wiki/Tokenize_a_string#JavaScript
alert( "Hello,How,Are,You,Today".split(",").join(".") );
![Page 27: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/27.jpg)
Language Tour: PHP
https://rosettacode.org/wiki/Fibonacci_sequence#PHP
<?php function fibRec($n) { return $n < 2 ? $n : fibRec($n-1) + fibRec($n-2); } ?>
![Page 28: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/28.jpg)
Language Tour: PHP<?php $str = 'Hello,How,Are,You,Today'; echo implode('.', explode(',', $str)); ?>
http://rosettacode.org/wiki/Tokenize_a_string#PHP
![Page 29: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/29.jpg)
Jupyter
Lectures this semester are prepared using a tool called JupyterAllows mixing of code and notesKernels available for many languges
Following Examples from http://r-statistics.co/Complete-Ggplot2-Tutorial-Part1-With-R-Code.html
![Page 30: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/30.jpg)
In [4]: library(ggplot2) ggplot(midwest, aes(x=area, y=poptotal)) + geom_point() + geom_smooth(method="lm") + coord_cartesian(xlim=c(0,0.1), ylim=c(0, 1000000)) + labs(title="Area Vs Population", subtitle="From midwest dataset", y="Population", x="Area", caption="Midwest Demographics")
![Page 31: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/31.jpg)
In [5]: library(ggplot2) gg <- ggplot(midwest, aes(x=area, y=poptotal)) + geom_point(aes(col=state), size=3) + # Set color to vary based on state categories. geom_smooth(method="lm", col="firebrick", size=2) + coord_cartesian(xlim=c(0, 0.1), ylim=c(0, 1000000)) + labs(title="Area Vs Population", subtitle="From midwest dataset", y="Population", x="Area", caption="Midwest Demographics") plot(gg)
![Page 32: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/32.jpg)
In [6]: library(ggplot2) # Filter required rows. midwest_sub <- midwest[midwest$poptotal > 300000, ] midwest_sub$large_county <- ifelse(midwest_sub$poptotal > 300000, midwest_sub$county, "") # Base Plot gg <- ggplot(midwest, aes(x=area, y=poptotal)) + geom_point(aes(col=state, size=popdensity)) + geom_smooth(method="loess", se=F) + xlim(c(0, 0.1)) + ylim(c(0, 500000)) + labs(title="Area Vs Population", y="Population", x="Area", caption="Source: midwest") gg + geom_label(aes(label=large_county), size=2, data=midwest_sub, alpha=0.25) + labs(subtitle="With ggplot2::geom_label") + theme(legend.position = "None") # label # Plot text and label that REPELS eachother (using ggrepel pkg) ------------ library(ggrepel) gg + geom_label_repel(aes(label=large_county), size=2, data=midwest_sub) + labs(subtitle="With ggrepel::geom_label_repel") + theme(legend.position = "None") # label
Warning message: “Removed 15 rows containing non-finite values (stat_smooth).”Warning message: “Removed 15 rows containing missing values (geom_point).”Warning message: “Removed 14 rows containing missing values (geom_label).”
Error in library(ggrepel): there is no package called ‘ggrepel’ Traceback:
![Page 33: S c r i pt i n g L a n g u a ges · 2018-01-29 · Atom Text Editor Practically Every Website. Fa m o u s Pro j ec t s Us i n g S c r i pt i n g L a n g u a ges ( Pa r t 2 ) PHP Wordpress](https://reader033.vdocuments.us/reader033/viewer/2022050208/5f5b60d293842917427c340a/html5/thumbnails/33.jpg)
Binder
Binder uses a combination of Jupyter and related projects along with Docker tocreate a cloud based notebookAnyone can run with the link, creates a virtual machine per session
Nothing is saved in the virtual machine permanetlyA great way to try out lectures interactively, or explore what small changes tothe code will do