6. Web? Use MVC!
• Quite a number of Go MVC web framework exist:
• Beego / Martini / Revel….
• Different approach for MC layers
• V layer are mostly the same: Go HTML Template http://golang.org/
pkg/html/template/
7. @yinwang0:Go HTML Template
• “Basically usable” template engine
• Surprisingly, logic control code in template are not Go itself
• Poor expressiveness
• Need to bind all template data into a single model
• Helper func need to be “registerd”
• Quite messy & tedious
10. – Wikipedia
“PHP(PHP: Hypertext Preprocessor)…server-side scripting
language designed for web development.. PHP code can be
simply mixed with HTML code..”
12. • “Not possible, Go doesn’t have interpreter”
• “Go is NOT script”
13. I think otherwise
• Go is turing complete
• No things Go can’t go
• Only thing more complicated to do with Go
• Embedding static compile language in HTML are possible:
• ASP.Net
14.
15. Razor
• Default template/view engine for ASP.NET MVC
• Support embedding c# / vb.net in HTML
• .Net developers love it (including me):
• http://www.zhihu.com/question/19973649 (Chinese link)
19. • Mature template engine; sublime plug-ins for syntax highlight + auto
complete
• Able use Go directly in template; no different syntax for flow control
• Powerful expressiveness
• Rendering template is calling function; models are function
parameters
• No need to register helper func, directly import in template
• Very concise & convinient
24. Dynamic
• web is built around string
• Go is static compiled; can it:
• Obtain object properties via string?
• Invoke package/object methods via string?
• Create object via string?
34. • Generate all these methods:
• NewXXXObjByID(namespace, classname, id string)
• ReadForm(params map[string]string)
• So, 600k LoC
35. • Code generation makes static compiled language feels “dynamic”
• Go can do this, so does all other languages
• But, how about the compilation speed?
38. • Go’s compilation speed is amazing!
• This is a project with 600k LoC on Mid 2011 Macbook Air
• We could keep cmd + s / cmd + tab / cmd + R development pace
39. Back to dynamic
• If complication is slow, then code-gen approach hurts produtivity
• Go compile extreme fast
• Go has unique point for dynamic
49. • Go allow querying original object’s interface
• Switch between different interfaces at runtime
• Interface could be defined in new packages
• No need to put all interface combinations for different purpose at
one place
51. But!
• Simple web pages? Pick whatever you like
• Of cause including Go
• Middle size web application, like a forum?
• php / Rails / Django / asp.net are more mature
• Go also can, if you like re-inventing the wheel
• How about large website?
52. Needs for large website
• Stability rules
• Scalability & Distributed are important
• SOA architecture
• Performance are critical
• Maintainable code (With GoRazor; even the templates are strong-
typed & compiler checked)
53. • Quick prototyping, and switch technology/platform?
• Works, but these are technical debt!
• If we could owe less debt since the beginning, why not?