Monday, July 26, 2010

Tim Bray reflection

Tim Bray reflecting on Andriod Hands-On:

"This event was a little bit controversial inside Google. The Android leadership (appropriately) includes people with strong consumer-electronics experience; it wasn't obvious to them that all these
open-source hippies constituted a good potential pool of mobile-app
developers.

Personally, I can't imagine a better one. We'll see if I'm right; in the
meantime, my most sincere thanks to the skeptics who gave this a chance, to David McLaughlin for marshaling resources, to Roman Nurik, Justin Mattson, and Dan Galpin for their teaching, and especially to the other Googlers and O'Reillyans who rallied around and made the not-fully-thought-through logistics run smooth."

http://www.tbray.org/ongoing/When/201x/2010/07/25/Five-Photos-of-OSCON

Saturday, July 24, 2010

OpenOffice.org Lessons Learned

Link to OSCON page.

openoffice.org

  • at first most considered openoffice.org a minor annoyance

    • wasn't popular at Sun as it undercut StarOffice

  • an alternative to a life of licensed software

  • focus on end-users

  • changing legacy software mindset

    • move away from monolithic structure

      • “let's cram as much crap into our software as possible”

      • difficult to refactor

    • focus on open data formats

    • ODF standard

      • make open source/standards/formats more palatable to governments and corporations

  • focus on extensions

    • allow non-core development


creating a community

  • requires a central focus

    • the easiest way is to have a common enememphasize the virtues of what you're doing

  • develop a product strategy

    • how do we encourage adoption

  • lower the bar of entry for contributing

    • don't just focus on developers

  • face-to-face meetings

  • architecture shapes community participation

    • monolithic structure limits participation

      • getting new developers is difficult

    • modular structure encourages participation

  • ecosystems

    • created around extensions, services, and support

  • education

    • need new developers

    • new developers need to be taught how to code and how to contribute

      • not a bunch of untrained developers slowing the process

      • the mythical man-month (throwing more developers at a project does not decrease development time)

Project Documentation

Link to OSCON page.

What is documentation

  • first contact with a user

  • source of education

  • front line of suppport

  • consists of

    • conceptual material

    • “how-to”

    • reference material

    • troubleshooting

  • communication with people who care about your project


Things to avoid

  • Perfection

    • release early and often

  • forgetting that your audience is people


qualities of solid documentation

  • complete

    • covers all features, usage modes, and interfaces

    • answers essential questions

      • who what where

  • correct

    • should match the software, hardware, or device

    • logically organized

    • consistent and professional

  • appropriate

    • know who your audience is

      • know what they need to know

      • answers their questions

    • accessible

    • consistent and professional

  • what is less important

    • text formats

    • tools

    • delivery format

      • consider mobile devices

    • perfection

  • what is not solid

    • missing unmentioned features

    • inconsistent

    • unprofessional

      • grammar, spelling, etc


classical elements of technical documentation

  • concepts – what?

    • The 10,000ft overhead view

    • overview

    • brochures, white papers

    • architecture guides

    • focus on education

  • Tasks and examples – how?

    • The 10ft overhead view

    • step-by-step guides

    • quickstart guides

    • tutorials

    • training materials

    • focus on usability and consistency

  • Reference

    • the 0ft view

    • system reference manuals

    • API guides

    • layout and manufacturing guides

    • maximal cross-references

    • focus on completeness

  • troubleshooting

    • the -6ft view, looking up

      • when you get here, you've dug yourself in a hole

    • step-by-step diagnostics

    • flowcharts

    • FAQs

    • from the reader's perspective

    • focus on answering questions


readers you must satisfy

  • partners

    • sell, extend, promote, or add value to your project

  • developers

    • use your project as a basis to start they're own project

  • internal

    • inside our organization

  • end-users

    • use the end result (and sometimes pay for the privilege)

  • community

    • care about your product by choice


critical questions about documentation

  • what is it

  • why do I need it

  • what does it look like

  • who's going to make it

  • where do I put it

  • when do I schedule it


good documentation habits

  • be proactive

  • begin with the end in mind

  • put first things first

  • think win/win

  • seek first to understand, then be understood

  • synergize (buzzword alert)

  • sharpen the saw (practice)


Veracity

Link to OSCON page.

sourcegear.com/veracity

ericsink.com


