programming languages: an overview for librarians · like drupal, libguides, and marcedit what...

55
Programming Languages: An overview for librarians Southeastern New York Library Resources Council | April 30, 2015 Joanna DiPasquale

Upload: others

Post on 30-Sep-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Programming Languages: An overview for librarians

Southeastern New York Library Resources Council | April 30, 2015 Joanna DiPasquale

Page 2: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Sitting around a lunch table…

https://flic.kr/p/4Y9Eg3

Presenter
Presentation Notes
You can do this! Maybe your background isn’t in computer science or you don’t have a lot of practice with it yet. That’s okay. A lot of people don’t start out this way, either!
Page 3: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Viking Code School

Viking Code School Blog, “Why Learning to Code Is So Damn Hard.” 2015 Feb 24. http://www.vikingcodeschool.com/posts/why-learning-to-code-is-so-damn-hard

Presenter
Presentation Notes
One major takeaway: do bite-sized challenges that really test the somewhat unsexy skills of writing standards-conforming good code, debugging, architecture, and data transfer. I would also argue that one of the toughest challenges is in that “cliff of confusion” area because you most likely are not writing your own code in your day-to-day – you’re following someone else’s, which means you have to get into their head. Practice, practice, practice.
Page 4: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Goals of the workshop

Page 5: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

“Why am I taking this again…?”

Hands-on How to break down

problems and use code to solve them.

Familiarity with a variety of languages and the strengths and potential of each one.

How APIs fit into the picture.

How to decide what language to apply to solve specific problems.

Applied Making the most out of tools

like Drupal, LibGuides, and MarcEdit

What skills are important to put on an RFP or job description.

Reasonable limits – when to call a pro!

How to make a worthwhile IT call.

Presenter
Presentation Notes
Remember, knowledge is being able to apply your information. So let’s start! Since you work in a library, you are used to thinking about how information is structured. This is a huge benefit.
Page 6: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

“How do you get to Carnegie Hall?”

Practice, practice, practice

https://flic.kr/p/qN5Lvc

Presenter
Presentation Notes
https://flic.kr/p/qN5Lvc
Page 7: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Jargon, jargon, jargon Some of it is important!

Page 8: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Warm-up exercise!

What terms do you know?

What terms have you never heard of?

What terms has someone told you that you should have heard at a meeting, even though it seemed vaguely irrelevant at the time (and maybe still does? )

Which term is a magic bullet for all library-wide problems? (Big hint: the answer probably isn’t on the sheet.)

Presenter
Presentation Notes
There is no magic bullet.
Page 9: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Section 1 Let’s get started!

Page 10: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Think like your computer, part 1: Breaking down real-world problems

Excellent resource: Yelton, Andromeda (2015). “Coding for Librarians: Learning by Example.” Library Technology Reports, 51:3. http://dx.doi.org/10.5860/ltr.51n3

Presenter
Presentation Notes
This book is filled with examples and code – from a variety of languages. Go check it out!
Page 11: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

The EAD problem

“…[a librarian] needed to export metadata: in his case, EAD files from ArchivesSpace. His short Python script finds all the resource IDs that match a given criterion, gets their EAD, and writes it to a specified destination.” (Chapter 2)

Page 12: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Let’s go to the code (Python)!

https://gist.github.com/helrond/1ef5b5bd47b47bd52f02

Page 13: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

“How do you get to Carnegie Hall?”

Practice, practice, practice

https://flic.kr/p/qN5Lvc

Presenter
Presentation Notes
https://flic.kr/p/qN5Lvc This is the problem – we look at the code and not at the problem we’re trying to solve. So let’s try that instead.
Page 14: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Let’s break this problem down

Page 15: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

What does your script need to know to solve this problem?

Where is the content that I need? In some software program called ArchivesSpace.

Wait, so what content do I need again? EAD files.

What’s an EAD file? It’s a special kind of XML.

Okay…. Um… this is embarrassing. What’s XML? eXtensible Markup Language.

(thinking) Aha! That means I’ll need to be good at capturing strings, maybe not so much numbers.

Great! Does ArchivesSpace just have EAD files? Nope.

So how will I know I have an EAD file? They are the resources whose IDs have ‘FA’ in them.

What do I do when I find the stuff with the ‘FA’? Save the file you find.

