Upgrade to Pro — share decks privately, control downloads, hide ads and more …

2023 - WebConf - 選擇適合你的技能組合

2023 - WebConf - 選擇適合你的技能組合

近十年來軟體產業蓬勃發展,許多新語言、框架跟工具都不斷被推出,我們應該如何選擇?我以一名 Ruby 愛好者的角度來說明持續選用 Ruby 的理由,來解釋問題沒有想像中困難,也不那麼單純。更多是我們自身的個性、環境影響,當我們了解一個語言跟框架的特性,就很好找到適合自己的工具和技能。

蒼時弦や

August 12, 2023
Tweet

More Decks by 蒼時弦や

Other Decks in Programming

Transcript

  1. 選擇適合你的技能組合
    Pick up the best skill set for yourself

    View Slide

  2. 蒼時弦也
    Software Developer
    https://blog.aotoki.me

    View Slide

  3. View Slide

  4. 歷史背景
    語言特性
    生態系
    技能搭配

    View Slide

  5. 歷史背景
    語言特性
    生態系
    技能搭配

    View Slide

  6. 歷史背景
    語言特性
    生態系
    技能搭配

    View Slide

  7. 歷史背景
    語言特性
    生態系
    技能搭配

    View Slide

  8. 資訊量過大
    我們來看一些有趣的地方

    View Slide

  9. 網站與程式語言
    把網路的進展與程式語言面世的時間對照

    View Slide

  10. C
    1972
    1983
    C++ Python
    1991
    1995
    Java PHP Ruby JavaScript
    200

    View Slide

  11. C
    1972
    1983
    C++ Python
    1991
    1995
    Java PHP Ruby JavaScript
    200
    1990 年代,World Wide Web(全球資訊網)被提出

    View Slide

  12. PHP Ruby JavaScript C#
    2000
    2009
    Go Node.js Rust
    2013
    2000 年代,Web 2.0 被提出

    View Slide

  13. PHP Ruby JavaScript C#
    2000
    2009
    Go Node.js Rust
    2013
    2006 年代,Amazon Web Service 推出

    View Slide

  14. Ruby、Python 初期沒有內建 HTTP 伺服器,直到 2010 年前後才
    被加入到標準函式庫,然而 Go、Node.js 一開始就內建

    View Slide

  15. 開發框架的進展
    除了語言之外,現今主流的框架在何時誕生

    View Slide

  16. Spring
    2002
    2005
    Rails Django .NET MVC
    2007
    2010
    Angular Laravel
    2011

    View Slide

  17. Spring
    2002
    2005
    Rails Django .NET MVC
    2007
    2010
    Angular Laravel
    2011
    Web 2.0 後當代主流的網站開發框架才逐漸成形

    View Slide

  18. 2005
    Rails Django .NET MVC
    2007
    2010
    Angular Laravel
    2011
    2013
    React Vue
    2014
    後端成型後的十年,前端框架也開始被提出

    View Slide

  19. 從時間的角度來看,不同時期推出的語言、框架剛好對應當時面對
    的問題

    View Slide

  20. 型別
    一個語言如何看待型別會影響使用

    View Slide

  21. # Ruby


    def
    end


    (value)

    value

    inspect
    inspect [ ]
    inspect
    puts
    "string"

    "array"

    View Slide

  22. // Golang


    // ...

    func
    switch :=
    case string
    case string
    string
    (obj any) {

    v obj.(type) {

    :

    fmt. (v)

    [] :

    fmt. (v)

    }

    }


    ( )

    ([] { })
    Inspect
    Println
    Println
    Inspect
    Inspect
    "string"
    "array"

    View Slide

  23. 動態型別語言會自動分辨,在撰寫上通常會比較簡潔

    View Slide

  24. # Ruby


    Person Struct :name :age
    Person name: age: 28
    Person name: age:
    . ( , )


    bob . ( , )

    john . ( , )
    = new
    = new
    = new
    "Bob"
    "John" "John"

    View Slide

  25. // Golang


    // cannot use "John" (untyped string constant) as int value in
    struct literal
    type struct
    string

    int

    :=
    :=
    {

    Name
    Age
    }


    bob Person{Name: , Age: }

    john Person{Name: , Age: }


    Person
    "Bob"
    "John" "John"
    28

    View Slide

  26. 動態型別的語言通常會需要額外確認資料是否正確

    View Slide

  27. # Ruby


    def
    do
    new
    end

    &
    end
    (services)

    services

    .map |service|

    . { service.start }

    .each( )

    run
    Thread
    :join

    View Slide

  28. // Golang


    // select { ... }

    package
    type interface
    func ...
    :=
    for := range
    go func
    {

    (ctx context.Context)

    }


    (services Service) {

    ctx context. ()


    _, svc services {

    () { svc. (ctx) }

    }


    }
    daemon


    Service
    Run
    Start
    Background
    Start

    View Slide

  29. // Golang


    // ...

    package
    type struct
    func *
    {}


    (s Server) (ctx context.Context) {

    }
    http


    Server
    Start

    View Slide

  30. // C#


    namespace
    interface
    void
    class
    void Service
    foreach IService in
    {

    {

    ()

    }


    {

    ( [] ) {

    ( services) {

    service. ()

    }

    }

    }

    }
    Daemon
    IService
    Start
    Main
    Run services
    service
    Start

    View Slide

  31. // C#


    // ...

    namespace
    class Daemon IService
    {

    : . {

    () {

    }

    }

    }
    Http
    Server
    Start

    View Slide

  32. 同樣是靜態型別,也會有所不同,在使用不同工具的思考方式就會
    有所差異

    View Slide

  33. 不同語言描述事物的方式都不太一樣,我自己比較喜歡 Ruby 保留
    很多彈性的方式,因為很彈性不同人寫出來的差異就會更大

    View Slide

  34. 物件
    不同語言中對物件的看法都有點不同

    View Slide

  35. # Ruby


    class <
    def
    new + +
    end

    end


    = new
    = new
    +
    ( , )

    (other)

    (x other.x, y other.y)

    p1 . ( , )

    p2 . ( , )


    p1 p2
    Point Struct.new
    +
    :x :y
    Point x: 1 y: 1
    Point x: 2 y: 2
    puts

    View Slide

  36. # Elixir


    # ...

    defmodule do

    defstruct
    def +
    +
    end


    =
    =
    |>
    [ , ]



    (%{ x, y}, %{ x2, y2}), % { x x2,
    y y2 }

    p1 % { , }

    p2 % { , }

    . p1 . (p2)
    Point
    add Point
    Point
    Point
    IO inspect Point add
    :x :y
    x: y: x: y: do: x:
    y:
    x: 1 y: 1
    x: 2 y: 2

    View Slide

  37. typedef struct
    int
    int
    = = + = +
    return
    int
    = = =
    = = =
    =
    return
    {

    x;

    y;

    } Point;


    Point (Point , Point ) {

    Point p { .x p1.x p2.x, .y p1.y p2.y };

    p;

    }


    () {

    Point p1 { .x , .y };

    Point p2 { .x , .y };

    Point p (p1, p2);

    ( , p.x, p.y);



    ;

    }
    add
    main
    add
    printf
    p1 p2
    1 1
    2 2
    %d %d
    0
    "x = , y = "

    View Slide

  38. Point(1, 1)
    Object
    Add(p1, p2)
    Method
    Point(3, 3)
    Object
    物件是一組有意義的資料,類別(Class)則是定義哪些函示能對資
    料發揮作用,稱為方法(Method)
    https://hackmd.io/@sysprog/c-oop#物件導向是一種態度

    View Slide

  39. # Ruby


    # ...

    module
    def
    end

    end


    class
    include
    include
    end
    (other)

    Addable

    add
    Point

    Addable

    Printable

    View Slide

  40. # Python


    # ...


    class
    def
    class
    pass
    :

    (self, other):

    ( , ):

    Addable
    add
    Point Addable Printable

    View Slide

  41. // Go


    // 這是對的嗎?
    type interface
    type struct
    {

    (other Addable) Addable

    }


    {

    Addable

    }


    Addable
    Point
    Add

    View Slide

  42. Mixin(混合)是部分語言才有的概念,這類語言通常會有 Duck
    Typing 的概念存在(可以呼叫特定方法即可)

    View Slide

  43. // Go


    // Yes, But!


    type interface
    type struct
    := &
    {

    (other Addable) Addable

    }


    {

    Addable

    }


    p Point { Addable: Vec2{ , } }
    Addable
    Point
    Add
    1 1

    View Slide

  44. // C


    // Usage: p.addable->vec2


    // 更像這個狀況
    typedef struct
    union
    *
    *
    = = =
    = = *
    {

    {

    Vec2 vec2;

    Vec3 vec3;

    } addable;

    } Point;


    Vec2 vec2 { .x , .y };

    Point p { .addable vec2 };

    1 1

    View Slide

  45. 不是將方法混合到物件中,而是作為一部分組合(Composite)到
    物件裡面

    View Slide

  46. 框架
    輔助開發的利器

    View Slide

  47. Ruby on Rails
    Model
    View
    Controller

    View Slide

  48. Laravel
    Model
    View
    Controller

    View Slide

  49. Spring Framework
    Spring WebFlux
    Spring MVC
    ...

    View Slide

  50. Golang
    net/http
    template/html
    database/sql

    View Slide

  51. 不同語言的框架解決方案並不相同,Golang 通常只使用 Router 為
    主的框架,Rails 以 MVC 為主體,Spring 有非常完整的解決方案

    View Slide

  52. Spring 有 VMWare 的支持,同時 Java 是許多企業採用的語言,
    因此提供完整的解決方案能讓工程師專注在商業問題上

    View Slide

  53. 不同社群在維護功能的選擇上有不同差異,有的可能以少數意見領
    袖為主,有些則是非常開放以社群意見為方向

    View Slide

  54. Golang 主要設計給網路服務,在多核心、網路相關的支援完善,重
    心不完全在 Web 上,框架的發展大多只針對不好處理的 Router

    View Slide

  55. Vue React Angular
    扣掉喜好這類外在因素,我們會怎麼選擇?

    View Slide

  56. Vue React Angular
    產品原型、個人專案、功能明確的產品

    View Slide

  57. Vue React Angular
    跨團隊協作維護、功能複雜的產品

    View Slide

  58. Vue React Angular
    大型企業使用系統、多租戶服務

    View Slide

  59. 單純從框架規範、開發方式來看,越強大完善的框架限制也越多,
    也就越適合多人協力(規範明確不容易出錯)

    View Slide

  60. 解決方案
    生態系決定選擇

    View Slide

  61. 如果我們想處理 AI/ML 的題目,想到什麼語言?

    View Slide

  62. Python
    Python 有許多適合處理資料的套件,而且非常完整容易使用

    View Slide

  63. 如果想快速製作產品原型,會想到什麼語言?

    View Slide

  64. Ruby PHP
    Ruby on Rails 和 Laravel 兩個框架在在初始化後即可馬上可用,語法彈性更容易驗證想法

    View Slide

  65. 如果想做網路服務,會想到什麼語言?

    View Slide

  66. Golang
    Golang 天生對網路服務的相容性就非常好,因此被大多微服務基礎建設專案選用

    View Slide

  67. 如果想做安全、系統底層的應用,會想到什麼語言?

    View Slide

  68. Rust
    Rust 對記憶體的使用非常嚴謹,並且大量利用編譯器檢查來改善軟體的品質

    View Slide

  69. 如果想做遊戲,會想到什麼語言?

    View Slide

  70. C# C++
    Unity 讓遊戲開發的門檻極大降低,目前兩大主流引擎分別使用 C# 和 C++

    View Slide

  71. 工具選擇
    如果要學習一個語言,該怎麼選?

    View Slide

  72. 從個性來看,喜歡彈性還是有規則跟標準?

    View Slide

  73. Ruby JavaScript
    雖然不排斥繁複的定義,但是因為自己很多想法想驗證,有彈性的語言更適合

    View Slide

  74. 從喜好來看,想做遊戲相關聯的軟體

    View Slide

  75. Ruby C# JavaScript
    這幾個語言都有遊戲開發相關的解決方案可以用

    View Slide

  76. 從環境來看,當下的趨勢與機會是什麼

    View Slide

  77. Ruby JavaScript
    自己在程式領域進步最快的 2013 年那個時期,Ruby on Rails 是最有潛力的工具與職業

    View Slide

  78. 綜合各種條件,大致上就能找到適合的語言

    View Slide

  79. Ruby TypeScript
    從 PHP 開始學習,到 Ruby & TypeScript 能用十年以上有很多條件

    View Slide

  80. 然而,現代人的人生長到足以學習大多數程式語言

    View Slide

  81. Golang Python
    考量到職涯發展,我在工作中使用截然不同的語言跟環境來「解決問題」

    View Slide

  82. C C#
    遊戲開發跟研究技術是我的興趣,我也會不時使用他們

    View Slide

  83. Elixir Rust
    嘗試不同的語言跟思考方式,也是作為工程師有趣的一環

    View Slide

  84. 比起語言跟框架,清楚自己「想做什麼」以及「如何做好」更重要

    View Slide

  85. END
    工商一下網誌的連載內容

    View Slide

  86. 2023 Later - Rails 開發實踐
    2024 Early - Cucumber 的文件測試法
    2024 Later - Rails 架構設計(規劃中)
    https://blog.aotoki.me

    View Slide