Opensource (Apache v2), current version is v0.3


DVCS advantages

  • fast

    • everything is local

  • cruise ship

    • disconnected operation

  • moscow

    • distributed teams

    • offshoring

  • dell

    • scale out instead of up

    • no need for $$$ servers

    • add another dell

  • lego

    • complex processes


Trend is toward integration; this doesn't work well with dvcs

  • bug tracking

  • wiki

  • etc


Other solutions

  • ditz

  • tcgit

  • git-issues

  • Bugs Everywhere


Veracity

  • decentralized database

  • template driven merge

    • automerge based on rules in the template

      • Json (json.org)

      • automerge is correct if the template defines it to be correct

      • possible to define a template such that automerge never fails

      • log of automerge changes

      • conflicting changes

        • two people modify the same record and field

          • most recent

          • highest value

          • resolve by group (dev vs qa)

      • unique constrains

        • GUIDs

          • concatenate a level 1 UUID and level 4 UUID

          • not a friendly id

        • uniqify

          • on merge, if a merge result violates unique constraint, the template defines the resolution

        • create friendly ids, then uniqify if necessary

          • userid + incrementing integer

          • if conflict, increment integer again

Friday, July 23, 2010

A tool for Integration Testing

Why Unit Tests Aren't Enough
Trotter Cashion
QA is an O(n^2) problem
Cucumber – an integration testing tool
Written in Ruby; usable beyond Ruby
Stories are written in natural language
This allows you to think in a natural language

Practical Concurrency

Practical Concurrency
Tim Bray (Google)
On his work with concurrency before recently joining Google
Wrote an Android App called lifesaver that copies call logs and SMS to and sd card
“Application programmers should not use threads”
“Application programmers should get the most out of modern computers”
Functional programming may be the answer
Haskell, Erlang
Virtues of the two
Closure - Lisp that works on JVM
*my brain hurts*
Closure: actor model
Erlang: process model
Unit testing is hard with Closure
Unit testing is easy with Erlang
Question about OpenMP: “Parallelism and concurrency is different!” what?!?!?!?!

Friday Keynotes


Friday Keynotes



The State of Open Source, Chris Dibona
Google Code search Crawl
40m unique files
3b loc (an admitted bad measurement)
Showed license use over time 2008-2010 – people are leaving minority licenses for GPL, BSD, Apache
Showed language use pattern: c, c++, java, scripting, fortran
The most prolific developers:
- RMS or Torvalds - RMS
- Juno Hamano (Git) vs Greg Stien (SVN) - Hamano, he is a machine

Mayor of Portland, Sam Adams
“America's open source city”
City has a mandate to open their code and data
Welcomes everyone to move their business to Portland
Open source: licensing, access to source code, willingness to collaborate
30-40 layers of government just in this city (others are like it)
“Civic apps”
Welcome to move family and business to Porland

Thursday, July 22, 2010

D, AmbientTalk, and Perl

D Programming Language

For system and application programming.
Large language.
Multi-paradigm: including functional, metal programming (assembler), the commonly used paradigms (OO, procedural), plus other paradigms
D can directly call any C function.
D matches C's ABI better that C++ does.
Functional programming = no mutual state.
A wickedly smart C++ meta-programming expert wrote the Generic paradigm of D.

AmbientTalk Programming Language

Scripting for mobile platforms
OO, Functional
Concurrent, distributed
Reflective
JVM, Android

State of the Onion
Larry Wall (Creator of Perl)

Painful for a non-Perl programmer...

Good and bad practices from the Linux Kernel open source project

Good and bad practices from the Linux Kernel open source project
James Bottomly (one of Linus Torvalds lieutenants)