Presenter
Presentation Notes
Imagine your potential program is talking to you. What is it saying? Really?
Page 16: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Diagram

Get all the resources

by ID

Connect to AS

IDs with FA (save)

IDs without

FA (ignore)

Page 17: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Pseudocode

Connect to ArchivesSpace. // Maybe ArchivesSpace has a publicly-available list of all of the IDs. That would make life easier. // Assume connection is successful.

Once connected: Get a list of everything in the system based on ID For (every ID that I get):

If the ID has the string “FA” in it, save it locally. // this is the criteria we need If the ID doesn’t have the string “FA” in it, keep going.

Close the connection.

Presenter
Presentation Notes
Pseudocode? This is helpful when you are learning to break down problems for coding / scripting.
Page 18: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Keys to solving the problem

The right questions to ask What information structure do you need? Where and how is it stored? What is unique about the information I need? How will I know when I find it? What do I need to do with it when I find it?

The right facets of information Unique identifiers Data types File formats and structures

Presenter
Presentation Notes
There are lots more ‘right’ facets, but these three are so common to libraries…!
Page 19: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

A whirlwind lesson on data types & (two) paradigms

https://flic.kr/p/9J5r8M

Page 20: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Data types (primitive)

Numbers Integers (short, int, long) Real (float, long)

Characters Char

Logical Boolean (true, false)

Presenter
Presentation Notes
* Java programming language model (for short) Think about a container and how many containers can express something.
Page 21: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Data types (composite)

Arrays Associative arrays

Strings

Records

Object Object-oriented programming

Presenter
Presentation Notes
Arrays are incredibly useful. PyMARC makes use of them extensively – that’s the beauty of PyMARC!
Page 22: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

“Why are TRUE and FALSE integers?”

Lurking behind every data type is a number. Somewhere.

Inherently, computers… compute.

There’s always numbers lurking behind data types.

Zero is the first number.

Associative arrays get around this a little bit.

Presenter
Presentation Notes
True = 1, false = 0
Page 23: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Variable

A container that will hold a value

Can be simple or composite

Global variables – don’t change no matter where you are in your program. Some languages have built-in global variables. Example: PHP’s $_SERVER

Object oriented programming

Presenter
Presentation Notes
This is oversimplified. You also need to know that, depending on tools available to you, variables can be passed by reference or directly, they can be modified within scope or outside of scope, they might be global, etc.
Page 24: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Beginning to build your code

Program

Variables (nouns)

Functions (verbs)

Conditionals (adjectives or adverbs)

Presenter
Presentation Notes
This can be a helpful model if you are coming from a non-math background
Page 25: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Two different programming paradigms

Functional

Fixed set of things (the types of things tend not to change)

Primarily adding new operations

Database query languages like SQL are considered declarative (a third animal)

Object oriented

Fixed set of operations (the functions tend not to change)

Primarily adding new things

Library code tends to be written in languages that are object oriented

Presenter
Presentation Notes
This is just a great description: http://stackoverflow.com/questions/2078978/functional-programming-vs-object-oriented-programming
Page 26: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Dicing onions

Functional

Define variables: knife, cutting board, bowl, vegetable = onion

Define functions: lift, peel, cut / dice, scrape

Easy to add new types of chopping methods

Object oriented

Define the characteristics of an onion: peel, layers, shape

Define methods: getting bag of onions, selecting one onion, dicing onion

Easy to add new types of vegetables / things to dice

Presenter
Presentation Notes
ADD: compiled vs. interpreted
Page 27: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Back to the EAD problem

Python code chosen: object-oriented programming import requests import json These are libraries of functions based on object

Variables such as string, array

Conditional logic / loop

Presenter
Presentation Notes
The object is so important here! Request object, JSON object – these are things that can be assumed and makes code easier to write.
Page 28: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Now it’s your turn! Practice, practice, practice

https://flic.kr/p/qN5Lvc

Presenter
Presentation Notes
https://flic.kr/p/qN5Lvc
Page 29: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Exercise 1

A real-world problem from Code4Lib

Compare answers!

Page 30: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Section 2 The Medium Dive

Page 31: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Strengths of various languages

Language Strengths Weaknesses

Java “Write once, run anywhere” Slow

C Speed Memory management

C++ Speed Clumsy?

