Top Banner
Marco Fioretti ([email protected]) September 2010, Prishtina http://mfioretti.com Software Freedom Conference Kosova http://stop.zona-m.net Some rights reserved The Power of scripting why and how to promote scripting languages in schools and small businesses Marco Fioretti http://mfioretti.com http://stop.zona-m.net
30

The Power of scripting

May 10, 2015

Download

Technology

Marco Fioretti

Why and how to promote scripting languages
in schools and small businesses: "it can save a huge amount of work!"

Background: these are the slides of my talk at the 2010 Free Software conference in Kosova. For details, read http://mfioretti.com/power-scripting-why-and-how-promote-scripting-languages-schools-and-small-businesses
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The Power of scripting

Marco Fioretti ([email protected]) September 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some rights reserved

The Power of scriptingwhy and how to promote

scripting languages

in schools and small businesses

Marco Fiorettihttp://mfioretti.com

http://stop.zona-m.net

Page 2: The Power of scripting

2Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Marco Fioretti

Member ofOpenDocument Fellowship (www.opendocumentfellowship.com)

Digistan.org (www.digistan.org)

Writer for Linux Journal, Linux Format, Pc Professionale and other magazines

Author of the Family Guide to Digital Freedom (http://digifreedom.net)

Co-author of the O'Reilly Open Government book

Home page and writings:

http://mfioretti.com

http://stop.zona-m.net

Author introduction

Page 3: The Power of scripting

3Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

What the command line and scripting

languages really are

Practical examples

Conclusions: why scripting languages are

good for schools and small businesses

Agenda

Page 4: The Power of scripting

4Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

A GUI is an environment in which the computer

visually tells you what can be done, showing

possible choices in buttons or menus

And the user manually indicates (mouse clicks) what

he or she wants to do. Every time...

What is a graphical user interface (GUI)?

Page 5: The Power of scripting

5Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

A command line is a place, inside a text terminal

window, where the user can write, that is declare in

writing, whatever he or she wants the computer to do

Depending on the context, a shell is either an

environment in which the user can give commands to

the computer, or an interpreter of those commands

What are shells,command lines, terminals?

Page 6: The Power of scripting

6Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

The GUI shows what is the content of a folder:

GUI vs Command line: visual comparison

Page 7: The Power of scripting

7Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

A shell tells the user what is the content of a folder

GUI vs Command line: visual comparison

Page 8: The Power of scripting

8Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

To move files and folders in GUIs, the user must point to

those objects and to the place where they should go

GUI vs Command line: visual comparison

Select object Drag it to destination

Page 9: The Power of scripting

9Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

To move files and folders in the terminal, the user tells the

computer where those objects should go

GUI vs Command line: visual comparison

mv = “move this here”

Page 10: The Power of scripting

10Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

There are many cases where a GUI is much more efficient (e.g.

picture editing, drawings...)

But also many others where the difference between GUI and

command line users is the same that there is between a toddler

pointing at objects and an adult saying “I need to do this”

Ignorance of real speech (GUI) = much more communication

limits, that is much more effort and time wasted to tell the

computer what it must do

GUI vs Command line: what's the difference?

Page 11: The Power of scripting

11Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

The fact that textual commands don't need to be given in real time!

To repeat gestures you must either repeat them or make a movie

To repeat many text commands, you can just type them all, once,

into a file...

...that the computer is able to read by itself!

And all this is much, much, much simpler than real

programming!

And another HUGE difference is...

Page 12: The Power of scripting

12Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

A scripting language is a computer language which has an

interpreter, that is a separate program that:

Reads the commands written into files called scripts, one at a

time

And executes those commands, one at a time

Without asking the user to take care of variable declarations or

typing, memory allocation, compiling code and so on!

What are scripting languages?

Page 13: The Power of scripting

13Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

What does a script look like?

Declaration of whichinterpreter must be used

comments

Variable assignments These are the actual commands that

the script will executes for you

Page 14: The Power of scripting

14Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

The OpenDocument Format (ODF) which is the default format

for OpenOffice...

...is nothing else than ZIP archives containing plain text files and

other objects (e.g. images) in normally standard formats

Therefore, it is very easy to create or analyse office texts,

presentations and spreadsheet automatically...

...using the many FOSS tool created just to process plain text

Examples with OpenDocument scripting

Page 15: The Power of scripting

15Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Examples (1): Generate OpenDocument invoice

marco => cat my_data.sh INVOICE_DATE='2010/05/15' VENDOR_CODE='007' PO_NUMBER='Purchase Order #1' TOTAL=10 ISSUE=150 DESCRIPTION='Here is your invoice'

1 ASCII data file

+ 35 lines shell script

Result directlyUsable in OpenOffice!

Page 16: The Power of scripting

16Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Example (2): Spreadsheets with working graphs and formulas

•Time-of-day BW 1 BW2• Midnight 4.5 6.4• 6.3 6.3• 3.1 6.1• 1.85 5.87

+

Still editable formulas!!!

Page 17: The Power of scripting

17Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Example (3):Slideshows drafts from plain text outlines

A: with the same trick used in the spreadsheet example, same scripts complexity

Q: how did I generate the first version of this slideshow?

Page 18: The Power of scripting

18Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Other things very easy to do with ODF

Format math formulas and exercises created with Mathematica

Generate course DVDs from existing slideshows

Generate printable versions of multiple choice tests created in

Moodle for online teaching

Automatically import content of spreadsheets or texts to databases

Automatically add watermark or caption to each image in many

texts or presentations

Reduce image resolution, to save disk space

replace company logos or other clipart

Page 19: The Power of scripting

19Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Image processing with ImageMagick

The ImageMagick tools (www.imagemagick.org) can be run at the command line or inside a

script to:

Automatically resize all your

pictures

Generate thumbnails for web

publishing

Add captions, frames or

watermarks to them

Example from

www.rubblewebs.co.uk/imagemagic

k/compair.php

Page 20: The Power of scripting

20Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Automatic (collaborative) picture geotagging

Minimap is a

Firefox extension

that lets the user

create lists of

points of interests

and of their

geographical

coordinates

Page 21: The Power of scripting

21Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Automatic (collaborative) picture geotagging (2)

The Minimap user needs to know nothing about geotagging or

geographical coordinates at all

1) click on point of interest in Google Maps