Part of the motivation for Linux: even BSD code was hard to get outside the US
Founding: freedom to redistribute and contribute
Linus dislikes the 'cult of personality' associated with some open source projects
Not tracking the origin of contributions from the beginning is a lesson learned
Kernel developers try really hard to do development in the open
All patches should always first should go over a mailing list (a few have not)
“Even the best open source companies would, one in a while, like to keep code hidden until the product releases – classic example is Google with Android”
“There are sound reasons business reasons for doing this”
A transparent open dev policy creates a client of equality, trust, and franchise
Single committer model – “the Linus doesn't scale problem” … enter Bitkeeper
DVCS proved to be the solution
People who merged entire trees became Lieutenants
Solidification of the Maintainer Model
April 2005 – The Bitkeeper Blowout – Git was born
All of the Lieutenants at this time starting to working on Git (and Mercurial even)
They replicated the functionality of Bitkeeper in 3 months
Mercurial principles are similar to Bitkeeper; Git is much different
June 2005 – Git became stable enough to host Linux Kernel development
Mistake in Kernel development: Odd is Unstable version numbering scheme
Should have (and now does) a release early, release often model
The Linux Culture … a meritocracy
A negative: “Code costs effort to produce but Criticism is free”
People follow be example: some lieutenants flame a lot
Surviving the Critical Culture – learn who to listen to and who not to listen to (just watch the list)
People who only criticize and never contribute are not trusted by the community
LKL list (only 2 of 30 lieutenants still even read it – look for the smaller lists)
Advise on identifying mentors: look at contribution record, sometimes can be abrasive (nerd social ineptness)
Git cred: git log | grep
Conclusions:
- Full openness brings problems (but they are outweighed by community it creates)
- Ownership create franchise (conversely copyright assignment creates inequity)
- Mailing lists can be rough places, particularly with a critical meritocratic cultures
– To survive them, learn who the trust

The Desperate Perl Hacker





So I was confused by the "Desperate Perl Hacker" badge labels at OSCON. Why are we desperate? Is there something I should know?

The explanation I was given was that during the XML planning sessions, one of the requirements was that the spec should be implementable by a desperate Perl hacker in one weekend.

The Go Programming Language

http://golang.org/
Something to investigave.

K-9 Android Email App

K-9 Android Email App
Jesse Vincent (K-9 App Author)
Aside: on experiences of getting a Tmobile G1, downloading an early SDK, submitting a patch to Google, et al.
Very interesting stuff, eg: back then Google's internal Android repo was Perforce!
K-9 has been on the Android Market for a long time
Has been painful to keep support 1.6
Stuff learned last nite has already made it's way into K-9
Aside: When mentioning Subversion “I wish
No test suite (<--- an opportunity!)
Aside: Android Java is very easy to use, and useful

Perl Sessions

Wednesday was my Perl session day, so here's a glob of the 4 sessions I attended.

New Beginnings in Perl 5

Why switch to Ruby?

  • Got fed up with jumping through hoops

  • for example, unrolling @_

    • my ($arg1,$arg2) = @_

Why come back

  • use MooseX::Declare

  • use TryCatch

  • cpanm

  • NYTProf

  • Test::Class::Sugar

“Language design is premature optimization”



What's New in Perl 5.12


Perl5 is 16 years old (!!)

New CPAN goodness

  • Moose

  • Plack

  • cpanm

  • Devel::Declare

  • AnyEvent

  • Devel::NYTProf

Perl6 is a completely different language from Perl5

  • Perl5 and Perl6 are different versions of Larry's brain

  • rakudo.org

  • perl6 will not replace Perl5

What's new in Perl 5.12

  • 5.10 is not too new to use anymore

  • use 5.12.0 use strict

  • deprecations warn by default

  • suidperl is dead

  • Y2.038K compliant

  • DTrace support

  • sub do_something{...}


Perl 6


Perl 6 language specification

  • separate from implementation

Perl 6 implementations

  • Rakudo

  • Pugs

Rakudo *

  • early adopter distribution of Perl 6


Profiling Perl with Devel::NYTProf


Subroutine

  • Measures time spent in a subroutine

Statement

  • measure time from one statement to the next


Output

  • kcachegrind

  • HTML

  • Tree Map

  • DOT file (graphviz)


Exclusive time

  • Time spent executing statements in the current subroutine

Inclusive time

  • Exclusive time + time spent is called routines



Wednesday, July 21, 2010

Android Hands-On - literally!

Android Hands-On












by several Googlers:















Android phones were handed out like candy.

(a bit dated, but still good)

http://developer.android.com (for app development)

Agenda
- What make a great app?
- UI design tips
- Developing REST client apps
- Porting existing C codebases
- Lots of Q&A time at the end

What make a great app?
Roman Nurik
1) Speed, responsiveness
- Use AsyncTasks and Services
2) Quality/Polish
- Clean, flexible, beautiful UI
- Feature completeness
- Stability and error resilience
3) System UX integration
- Widgets, notifications, live folders, Quicx Search box, accounts, sync, etc
- Intuitive and correct navication, proper use of back, menu, search buttons
Bonus: Cross-app integration
- Exposing public intents, content providers, URL schemes, etc

