golang and domain specific languages - fntlnz.wtf · background on dsls: terminology internal dsl :...
TRANSCRIPT
![Page 1: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/1.jpg)
Golang and Domain Specific Languages
Lorenzo Fontana
March 24, 2017
![Page 2: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/2.jpg)
About Me
Lorenzo Fontana
DevOps Expert @Kiratech
Docker Maintainer
http://fntlnz.wtf
https://github.com/fntlnz
https://twitter.com/fntlnz
1
![Page 3: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/3.jpg)
Background on DSLs
![Page 4: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/4.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 5: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/5.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 6: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/6.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 7: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/7.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 8: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/8.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 9: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/9.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 10: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/10.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 11: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/11.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 12: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/12.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 13: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/13.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 14: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/14.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more
2
![Page 15: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/15.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more, really
2
![Page 16: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/16.jpg)
Background on DSLs: Examples
• HTML
• SQL
• GraphQL
• Protobuf
• Regex
• Jenkinsfile
• Dockerfile
• Make
• CSS
• TeX
• And a lot more, really, trust me
2
![Page 17: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/17.jpg)
Background on DSLs: Terminology
Internal DSL : a DSL which exposes a particular form of host general
purpose language to fit domain specific needs, for their
nature, this kind of DSLs are easier to implement but
limited by the design of the host language.
External DSL : a DSL which is parsed independently of the host
general purpose language.
3
![Page 18: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/18.jpg)
Background on DSLs: External or internal ?
Example from: Ginkgo, BDD testing framework for Go
I t ( ” shou ld f a i l i n a l l the p o s s i b l e ways” , func ( ) {s e s s i o n := s t a r tG i n k go ( pathToTest , ”−−noCo lo r ” )
E v e n t u a l l y ( s e s s i o n ) . Should ( gexec . E x i t ( 1 ) )
output := s t r i n g ( s e s s i o n . Out . Contents ( ) )
( output ) . ShouldNot (
Con t a i nSub s t r i n g ( ”NEVER SEE THIS” )
)
}
4
![Page 19: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/19.jpg)
Background on DSLs: External or internal?
Makefile
.PHONY: check−gopath
check−gopath :
i f n d e f GOPATH
$ ( e r r o r GOPATH i s not s e t )
e n d i f
l i n t : check−gopath@echo ” check i ng l i n t ”
@ . / . t o o l / l i n t
gofmt :
@. / hack/ v e r i f y −gofmt . sh
conmon :
$ (MAKE) −C $@
5
![Page 20: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/20.jpg)
Background on DSLs: Lexical analyzers and parser generators
6
![Page 21: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/21.jpg)
Background on DSLs: Backus-Naur Form (BNF)
<expr> : := <term> ”+” <expr>
| <term>
<term> : := <f a c t o r> ”∗” <term>
| <f a c t o r>
<f a c t o r> : := ”(” <expr> ”)”
| <const>
<const> : := i n t e g e r
7
![Page 22: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/22.jpg)
Background on DSLs: lex and yacc - flex and bison
8
![Page 23: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/23.jpg)
What about Go?
![Page 24: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/24.jpg)
Go: goyacc
9
![Page 25: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/25.jpg)
Go: SHOW US THE CODE!
Who am I to not put a gopher in my slides?
10
![Page 26: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/26.jpg)
Conclusion
![Page 27: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/27.jpg)
Conclusion: Happy promotion!
Kiratech, the company I work for, is hiring!
drop me a line at [email protected]
11
![Page 28: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/28.jpg)
Questions?
11
![Page 29: Golang and Domain Specific Languages - fntlnz.wtf · Background on DSLs: Terminology Internal DSL : a DSL which exposes a particular form of host general purpose language to t domain](https://reader034.vdocument.in/reader034/viewer/2022052313/5b5ebffa7f8b9a51328cf25b/html5/thumbnails/29.jpg)
Thanks for listening!
And thanks to all the organizers!
11