PHP Hugely popular, great documentation, web programming

Inconsistent syntax, security issues

Visual Basic Powerful Only runs in Windows environment

Python Enforces best practices None?

C# Fast Really only suitable for Windows

JavaScript Only reliable way to do client-side scripting

Only useful with a web browser

Perl Powerful and fast Steep learning curve

Ruby Extremely object-oriented Slow

Presenter
Presentation Notes
The common question: what language should I learn? It’s always hotly contested, and there is no right answer. Handy writeup: http://www.english4it.com/unit/9/reading We’ll be writing today in PHP.
Page 32: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

But what about…?

“Language” Strengths Weaknesses

HTML You can’t display pages on the web without it!

Too much of a mix between “look” and content

CSS Powerful tool to separate content from layout

None

SQL Ability to query databases Complex quickly; only useful within a database

XML Powerful structural tool Difficult parsing

XSLT Designed to parse XML Procedural and recursive

XPATH Allows querying of XML files Steep learning curve

Presenter
Presentation Notes
These are some of the other buzzwords that you may have heard – they aren’t all computer languages, per se, but are ways that computers talk to each other.
Page 33: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Language choice vs. analysis

Syntax will vary

Available libraries* will vary

Your analysis will always prevail!

* Libraries code that has been written for you, allowing you to stop reinventing the wheel

Presenter
Presentation Notes
PyMARC as a library
Page 34: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Common syntax + structures

Output / print echo “Hello, world! Hello “ . $name . “!”;

Comparison statements (greater than, less than, equal/not equal to)

Conditional statements (if/then) if “FA” in resourceID: resource = resourceID[“id_0”]

Loops for (i = 0; i < 100; i++) echo “This is a FOR loop!”;

Regular expressions $pattern = “/\d\d\d\d-\d\d-\d\d/”;

Combine for your code!

Presenter
Presentation Notes
Can anyone guess what $pattern is looking for? What if we have an error? Introduce IDEs.
Page 35: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Example

“[A librarian] wrote a CoffeeScript that harvests ISBNs from a page of search results from the Blacklight discovery interface, grabs the corresponding cover image from Google, and enriches the results page with the images—all in a mere twelve lines.”

Let’s go to the code!

Presenter
Presentation Notes
“Success” is NOT “I found the book cover” but “I returned a value without error”. Last question: this is a post-server query – we’ll need JavaScript or something like that.
Page 36: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Questions

What information ties these systems together?

What does “success” look like?

Does it matter if I don’t have a book?

Where does my code have to “live” for it to work?

Related: what is Blacklight?

Presenter
Presentation Notes
“Success” is NOT “I found the book cover” but “I returned a value without error”. Last question: this is a post-server query – we’ll need JavaScript or something like that.
Page 37: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Writing out the problem

When a user queries my catalog, it would be nice if the user could see book covers.

Google has book covers that I can use.

I need:

The ISBN of the book

The URL pattern for Google

The ability to write out an image in my catalog

Page 38: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Pseudocode

if (search results > 0), then: for (each result): get the ISBN; go to Google’s API service; check if an image exists for the ISBN.

if (image exists): write out HTML image tag. else: write out a default image.

Page 39: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Diagram

Page 40: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Now it’s your turn! Practice, practice, practice

https://flic.kr/p/qN5Lvc

Presenter
Presentation Notes
https://flic.kr/p/qN5Lvc
Page 41: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Exercise 2

Use syntax and structure ideas to generate pseudocode to start solving the Code4Lib problem.

Page 42: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Section 3 The Deep Dive

Page 43: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Writing code For the next hour or so, we’ll be working through the example found in

your workbook.

http://pixabay.com/en/road-start-beginning-intention-368719/

Page 44: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Exercise 3

We’ll start writing code together

There are lots of questions in the file!

Compiled code and environments

WAMP = windows, apache, mysql, php

IDE = integrated development environment (Eclipse)

CodeAcademy (www.codeacademy.com)

Page 45: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Exercise 4

Putting it all together

Does our code work?

Page 46: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Other thoughts…

HTML/CSS

Writing out report

Adding additional information

What would YOU like to see in this program?

Page 47: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Applying your knowledge

Page 48: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Getting the most out of your system

Content Management Systems

LibGuides

MarcEdit

Others