User Interface Design Tips
1) Dos/Dontshttp://oscon2010.blogspot.com/2010/07/android-what-wherefores.html
- Don't simply port from other platforms
- Do create versions of all resources for high density screens
2) Design philosophy and considerations
- Choose clear vs. “simple”
- Content vs. chrome
- Enhanced by the cloud
- Design considerations: screen size, screen density, portrait/landscape, primary ui interaction method, keyboard
3) UI framework features you should definitely be using
-
- Resource qualifiers: ie res/layout, res/layout-port, res/layout-land, res/layout-large-port, res/layout-large-land
- patch drawables
4) New UI design patterns
- introduced in last google i/o talks
- dashboard, action bar, quick actions
5) Icons
- http://j.mp/androidfun for some icon ideas

Official Twitter app was developed by Google. Will be open sourced. No timeline on this.

The Google I/O conference app is still available in the app store. Source is available at: http://code.google.com/p/iosched

Developing REST client apps

1 min. intro to REST

Native REST Client vs. Mobile Web App
- Deep system integration (ie, contacts, sync UI)
- Can run in the backgroud, sync on a schedule
- Potential faster – binary formats
- Some things aren't yet possible with HTML/JS (eg, taking a photo)

Implementing REST
- do data operations in a service, not an activity

Thress design patterns to handle
1) Service API
2) ContentProvider API
3) ContentProvider API with SyncAdapter

Intermission: Android YouTube Commercials

Why SVG isn't supported (yet):
- rather expensive from a storage perspective
- not many websites use it currently
- it might be in foryo

Porting C codebases to Android

Native Code whys:
- Existing C/C++
- HPC
- OpenGL EL 2.0 (in Android)

NDK
- c library
- math libs
- minimal c++ (stl port)
- logging in android
- zlib
- jni graphics
- new in 2.2 (ndk debugging on retail devices)

Using JNI (Java Native Interface)
- public static native void …
- plain 'old JNI can be used

Case Study: Audio Processing and Mixing

Case Study: Driving Android Display from Native Code

Showed a demo of a C (and OpenGL) version of Tetris on a Nexsus One

OSCON shirts

Veracity: DVCS

I spoke to a guy from SourceGear today about Veracity. It seems like a tool to watch. They are looking at mapping DVCS concepts to databases, request trackers, and so on. He said they will have a library version as well. No stable API yet though. Also sounds like they have a working distributed request tracker right now. 

Sound promising.

http://sourcegear.com/veracity

Nexus One

r0ml

(insert notes here)

Android: The What & Wherefores


Dan Morrill (Google)
Android project manager

This talk is about Android as an open source project.

Agenda
First things first
Project overview
Tools and tallies

First things first
What we mean by open:
Quote from source.android.com “No central point of failure...”
“I disapprove of what you have to say, but I will defend to the death you right to say it/.” Evelyn Hall
Before Android there were gatekeepers on getting mobile apps on devices.
Google has a very liberal for getting apps on the Android Market (similar to getting a video on YouTube)
Omitted: security, fraud, illegal, copyright

Project overview

Overall Goal: Improve App User / Developer Expirence

ASOP – Android Open-Source Project
Not a distro; a single corpus of software
Apache License 2.0 (mostly)
Partially non-public development process
Open for any use … but to join the eco system you mst be compatible.

Why Apache Licence?
It's close to BSD. Patent clause.
Why not GPL: OEMs should be free to keep their changes
There are some GPL s/w, like Bluetooth and Webkit, in Android

Who a partially non-public development process
(two source repos – one internal to google and one on soruce.google.com)
- We're defining a platform as we go
It we do this in the open, people WILL shop early
We simple can't afford inconsistent API implementation
Contrast with HTML5, where platforms are already defined
- It's necessary to complete
We're not a software project, we are a consumer electron project.
Margins are small; competition is fierce; mindshare is king.
Splashy launches and campaigns are How It's done.
- Private development actually not ENTIRELEY true...
kerenal dev done (almost) entirely in the open
SDK compatibility Test Suite recent moved open-source
NDK is moving open

