Top Banner
How to write a web framework With illustration using Sinetja and Xitrum Ngoc Dao Sunday Oct 26 2014
25

How to write a web framework

May 27, 2015

Download

Software

Ngoc Dao

In this talk I'd like to share experience about writing web frameworks
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: How to write a web framework

How to writea web frameworkWith illustration using Sinetja and Xitrum

Ngoc DaoSunday Oct 26 2014

Page 2: How to write a web framework

About this presentation

• I want to share some experience about writing web frameworks.

Page 3: How to write a web framework

About Ngoc• Came to Japan to study and work in 2001

• Studied electrical engineering at Takamatsu 高専 andcomputer vision at Tsukuba 大学

• Worked at several software startups:Murakumo (Kokolink), GNT, KAYAC, Mobilus

• Interests: web frameworks, distributed systems, realtime systems

• Have been writing some web frameworks since 20092 in Erlang, 1 in Scala, 1 in Java

• Open source:https://github.com/ngocdaothanh

Page 4: How to write a web framework
Page 5: How to write a web framework

Discussion question

• Have you ever written a web app?

• What are your favorite web frameworks?

Page 6: How to write a web framework

• My favorite: Ruby on Rails

• It's a beautifulopinionatedconvention over configurationweb framework

Page 7: How to write a web framework

https://gettingreal.37signals.com/ch04_Make_Opinionated_Software.php

Some people argue software should be agnostic. They say it's arrogant for developers to limit features or ignore feature requests. They say software should always be as flexible as possible.

We think that's bullshit. The best software has a vision. The best software takes sides. When someone uses software, they're not just looking for features, they're looking for an approach. They're looking for a vision. Decide what your vision is and run with it.

And remember, if they don't like your vision there are plenty of other visions out there for people. Don't go chasing people you'll never make happy.

Page 8: How to write a web framework
Page 9: How to write a web framework

Discussion question

• What are the differences betweenlibrary and framework?

Page 10: How to write a web framework

• In my opinion

Library is about features

Framework is about workflow and connecting other existing libraries

Page 11: How to write a web framework

Discussion question

• How hard to write a web framework?

Page 12: How to write a web framework

• In my opinion,

Writing a framework is 10x harder than writing a library,

Because:- You need to know how to use and connect many libraries- You need to have much experience to have your vision, to make your framework opinionated

• Writing a library ~ Playing a music instrumentWriting a framework ~ Conducting an orchestra

Page 13: How to write a web framework

• Vision example:

Xitrum:- Easy async- Easy cluster- Beautiful API

Page 14: How to write a web framework

Discussion question

• How market your web framework?How to let users know about and use it?How to create a community around it?

Page 15: How to write a web framework
Page 16: How to write a web framework

Discussion question

• What happens behind the scene

from the time when you type URL in the browser address bar and press ENTER

to the time the web page is displayed?

(Note: This is a Google interview question)

Page 17: How to write a web framework

Discussion question

• What are the differences betweena command line program anda web program?

• What are the similarities between them?

Page 18: How to write a web framework

Discussion question

• What are the features that you think a web framework should have? What are the things that you think a web framework should do for you?

• What is the most important part in a web framework?

Page 19: How to write a web framework

• In my opinion,

the most important part in a web framework is the router.

Page 20: How to write a web framework
Page 21: How to write a web framework

• Use curl and telnet to demo

Structure ofHTTP request and response

Page 22: How to write a web framework

• Request method + path info-> Router-> Which action to dispatch the request to

Routefrom request

to action

Page 23: How to write a web framework

• Stacked handlers:

Request-> Handler 1-> Handler 2-> …-> Response

• Handler examples: router, dispatcher, static file server, response cacher etc.

Structure ofrequest processing pipeline

Page 25: How to write a web framework

• Sinetjahttps://github.com/sinetja/sinetja

• Xitrumhttp://xitrum-framework.github.io/

(Show how beautiful the APIs look like :D)

Demo