Not Invented Here: Things Rails Didn't Innovate

A presentation at Scottish Ruby Conf 2014 in May 2014 in Perth, UK by Caleb Hearth

Slide 1

Slide 1

Things Rails Didn’t Innovate Not Invented Here Thank you for coming. We’ll be talking about things Rails has not innovated.

GO FUCKING SLOW

Slide 2

Slide 2

Caleb

Thompson Before we get too far, Let me introduce myself: my name is Caleb Thompson

I’m a developer working in Ruby on Rails for a consultancy who specialize in web and mobile application design and engineering.

We build other people’s ideas.

Slide 3

Slide 3

We'll talk a bit about Rails

Slide 4

Slide 4

But that's my elevator pitch the thing that got you into this room with me instead of Matt Wynn

Slide 5

Slide 5

The point:

Slide 6

Slide 6

You can be more effective

Slide 7

Slide 7

at your job

Slide 8

Slide 8

by not innovating

Slide 9

Slide 9

Rails didn’t really invent much at all. The thing is, Rails didn’t really invent much of anything.

Slide 10

Slide 10

Its success is just a matter of execution and delivery The success of the framework has been based on its execution and delivery.

Slide 11

Slide 11

Not that sort of execution. No, not that sort of execution.

http://boisdejustice.com/History/Brugge1862.JPG

Slide 12

Slide 12

Great ideas brought together in new ways

Slide 13

Slide 13

How we got here

Slide 14

Slide 14

http://globalcitizenblog.com/wp-content/uploads/globalcitizen/railroad_tracks414.jpg

So let’s talk about the history of rails.

Slide 15

Slide 15

In around 5000 BCE, the first wheeled vehicles were invented in Sumeria.

They used a technology that may have been around since 9000 BCE but certainly since 6500BCE - the wheel.

Wheeled vehicles were not widely used for thousands of years - this is because they required relatively smooth roads to be effective.

Slide 16

Slide 16

http://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Ridgeway_mongwell.jpg/800px-Ridgeway_mongwell.jpg Around the same time - 5000 BCE - The Ridgeway began to see use.

The Ridgeway is the oldest road in Britain and has been in regular use since before the Bronze Age.

You can see why this isn’t an ideal road for wheeled vehicles - narrow, unpaved.

Slide 17

Slide 17

The first constructed roads were either in Ur or somewhere in the Indus Valley Civilization.

In 4000 BCE they were planning their cities around grids of paved roads.

This technology probably allowed the Indus Valley Civilization to become the most widespread in its time, covering most of what is now Pakistan and northwestern India, Afganistan, and Iran.

Slide 18

Slide 18

By 3000 BCE, simple carts with wheels had been evolved from an earlier sled made of two pieces of wood joined together to allow things to be carried by dragging.

Slide 19

Slide 19

http://www.rottentomatoes.com/m/paul_blart_mall_cop/news/1791902/box_office_guru_wrapup_paul_blart_segways_ahead_of_the_competition/ A couple hundred years later, we begin to see two wheeled chariots.

These were hauled by onagers, which are related to donkeys, and it is the first time we see animals pulling wheeled vehicles.

Slide 20

Slide 20

http://www.deccanchronicle.com/130501/sports-motor-sports/gallery/sportstars-and-their-four-wheeled-chariots Around 2500 BCE we see very heavy four wheeled chariots.

These were heavy enough that they were not in regular use because of poor roads and we see them primarily near farms.

Slide 21

Slide 21

http://www.bigredcollective.com/corduroy-road-1 This leads us into the need for sturdier roads.

While these were certainly less effective than the paved roads we saw in Ur and the Indus Valley Civilization, in Glastonbury, England we start to see corduroy roads circa BC 3300.

Courduroy roads are roads built by joining together logs and are typically used for crossing shallow bodies of water, flattening dips in paths, or muddy areas.

Coruroy roads improve roads slightly, but are a hazard to heavy animals such as horses or oxen as the logs shift under weight.

Slide 22

Slide 22

http://upload.wikimedia.org/wikipedia/commons/6/63/AlaskaHWY.JPG As an interesting aside, one of the highways in Alaska - where I grew up - is built on top of a corduroy road buried in soil so that it decays slowly.