Balancing open source with platform integrity
Compatibility is a BIG issues

Tools and tallies
Uses git for SCM
Uses repo for cross-git-project automation (a big shell for loop)
Uses gerrit for our review-before-commit process (see review.source.android.com)
Also see code.google.com/p/gerrit

kernel.org is really good and globacl git hosting
OSUOSL.org is really good at hosting Java apps

See source.android.com/source/life-of-a-patch.html WOW

Demo of submitting a patch.

Note to self: try gerrit

AOSP on Devices
Up through Eclair, it was hard

Numbers
40 company, 4000 users
1000 contributions
80% acceptance rarre

Larry broke out the stamps when asked for his autograph

Chris meets Larry Wall, Pearl creator

Tuesday, July 20, 2010

Faster Python Programs through Optimization

Presenter: Mike Mueller (Python Academy)

Sample code and exercises available here. Slides have not been posted yet; I'll update when available.

Premature optimization is the root of all evil – C.A.R. Hoare

Knowing when optimization is premature defines the difference between the master engineer and the apprentice – via Twitter

Guidelines:

    • make sure your program is actually slow

    • don't optimize as you go

    • only realistic use cases should be considered

    • architecture can be essential to performance

    • check for bugs that slow the program down

    • find bottlenecks using profiling

    • always check the results of optimization with unit testing

The greatest speedup is usually achieved by optimization of algorithms

External causes

    • network

    • database

    • system calls

Measurement

    • Measuring in stones

      • test.pystone

      • a single core of my C2D laptop gets ~24k stones/second

    • Profiling CPU usage:

      • cProfile

      • pstats

    • Profiling memory usage:

      • Guppy_pe

