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

PyCon2014China-Zhuhai-meta programming

Zoom.Quiet
November 17, 2014

PyCon2014China-Zhuhai-meta programming

Zoom.Quiet

November 17, 2014
Tweet

More Decks by Zoom.Quiet

Other Decks in Technology

Transcript

  1. 欽1:㹊梡(P⯋綘玐
    线⠚!䋞ㅷ猰䪮

    View full-size slide

  2. Ⱒ✵䧮
    ˖ 线⠚⾲䌢끸倝⸈㗗梡㾀帿㖕
    ˖ ♶倗䫔艗䎃涸Ⰼ畮玐䎸プ
    • .net -> python -> go
    ˖ ⱄ妃㔐㕂⴯⚌錟⠑⠶
    [email protected]

    View full-size slide

  3. ⯋綘玐
    ˖ 䭷厤碫雦皾劼玐䎸涸綘ⱗ鵯碫雦皾劼玐䎸綘ⱗ䧴罏
    乼紷Ⱖ㸐玐䎸䧴罏荈魧⡲⚹㸐⟌涸侨䰘
    ˖ ♸䩛䊨綘ⱗⰌ鿈➿瀦湱嫱玐䎸プ〳⟄蜦䖤刿넞涸䊨
    ⡲佪桧

    View full-size slide

  4. ⯋綘玐Ⱖ㹊偽㢅♶㖈
    ˖ 剒䌢錛涸⯋綘玐䊨Ⱘ僽綘霖㐼㸐〳⟄㼜玐䎸プ⢪欽
    넞紩露鎊綘ⱗ涸湱㼆瀊㼭涸玐䎸鲮䰃⚹瘝⟟涸宨綘露
    鎊䧴罏劼㐼露鎊玐䎸
    ˖ Ⱖ㸐⯋綘玐禹絡ⴭ⯈雽⟄綘玐倰䒭乼紷♧猫露鎊կ㸪
    禹絡⽰僽鵯呋♧猫皍⽀涸禹絡

    View full-size slide

  5. $㸪
    #define list_for_each(pos, head) \
    for (pos = (head)->next; pos != (head);
    pos = pos->next)

    View full-size slide

  6. ˊ雽䒭⠚
    Go✽翫緸傞➿涸C♴♧⚡C

    View full-size slide

  7. Go⯋綘玐
    ˖ 加剣㸪
    ˖ 加剣岌㘗
    ˖ ⿿㼘䖎ꦼ欽
    ˖ gopher鵯Ⳝ䎃䖎⸖⸂鍒Ɀ✫雽㢴ⵆ涸露鎊⚥♶
    㶸㖈涸꡼곿˘˘!饆⹄嵞

    View full-size slide

  8. 溏溏䖎⸖⸂涸gopher

    㥵⡦欽py勻㹊梡go涸岌㘗

    View full-size slide

  9. ˖ StringSet♸IntSet➿瀦䖎碫⡃➑碫㘗♶ず
    ˖ 岌㘗涸Ⱙ㘗⢪欽㖞兞

    View full-size slide

  10. 皍⽀ծ磦凐ծ剣佪

    View full-size slide

  11. 荈⸓欰䧭
    ˖ MakeFile
    ˖ 港䱽俒⟝⥝佖HJUIVCDPNHPSBLIBSHPTI
    XBUDIEPH

    View full-size slide

  12. ⱄ勻溏溏ORM

    View full-size slide

  13. 䧮⟌欽thrift⡲㼆韌
    㹁⛐涸DSL

    View full-size slide

  14. ず♧㼆韌⯋⥌䜂
    ˖ 㟞ⴵ佖叅
    ˖ Ⰼ俒䵂程
    ˖ た〵勉ꣳ
    • RPC

    View full-size slide

  15. 㼆韌⠛鷻ծ餻⧩ծ儑爙
    剣㣐ꆀ湱⡃涸➿瀦

    View full-size slide

  16. ˖ ♳鶣➿瀦鿪呏䰘㼆韌⯋⥌䜂欰䧭ⴀ勻
    ˖ 欰䧭涸➿瀦♶⠔ꝡ

    View full-size slide

  17. 㥵⡦㹊梡

    View full-size slide

  18. 鍒區㼆韌
    • ptsd: github.com/wickman/ptsd
    • thrift lexer/parser using ply
    • ply: www.dabeaz.com/ply/
    • An implementation of lex and yacc
    parsing tools for Python

    View full-size slide

  19. ➿瀦欰䧭垷匣
    • www.cheetahtemplate.org

    View full-size slide

  20. YAML⛲僽㥩⚎銯_

    View full-size slide

  21. ˖ 㹊梡♸ORM碫⡃〫僽䪾DSL➢thrift䰃䧭YAML
    ˖ YAML
    ˖ 邍鴪腊⸂刿䔂
    ˖ ꨽宠➃プ⿼㥩

    View full-size slide

  22. 㢪鿈䱹〡
    ˖ ꨽銳㢴畮㹊梡
    • web
    • mobile web
    • mobile client
    ˖ ぐ畮⚌⸉♧荝⡎靈欽⚌⸉〳腊꨽銳♶ず㼓鄳

    View full-size slide

  23. 㼓鄳➿瀦
    鿪♶䎾霪➃聘ⱗ

    View full-size slide

  24. 䨾⟄䧮⟌고湡剣♰♰遤➿瀦

    View full-size slide

  25. ˖ ♳鶣➑➑僽怵爙➿瀦
    ˖ 㹊꣢➿瀦銳㢕勇䖤㢴㢴
    ˖ ORM剣䒓彂github.com/sipin/xuanwu
    ˖ ➑⣘⿬罌ծⴗ⺡⢪欽
    ˖ 偽俒咓
    ˖ ♶絶䫡
    ˖ ⰻ鿈䊺䲀⦝ꅾ勻

    View full-size slide

  26. 㥵⡦㹁ⵖ
    ˖ 欰䧭♧妃た꬗ꥥ⤑佖
    ˖ ꥥ垷匣⥝佖⿿㢕欰䧭
    ˖ 䲿⣘㹁ⵖ䱹〡倰岁㔐靈
    ˖ 銻渷暵㹁倰岁

    View full-size slide

  27. ˖ 岌㘗ծORMծ崨玐ծ䱹〡㼓鄳瘝瘝㖞兞㖲〳罌贊⯋綘玐
    ˖ 儑搬⛲♶〫♳鶣㖞兞
    ˖ 䪾⯋綘玐錠⚹♧猫ꅾ匬䩛媯
    ˖ ⯓䩛⸓ⱗ♧麑➿瀦
    ˖ 䪾⿿㢕ⴀ梡ծ碫⡃涸➿瀦䬄韌⚹垷匣
    ˖ 鷥䭊DSL
    ˖ Python皍⽀ծ䎽餴彂⚪㺢〳⟄䖎㺂僒涸낉霆⯋綘玐涸䟝岁

    View full-size slide

  28. ⯋綘玐涸ꦼ挿
    ˖ 鷥䭊ざ鷓涸%4-
    ˖ 䲿⣘넞㽻妃䬄韌腊⸂
    ˖ 絶䭯絈蒜㹁ⵖ腊⸂
    • www.joelonsoftware.com/articles/
    LeakyAbstractions.html

    View full-size slide

  29. ➿瀦欰䧭
    ˖ 鍒區DSL靈欽垷匣欰䧭➿瀦涸垷䒭䖎㺂僒㹊梡
    ˖ 欰䧭涸鿪僽皍⽀➿瀦㺂僒debug
    ˖ 綘霖㐼唬叅➿瀦

    View full-size slide

  30. ⿿㼘欨荛LISP侅
    ˖ 偽곢ꅾ㢕綘霖
    ˖ 鵘遤傞唬叅ꝡ霴
    ˖ 㹊梡刿剣ꦼ䏞
    ˖ ➿瀦刿⸈礵䊫ծ⠏꧈
    ˖ 儑搬넞㣐♳

    View full-size slide

  31. –Ken Thompson
    “When in doubt, use brute force.”

    View full-size slide

  32. Ⱖ㹊
    ˖ Python♶䘯
    ˖ 嫱倰霹⡤낉鵂git涸匧鸟㽠䖎ꦼ䗽hg涸♶䘯
    ˖ ⯋綘玐剒㥩鵮僽鍒區露鎊劥魧
    • golang.org/pkg/go/parser/
    ˖ HPHFOFSBUF
    ˖ EPDTHPPHMFDPNEPDVNFOUE7-6GK4"%%PP%.IF
    @,&HQ5&N7VW23V/."&OKH

    View full-size slide