They just paved right over the corduroy road, using it as a foundation for the more modern road.

Slide 23

Slide 23

http://www.dailymail.co.uk/sciencetech/article-2218396/The-modern-Stone-Age-familys-cutlery-Designers-recreate-ancient-tools-using-modern-materials-techniques.html Back to more primitive roads, by 2000 BCE stone cutting tools made paving much easier.

It meant that even small local roads could be paved, meaning that vehicular transport became vastly more e ffi cient and widespread.

Slide 24

Slide 24

http://huskertim27.deviantart.com/art/Minotaur-road-rage-260878537 Around this time, Minoan Greeks paved an unprecedented 50km road from Knossos to Gortyn.

This road is the first time that we see regular transport of good and people across such large distances.

Slide 25

Slide 25

http://vimeo.com/43222290 In the 5th century BCE, Darius commissioned his Royal Road.

The road was 2699 km and was so well-constructed that mounted couriers could convey letters and packages across it in seven days.

Slide 26

Slide 26

http://nplusonemag.tumblr.com/post/27919786178/neither-snow-nor-rain-nor-heat-nor-gloom-of-night Herodotus (her-ah-doh-tus) praised these couriers with the words that are now thought of as the uno ffi cial creed of the United States Postal Service:

"Neither snow nor rain nor heat nor gloom of night stays these couriers from the swift completion of their appointed rounds"

Slide 27

Slide 27

Around the time that Darius was building the Royal Road, the Romans began work on what would become a network of over 400,000 km of roads.

Over 80,000 km of those were paved.

They provided e ffi cient means for the overland movement of armies and civilians, communication throughout the empire, and trade.

Slide 28

Slide 28

http://seekingsantosha.wordpress.com/2012/10/19/all-roads-lead-to-rome/ These roads, of course, are the origin of the sentiment, “All roads lead to Rome”

Slide 29

Slide 29

http://www.kotaku.com.au/2011/01/the-greek-engineer-who-invented-the-steam-engine-2000-years-ago/ In 600 BCE, we see the first rudimentary railway, the Diolkos.

The Diolkos was used to transport ships overland across the narrowest section of the Isthmus of Corinth.

Rails were used to reduce the friction between the ground and the carts the ships were carried on.

Slide 30

Slide 30

http://mygermantravels.com/2010/12/frankfurt-trains-%E2%80%93-an-autobahn-alternative/ Jump forward 2000 years to the 1550s and we see the first rudimentary wagon ways and tramways being built in Germany.

This sort of transport was used by miners to move large amounts of coal out of the mines - a single horse could haul fifty or sixty bushels, or 330 pounds.

Slide 31

Slide 31

http://en.wikipedia.org/wiki/File:Polar_Bear_-_Alaska.jpg Which is about the weight of a small adult polar bear.

Slide 32

Slide 32

http://compellingparade.com/2011/09/i-think-i-can/ Modern freight trains transport in the range of 10,000 tons across continents by building on the technology from 7000 years ago.

Slide 33

Slide 33

http://redfox.typepad.com/forest/2009/11/fashion-and-geography.html Which is 10,250 polar bears

Slide 34

Slide 34

http://www.mrwallpaper.com/paris-eiffel-tower-wallpaper/ Or about the weight of the Eiffel tower

Slide 35

Slide 35

http://www.spacex.com/hyperloop And even future technologies are based on the ideas that came before.

Slide 36

Slide 36

Haha, what? Okay, so why did I just give you a history lesson on wheels, roads, and transportation?

Slide 37

Slide 37

They weren’t reinventing the wheel The point of all this is that throughout history we’ve built upon the technologies that already existed.

By stealing the ideas of those who came before us, we were able to advance and create new and interesting things - we focused on new problems rather than those which had already been solved.

Slide 38

Slide 38

Rails stole ideas

Slide 39

Slide 39

...but which ones?

Slide 40

Slide 40

What do we think of when we think Rails? Rails was released in 2004

http://mattions.files.wordpress.com/2012/10/ruby-on-rails-logo.png

Slide 41

Slide 41

M odel

V iew