Algorithms and Anti-patterns

  • String concatenation

    • use lists and ''.join(list) to create large strings

  • list generators

    • l = [x * x for x in range(10)]

    • sum(x * x for x in range(10)

    • g = (x * x for x in xrange(10))

      • g.next()

      • list(g)

  • data structures

    • sets vs lists

      • use sets instead of lists if performing membership tests

      • if order matters, create a set from your list

        • this has a cost, so weigh set_creation_cost vs list_search_cost * number_of_searches

      • use set.intersection to for intersection tests

    • deque vs lists

      • use deque (doubly-linked list) instead of lists for faster inserts

      • deque has a higher index access cost

    • dict vs defaultdict

      • defaultdict is faster for larger data sets

  • Python big-O

    • O(1)

      • len(list)

      • len(dict)

      • list[i]

      • del dict[i]

      • x in dict

      • x in set

      • list.append(i)

    • O(n)

      • loops on lists, strings, sets

      • string methods

      • x in list

    • O(n log n)

      • list.sort()

    • O(n^2)

      • nested loops

    • O(n^3)

      • nested nested loops

  • Caching

    • Reuse before you recalculate

    • memoization

    • deterministic caching

      • eg numerical results that are always the same for the given inputs

    • non-deterministic caching

      • expiring cache

      • eg caching of database queries

    • Memcached

  • JIT compilation

  • Numeric libraires

  • Parallel

    • Python 2.6 – import multiprocessing

    • Python <>

      • Using both cores, my laptop gets ~45k stones/second

Design Patterns in Python

Alex Martelli (Google)












The Facade DP – provide a controlled subset of functionality to a client. Most Python libraries are facades. Layers on top of bigger packages.

An explanation of basic DPs.

There are other patterns...











This talk is about Pythonic Patterns

Singletons in Python … use a module instead of a class. They are inherently singletons, you can use it one time.

The Canceled Perl Session

The Mastering Perl session was canceled, but the presenter has uploaded his slides. I'm disappointed about missing this one, but the DTrace session turned out to be pretty interesting.

Python AppEngine

Google's Python AppEngine
Ikai Lan (Google)


Hands on will need:
Python 2.5.x

In attendance also from Google:
Shawn Lynch (sp?)
Alex Martell (sp?)
John Modell (sp?)

DiveIntoPython.org <-- Online book; 30 min proficiency in Python

App Engine – Google's tool for writing quick webapps that run on their systems at Appspot.com.

Write App Engine code (see my public git repo at http://github.com/jcalahan/appenginetest)

Run it with:
~/google_appengine_1.3.5/dev_appserver.py

View it with:

http://localhost:8080/_ah/admin/ <-- Local admin console

Morning Dew

Chris found his morning mountain dew!

Monday, July 19, 2010

The Productive Programmer

Presenter: Neal Ford (ThoughtWorks)

The Productive Programmer session was based on the book The Productive Programmer, presented by the author. Below is a quick outline of the session. I'll be honest, this session was kind of long and I may have nodded off in a couple of places.

The slides have not been posted yet; I'll try to remember to update this post when they become available.
  • Mechanics

    • accelerators

      • typing is faster than navigating

        • use gui tricks to minimize mousing

      • multiple clipboards

      • pushd/popd

      • command line/file explorer integration

      • use shortcuts instead of menu entries

      • templates/macros

    • focus

      • ergonomics

        • get a comfortable chair

        • dual monitors

        • good keyboard/mouse

      • developers should have root

      • war rooms instead of cubicle farms

      • locus of attention: The Humane Interface by Jef Raskin

        • pop-ups/distracting dialogs

          • screen dimmers

        • internet/games

        • instant messaging/email/twitter

      • maintain concentration

        • turn off notifications

        • don't keep email open

        • turn off instant messaging

        • put on headphones

        • create office “quiet time”

      • the higher the level of concentration, the denser the ideas

      • focus techniques

        • search > navigation

          • replace file hierarchy navigation with search

        • rooted views

        • use virtual desktops (virtuawin)

    • Canonicality

      • define things once

    • Automation

      • obvious

        • one-command build

        • continuous integration

        • version control

        • documentation

      • tools

        • automated interaction

      • to automate or not

        • set a time box

        • analyze the ROI

          • time_for_task * times_repeated > time_to_automate

        • don't shave yaks

  • Practice

    • composed method

      • divide your program into methods that perform one (and only one) identifiable task

      • strip generic code out to new methods

    • test driven development/design

      • creates consumption awareness

      • forces mocking of dependent code

    • static analysis

      • cpd – copy/paste detector

    • citizenship

      • bunch of java stuff (ZZzzZzzzzZzZzz.....)

    • yagni (you ain't gonna need it)

      • build what you need now, don't indulge in speculative development

      • increases software entropy

      • don't need frameworks for everything

        • Avalon is a framework for building frameworks

    • question authority

      • that's the way it's always been done

      • know when to break the rules

      • non-intuitivity

        • pair programming

          • produces code 15% less efficiently than two programmers working independently, but with 15% fewer defects

    • single level of abstraction principle

      • keep all code of a method at the same level of abstraction

    • polyglot programming

      • leverage existing platforms with languages targeted at specific problems

      • many different languages that compile down to JVM byte-code

      • not “resume driven development”; the right tool for the job

    • every nuance

      • learn all the “back alleys” of your chosen language

      • $1000 plumber: $1 dollar for closing a valve, $999 for knowing which valve to close

    • anti-object

      • ?? (ZzzZZzzzZZZzzzzz....)

DTrace Hands-On

Presenter: Angelo Rajadurai (Oracle/Sun)

The full tutorial is available here, or you can grab the OSCON slides here. There is also a Google group set up here.


Why DTrace

Some performance issues only show up in production and DTrace allows you to perform live instrumentation in a production environment. DTrace doesn't require a debug binary or access to source code. The instrumentation can be performed on demand and you can probe any arbitrary location. Active DTrace probes require little system overhead, and disabled probes require no overhead.

Simple Example

% dtrace -P syscall'/execname==”java”/{@[probefunc]=count()}'

This tells DTrace that you want to use the syscall probe to count the number of system calls made by the 'java' executable.

D-Scripts

More complex setups are easier served using scripts. DTrace uses it's own scripting language called D-Script. The simple example above is actually a simple D-Script. More complex D-Sripts will allow you to introduce variables, stack multiple probes, and format output.

DTrace Patterns

Event Trace: Basically printf() debugging. Good for rare events, but gets very expensive. One thing I discovered today is that printf() performs ~2400() system calls to print a string.

Count: A collection or summary of events. The simple example above is uses the Count pattern.

What's In Between: Traces everything that happens between two events (eg function entry/exit).

Time Spent: Performance profiling. Find the amount of time spent in a function.

Profile: A polling probe that takes a sample over time to create an overview.

Gotcha's

Probes do have a performance impact. This is usually small, but it possible to unintentionally cripple a production system. DTrace contains a “killswitch” that should prevent you from completely killing the system.

DTrace only provides probe results. It can't tell you what to probe, or interpret the probe results. It's just an instrumentation tool.

General Approach

  1. Define problem

    1. program foo is running much slower on Wednesdays

  2. Verify “known” conditions

    1. “It can't be the disks, we just replaced them”

  3. Attempt to reproduce the problem.

    1. If the problem can't be reproduced, it can't be instrumented

  4. Isolate the problem

    1. CPU, I/O, Network, etc

  5. Determine if other tools are more applicable

    1. Vendor supplied instrumentation packages

Android 101












Android for Java Developers
by Marko Gargenta

10 people last year at this talk at OSCON. This year: 100+

Writing an O'Reilly book: Learning Android.

Agenda
The Stack
Android SDK
Hello, World
Main Building Blocks
Android User Interface
Operating System Features
Debugging
Summary

The stack … good overview. See the graphic at http://developer.android.com/images/system-architecture.jpg.

Android Software Development Kit (SDK) … overview of what is included.

Using Eclipse is pretty standard but you don't have to. Android SDK included many command-line tools that integrate well with other Integrated Development Environments (IDEs).

SDK includes AVD Manager, a tool for creating Android Emulators. Version 1 of the SDK was released without any Android hardware (like the G1, Droid, Incredible, etc). Emulators can be created for many combinations and permutation of hardware abilities. For example: an emulators that doesn't have a camera, gps chip, et al. Can create mock sd_cards, etc. DDMS perspective in Eclipse can simulate GPS position, phone calls, SMSs, et al.

Review of $HOME/.android
ls avd
cat avd/.ini

Hello, World”

(Basically going over: http://developer.android.com/resources/tutorials/hello-world.html)
http://www.google.com/
Created a “Hello, OSCON” project in Eclipse

Review of what was created

~/workspace/HelloOSCON> ls
AndroidManifest.xml
assets/
bin/
default.properties
gen/
res/
src/

R.java is the glue between Java and XML. Bascially a bunch of pointers.

Review of Eclipse Android XML creator, for strings.xml for different languages, layout.xml for landscape views, et al.
http://www.google.com/
Review of /bin - .classes, .apk, et al.

The adb tool.

$ adb shell
$ ls
$ ps
$ adb --help
Android Debug Bridge version 1.0.26

Main Application Building Blocks
(The meat of the talk)

Activities – roughly, the screen.
An activity is to an application what a web page is to a website. Sort of.
Usually have a main activity.
Typically requires lotes of memory, processor needs.
One running at a time with many sleeping
How/when onCreate() gets called.

Intents – represents events or actions.
Like HTML hyper-links between webpages. Sort of.
Can be implicit or explicit.
See the Home application sameple.
The home button sends a “home” intent.

Services – a piece of code that runs in the background. No UI.
Well defined lifecycle.
Usually much lighter on resources than activities.

Content providers – interface to shared data between applications.
Content URI, insert(), update(), delete(), and query().
Android built-in examples: contacts, settings, et al.

Broadcast receivers – an Intent-based publish-subscribe mechanism.
For example: when an SMS arrives.

A review of his MyTwitter app to ties together all the building block consepts.

Android User Interface

Procedural: in Java
Declarative: in XML
Best approach uses both.

Hands-on developing a layout.
Views and Layouts
Linear Layouts...
Android units: dp (density-independent pixel)
dip (synonym)
sp (similar but also scaled by user for fonts)
In layouts, the order of siblings matters.
Layout weight property
“...” in the property editor in Ubuntu Eclipse is buggy

Write a little gui with Eclipse, main.xml
Connected with this Java:

package com.blogspot.oscon2010;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class MyTwitter extends Activity implements OnClickListener {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
EditText editTweet;
Button buttonUpdate;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Find the views
editTweet = (EditText) findViewById(R.id.editTweet);
buttonUpdate = (Button) findViewById(R.id.buttonUpdate);
buttonUpdate.setOnClickListener(this);
}
public void onClick(View view) {
Log.d("Twitter", "Button clicked");
}
}

$ adb logcat # for viewing log via command-line

Summary...

Distributed Version Control

Watch out Git, here comes Vereacity...

Sights

Headed down...
Outside...
There!...
Inside...
Sad Chris...