Know what they do and how they do it!

Presenter
Presentation Notes
“How you know the problem is solved:” will the problem happen again? Are you looking at a workaround, or a solution?
Page 49: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

How to make an IT call

Understand your problem, as best as you can

Pay attention to: When the problem happens (is it predictable? timed?) How to recreate it What you’ve already done to solve the problem How you know the problem is solved

Beware and be patient: https://xkcd.com/806/

Presenter
Presentation Notes
“How you know the problem is solved:” will the problem happen again? Are you looking at a workaround, or a solution?
Page 50: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

We’ll do this exercise together…

Hi all, I just created a new multisite instance in my production setup, and there are some weird things happening. I'm hoping you can help. Here are the issues: • I created a new site, inscriptions.digitallibrary.vassar.edu. All went well. This is a Drupal 7 / Islandora 7 site. • I can ingest objects perfectly fine, and they report that they are part of a parent collection, Inscriptions (inscriptions:root). E.g.,

see: http://inscriptions.digitallibrary.vassar.edu/islandora/object/inscriptions:1 • None of the objects that I ingest are listed on the parent page

(http://inscriptions.digitallibrary.vassar.edu/islandora/object/inscriptions:root). • Side effect: I can ingest objects into my other Drupal 7 site, einstein.digitallibrary.vassar.edu, but the same thing happens --

they don't show up in the collection that I specify as parent. • Interestingly, when I log into my Drupal 6 site (digitallibrary.vassar.edu), I can see the "inscriptions" collection there, but not

the Einstein ones. I'm not sure what I did wrong -- I first did this in our staging area, and everything went well, once the Drupal filter was set correctly. To add to the complexity -- when I enabled my Islandora modules, the default Audio, Book, etc., collections showed up in my D6 + D7 instances. I'm really surprised at all of this, because things went so well in staging. None of these problems occur -- I can ingest without any issues, none of the collections seem to show up where they shouldn't, etc. I feel like the production things haven't divided up as well as they should. Complicating this, of course, is that my Einstein collection is a grant-funded one whose donors would like to see only their supported stuff show up, and I'm afraid that I'm going to delete something that is going to make that site go ka-boom. Thanks very much for any insight you can provide! Joanna

Presenter
Presentation Notes
This is a good example of how to report things. I won’t be offended if you don’t want to know how the story turns out.
Page 51: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

When to call a pro

Cost/resources

Do you know how to solve the problem? Do you know enough to be

dangerous/security issue?

Have others tried to solve it?

Time

Do you have time to solve the problem?

Do you have the time to acquire the skill set to solve the problem?

How complicated is your issue?

Page 52: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Writing an RFP/RFI

Excellent resource: TechSoup’s RFP Library http://www.techsoup.org/support/articles-and-how-tos/rfp-library

General tips: http://www.techsoup.org/support/articles-and-how-tos/overview-of-the-rfp-process

Major consideration: scope creep!

Project One Pager: http://www.slideshare.net/tsierra/the-projectonepager

Page 53: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Now it’s your turn! Practice, practice, practice

https://flic.kr/p/qN5Lvc

Presenter
Presentation Notes
https://flic.kr/p/qN5Lvc
Page 54: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

Exercise 5

You have a problem.

You have some money.

You need to hire someone.

What do you do?

Page 55: Programming Languages: An overview for librarians · like Drupal, LibGuides, and MarcEdit What skills are important to put on an RFP or job description. Reasonable limits – when

References

English4IT. “Top 10 Most Popular Programming Languages.” http://www.english4it.com/unit/9/reading.

Peters, Chris (2011). “An Overview of the RFP Process for Nonprofits, Charities, and Libraries.” 2011 May 10. http://www.techsoup.org/support/articles-and-how-tos/rfp-library

Serra, Tito (2011). “The Project One-Pager.” SlideShare presentation. http://www.slideshare.net/tsierra/the-projectonepager

Trautman, Erik (2015). “Why Learning to Code Is So Damn Hard.” Viking Code School Blog, 2015 Feb 24. http://www.vikingcodeschool.com/posts/why-learning-to-code-is-so-damn-hard

Yelton, Andromeda (2015). “Coding for Librarians: Learning by Example.” Library Technology Reports, 51:3. http://dx.doi.org/10.5860/ltr.51n3