C ontroller was conceived as a general solution to the problem of developers controlling a large and complex data set. Separating business logic and data - model layer

User experience and interaction - view layer

and a bit of glue to connect the two - controller layer

Slide 42

Slide 42

The essential purpose of MVC is to bridge the gap between the human user's mental model and the digital model that exists in the computer. Trygve Reenscrag XEROX PARC 1978-79 TRIT-vee Rain-skau

Slide 43

Slide 43

Active Record The mapping between database tables and business logic in applications happens in

Slide 44

Slide 44

An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data. Martin Fowler Patterns of Enterprise Application Architecture He co-authored the Manifesto for Agile Software Development, popularized the term Dependency Injection, and specializes in UML, extreme programming, and object-orienting analysis and design.

He also recently debated Test Driven Development with DHH. I haven’t had a chance to watch that video yet, so no spoilers.

Slide 45

Slide 45

RE presentational S tate T ransfer is a uniform interface for the web REST is a technology that replaced things like SOAP and Remote Procedure Calls to represent information and activities on the Internet.

Slide 46

Slide 46

T h i s i d e a l i z e d m o d e l o f t h e interactions within an overall Web application… became the foundation for the modern Web architecture Roy T. Fielding and Richard N. Taylor Principled Design of the Modern Web Architecture

(2002)

Slide 47

Slide 47

Rails didn’t invent REST • Now while Rails didn’t invent REST, what’s interesting is that when Rails adopted REST as its primary interface, REST wasn’t the clear winner before that happened.

• Rails took a technology that was:

• not theirs

• not all that popular

• and potentially just a “cool new thing” that could be a passing fad

• and contributed to its success and popularity through that decision.

Slide 48

Slide 48

Convention over Configuration seeks to decrease the number of decisions

that developers need to make, gaining simplicity , b u t n o t n e c e s s a r i l y l o s i n g flexibility.

Slide 49

Slide 49

defaults JavaBeans config files

Slide 50

Slide 50

ERB provides an easy to use but powerful

templating system for Ruby. embedded ruby

Slide 51

Slide 51

It is ruby

Slide 52

Slide 52

Merb • asset pipeline • extension api • parameter whitelisting and blacklisting (strong_parameters) • ORM / JavaScript agnostic When Merb was merged with Rails in Rails 3.0, it brought with it several features which are now iconic of Rails

Slide 53

Slide 53

So why is Rails so popular?

Slide 54

Slide 54

http://blogs.huongngo.com/dds/2010/11/15/monday-november-15/ At a high level, Ruby on Rails became a popular web application framework in part because of how easy it makes it to rapidly create a prototype, and then to take the prototype and scale up to a production application.

Slide 55

Slide 55

Execution is crazy important • Rails does a great job of taking the ideas we’ve seen and combining them usefully.

• This means that the conventions Rails relies upon to facilitate rapid development are present throughout the framework.

• It also means that everything works together seamlessly.

• Rails success relies heavily on this execution.

Slide 56

Slide 56

Presentation

is key 15 blog in rails

Build a blog from scratch

have a running web server in seconds

scaffolded application

Slide 57

Slide 57

What can we learn from this? Alright, we know something about Rails now.

I promised I’d bring this back around to making you a better developer, so let’s start with this question.

Slide 58

Slide 58

There is nothing wrong with taking other’s ideas

Slide 59

Slide 59

Rails was built on the shoulders of giants

Slide 60

Slide 60

That worked out pretty well

Slide 61

Slide 61

Keep it simple.

Slide 62

Slide 62

Strong, useful conventions make code easy to find and reduce mundane decision making

Slide 63

Slide 63

Not designed by committee

Slide 64

Slide 64

DHH still contributes • And DHH is still a primary contributor, and has the most say of anyone in the direction of the framework.

• He is fond of saying that Rails is for Basecamp (the application from which the framework was extracted), and that it just happens to be useful in other applications.

• In his “Benevolent Dictator for Life” role within Rails, he makes a lot of the decisions himself about what will happen in Rails’ future.

• These decisions may not always be popular, but they keep things from getting tangled up in bureaucracy.

Slide 65

Slide 65