2) give it a name and optional description in

the Minimap pop-up window

3) repeat for as many other points as you

like

3) save all place names and coordinates as

ONE plain text file

Page 22: The Power of scripting

22Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Automatic, collaborative picture geotagging (3)

Coordinates captured with Minimap can then be automatically inserted inside digital or scanned photographs with the Exiftool utility

Coordinates!

Page 23: The Power of scripting

23Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Flow for (collaborative) geotagging

Create plain text listing of place names and their coordinates with Minimap:

Cannigione Harbour: Long: 9.01E, Lat 42.03N

Cannigione Church: Long: 9.04E, Lat 42.06N

...

Create plain text list that associates each picture to a place

picture_1.jpg: Cannigione Harbour

picture_2.jpg: Cannigione Church

picture_3.jpg: Cannigione Harbour

.....

Page 24: The Power of scripting

24Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Flow for (collaborative) geotagging (2)

Run one script that:

Reads the two lists

Associates to each picture its coordinates

Tells the exiftools program to write those

coordinates in the EXIF standard format inside

the corresponding JPG file

Page 25: The Power of scripting

25Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Advantages of collaborative geotagging

Lists of coordinates must be created only once for

each point of interest

It can be made with Minimap, that is extremely easy

to use and multiplatform, just like Firefox

Being plain text files, lists of coordinates by many

different people can be merged without problems

The person that runs the script can be somebody else

Page 26: The Power of scripting

26Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Conclusions: what's the power of scripting?

Computers should save our time, not waste it!

Scripting can save huge amounts of time in all areas of

computer work!

The examples presented are directly relevant and useful in

any school or small business

Scripting automates creation of homework, exercises,

budget reports...

Page 27: The Power of scripting

27Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Why is scripting so powerful?

Because it is equivalent to moving from sign language to real

language

We have ten fingers to type on 101 buttons, only one hand to

move one mouse: what's more efficient?

Therefore, scripting makes it much easier to quickly explain to

your computer all you want it to do for you

No matter what you do with computers, there surely is

something that can be automated by scripting

Page 28: The Power of scripting

28Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Last but not least...

Even if you're an absolute beginner, there are

thousands of scripting tutorials and practical

examples online

Scripting is multiplatform: while it is already

“built-in” in any Gnu/Linux distribution, the same

scripts can also be run on Windows or Mac systems

Page 29: The Power of scripting

29Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Note for Free/Open Source Software activists

Explaining the power of scripting can also be an

effective way to introduce to FOSS many people

that would be intimidated or bored by other

approaches

Did you notice that in all these slides there is NO

mention of: source code, sw licenses etc...?

Page 30: The Power of scripting

30Marco Fioretti ([email protected]) August 2010, Prishtinahttp://mfioretti.com Software Freedom Conference Kosovahttp://stop.zona-m.net Some Rights Reserved

Resources

ODF scripting

http://freesoftware.zona-m.net/odf-scripting

Collaborative geotagging:

www.tuxradar.com/content/geotagging-linux

www.linux.com/archive/feature/147564

Command line recipes

www.commandlinefu.com

Questions?

For more info: [email protected]