Fast 

Web Applications

 with Go

DevFestW Istanbul
March 2, 2014
Ekin Eylem Ozekin

Outline


  • Introduction to Go
  • Web with Go
  • Is Go suitable to Web
  • Demo Web Application
  • Questions

    But First of All, Me


    • Ekin Eylem Ozekin
    • BSc. in Computer Science, MSc. in Software Engineering
    • Currently, PhD. Candidate at Bogazici University, on Machine Learning
    • Works at GE

    Introduction to Go

    • Build around 2007, announced at 2009
    • By "Go"ogle
    • Open Source
    • Similar to C
    • Statically typed, compiled
    • No pointer arithmetic

    Introduction to Go

    • Automatic memory management, classes (structs), type inference
    • First class functions, suitable to functional programming
    • Concurrency support, channels

    introduction to Go

    • Ideal for fast, distributed systems
    • Can import libraries directly from URLs
    • Built-in UTF-8 support(İ, ç etc. works perfectly)
    • Integrated AppEngine libraries

    introduction to GO


    introduction to Go

    • Written as read, left from right
    • No semicolons
    • Multiple return values (think of tuples in Python)
    • Single binary file after compile
    • More on previous code later

    Web with Go

    • Built-in http package
    • Similar to J2EE Servlets
    • But more like a Micro-framework

    web with Go

    • Web development with the performance of C
    • Might be deployed with built-in server (port listener actually)
    • Deploy to Apache or Nginx with FastCGI
    • Also mod_go for Apache
    • Deploy to AppEngine or Heroku

    Is Go Suitable for Web



    Should I use Go for Web?

    iS Go Suitable for web

    Pros
    Micro-framework style http package
    CGI support (kinda old but solid and useful)
    Compiled, fast performance
    C like syntax but better
    API is mature enough

    Is go suitable for Web

    Cons
    Not easier then PHP (or Ruby or Python)
    Not as widely used as others
    Not proven enough yet (can be argued)

    Last Word

    Service Oriented Architecture & Micro Frameworks fit well
    You don't have to use just Go, use with others


    Google already uses it (isn't it enough reason?)

    Demo


    A Web application with Go

    Source Code

    More information

    http://golang.org/doc/
    http://golang.org/doc/articles/gos_declaration_syntax.html
    http://blog.iron.io/2013/08/go-after-2-years-in-production.html

    Questions?

    Q&A Session

    Is there a Database Abstraction layer?
    As there are no classes ORM is a bit crippled. However, there are few implementations on that. You can find those here: 
    http://jmoiron.net/blog/golang-orms/ 
    There are also bindings for popular databases:
    http://go-lang.cat-v.org/library-bindings




    Q&A Session

    What can I use for User Interfaces?
    There is a GTK binding for that. For more libraries you can check: http://go-lang.cat-v.org/library-bindings

    Q&A Session

    To return multiple values Python returns actually a Tuple data structure. Is it similar in Go too?
    No. GO really returns multiple values.


    Q&A Session


    If I can something on a template, should I recompile in order to see changes?

    No, you don't.
     If you make a change on the template code, all you have to do is refresh the page. 
    However, you should be careful, when deploying to the server you should make sure that those templates exist too.

    Thanks

    Made with Slides.com