Released in July of 2004

Slide 66

Slide 66

Didn’t share commit rights until February of 2005 ~6-7 months

Slide 67

Slide 67

strong_parameters parameter whitelisting, protects from query parameter injection in controllers

Slide 68

Slide 68

turbolinks Replaces GET requests with AJAX which replace the body element of the page

Slide 69

Slide 69

turbolinks (not a popular decision)

Slide 70

Slide 70

While we may not always agree with him

Slide 71

Slide 71

It doesn’t matter; he’s doing it anyways

Slide 72

Slide 72

While this can be frustrating, you can’t argue with success

Slide 73

Slide 73

Almost 35 million downloads, and 32 thousand just for this version.

Slide 74

Slide 74

What can we take from this?

Slide 75

Slide 75

Take ideas

Slide 76

Slide 76

I know you want to build.

Slide 77

Slide 77

Interesting problems are fun to solve

Slide 78

Slide 78

but they already have been

Slide 79

Slide 79

Don't be seduced by the problem

Slide 80

Slide 80

You are trying to get something out the door

Slide 81

Slide 81

Buy for parity build for competitive advantage You’ve probably heard of the adage, Buy for parity; build for competitive advantage.

It means that you shouldn’t spend time building things that already exist, but rather focus on things that differentiate you.

Slide 82

Slide 82

123 Main St Anytown, MA 12345 As a consultant, I see a lot of companies who want to validate addresses.

It seems like a simple thing on the surface - you have to have a street address, a city, a state, and a ZIP code.

http://ronekissrichmond.files.wordpress.com/2012/01/us-postage-stamp.jpg

Slide 83

Slide 83

123 Main St Apartment #5 Anytown, MA 12345 but then you run into addresses with two street lines, which you’ll have to support as well.

Slide 84

Slide 84

123 Main St Basement Anytown, MA 12345 And the di ffi culty increases when you realize that there’s no real rules for what goes on the extra line.

Slide 85

Slide 85

c/o somebody else 123 Main St Anytown, MA 12345 And that the order of the street address lines doesn’t affect the deliverability

Slide 86

Slide 86

Bank of Canada 234 Laurier Avenue West Ottawa, Ontario, Canada K1A 0G9 And of course, you’ll have to support addresses in other countries, with weird address formats.

Slide 87

Slide 87

Caleb Thompson FNBA Downtown branch Downtown, Anchorage, Alaska Hell, I once got a coconut delivered to me at work in Anchorage, Alaska from Hawaii.

http://www.123rf.com/photo_11819896_a-fresh-whole-coconut-cocus-nucifera-isolated-on-a-white-background.html

Slide 88

Slide 88

Caleb Thompson FNBA Downtown branch Downtown, Anchorage, Alaska I think it was delivered partially because of all of the stamps she had stapled to it.

Slide 89

Slide 89

http://theunboundedspirit.com/holy-madness-and-insanity/ The point is, validating addresses is hard.

It’s what we call a core competency: you should only focus on doing it if deliverability is how you make money.

And if it isn’t, you should pay someone else to do it for you while you do the things that differentiate you.

This is a case where you shouldn’t even bother stealing ideas - just let other people take care of it for you.

Slide 90

Slide 90

Are you going to have a better idea than Fielding had about REST? Okay, so back to not reinventing things.

Slide 91

Slide 91

maybe

Slide 92

Slide 92

probably not

Slide 93

Slide 93

Take ideas

Slide 94

Slide 94

But don’t take it from me

Slide 95

Slide 95

Slide 96

Slide 96

Slide 97

Slide 97

Thank you.

Slide 98

Slide 98

Caleb Thompson @thompson_caleb calebthompson caleb@calebthompson.io

Slide 99

Slide 99

Don’t just sit there. Learn Something. learn.thoughtbot.com SCOTRUBY14 for 30% off a Learn Prime subscription I work for a company called thoughtbot. - I wouldn’t have been able to come to scottish ruby without them.

To thank you for your time, I’d like to offer all of you a free month subscription to Learn Prime - just use this coupon code.

I’ve also got stickers, so if you would like one come and find me. I accept other stickers, cool stories, and drinks in exchange.