SlideShare a Scribd company logo
24 HOURS LATER Phillip Trelford, @ptrelford
#fsharpgotham NYC, 2015
THIS TALK IS *NOT*
About how to write a compiler the hard way
All theory
For the faint of heart
THIS TALK *IS*
ABOUT
Domain Specific
Languages
Abstract Syntax Trees
Parsing
Interpreters
Code Generation
LANGUAGE DESIGN (CONSIDERED
OPTIONAL)
Adhoc
•PHP
•JavaScript
•Scala
Copy&Delete
•Java
•J
•Go
Copy&Add
•C#
•F#
•Haskell
TO THE TURTLES CODE Phillip Trelford, @ptrelford
#fsharpgotham NYC, 2015
TURTLE LANGUAGE
repeat 10
[right 36 repeat 5
[forward 54 right
72]]
TURTLE AST
type command =
| Forward of arg
| Turn of arg
| Repeat of arg * command list
THINGS YOU SHOULD NEVER DO
Custom Operators
Funny picture
TWO GIRLS (5 & 7YRS) + TURTLE
SMALL BASIC
SAMPLE
Sub Init
gw = 598
gh = 428
GraphicsWindow.BackgroundColor =
"DodgerBlue"
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
color = "1=Orange;2=Cyan;3=Lime;"
size = "1=20;2=16;3=12;"
passed = 0
cd = "False" ' collision detected
EndSub
SMALL BASIC AST
/// Small Basic expression
type expr =
| Literal of value
| Identifier of identifier
| GetAt of location
| Func of invoke
| Neg of expr
| Arithmetic of expr * arithmetic * expr
| Comparison of expr * comparison * expr
| Logical of expr * logical * expr
/// Small Basic instruction
type instruction =
| Assign of assign
| SetAt of location * expr
| PropertySet of string * string * expr
| Action of invoke
| For of assign * expr * expr
| EndFor
| If of expr
| ElseIf of expr
| Else
| EndIf
| While of expr
| EndWhile
| Sub of identifier * string list
| EndSub
| Label of label
| Goto of label
C# COMPILER IN 24 DAYS
Oh Yes! Neil Danson (aka The Do)
Now, I didn’t do any compiler
theory in uni, I’ve never written a
compiler before and I’ve only
ever looked at Reflection Emit in
anger. But despite these
limitations I have a fairly
capable C# 0.5 compiler (in that
it is a subset of the C# 1
compiler). Which means you can
do it too – it took me less than a
month.
http://tinyurl.com/funbasi
c
FUN BASIC - WINDOWS
STORE APP
FUN SHARP RUNNING ON
RASPIAN
http://github.com/ptrelford/f
unsharp
RESOURCES Phillip Trelford, @ptrelford
#fsharpgotham NYC, 2015
F# KOANS
[<Koan>]
let SquareEvenNumbersWithPipelineOperator() =
(* In F#, you can use the pipeline operator to get the benefit of
the parens style with the readability of the statement style. *)
let result =
[0..5]
|> List.filter isEven
|> List.map square
AssertEquality result __
TRYFSHARP.ORG
BUY THE BOOK
QUESTIONS?
Twitter: @ptrelford
Blog:
http://trelford.com/blog
Turtle: http://fssnip.net/nN

More Related Content

PPTX
F# eXchange Keynote 2016
PPTX
Building cross platform games with Xamarin - Birmingham 2015
PPTX
24 Hours Later - NCrafts Paris 2015
PPTX
Mobile F#un
PPTX
24 Hours Later - NDC London 2014
PPTX
Flappy - Paris 2015
KEY
PyCon JP 2011 Lightning Talk No.10
PDF
Debugging with pdb in Python
F# eXchange Keynote 2016
Building cross platform games with Xamarin - Birmingham 2015
24 Hours Later - NCrafts Paris 2015
Mobile F#un
24 Hours Later - NDC London 2014
Flappy - Paris 2015
PyCon JP 2011 Lightning Talk No.10
Debugging with pdb in Python

Viewers also liked (20)

PPTX
Build a compiler in 2hrs - NCrafts Paris 2015
PPTX
F# for Trading - QuantLabs 2014
PPTX
Machine learning from disaster - GL.Net 2015
PPTX
F# in your pipe
PPTX
F# in Finance Tour
PPTX
F# for Trading - Øredev 2013
PPTX
F# for C# devs - Copenhagen .Net 2015
PPTX
Beyond lists - Copenhagen 2015
PPTX
Keyboard warriors #1 copenhagen performance
PPTX
Beyond Lists - Functional Kats Conf Dublin 2015
PDF
Building a web application with ontinuation monads
PPTX
FSharp eye for the Haskell guy - London 2015
PPTX
Generative Art - Functional Vilnius 2015
PPTX
F# Eye 4 the C# Guy - DDD Cambridge Nights 2014
PPTX
FSharp On The Desktop - Birmingham FP 2015
PPTX
Write Your Own Compiler in 24 Hours
PPTX
Creating own language made easy
PPTX
FParsec Hands On - F#unctional Londoners 2014
KEY
Let's build a parser!
PPTX
Real World F# - SDD 2015
Build a compiler in 2hrs - NCrafts Paris 2015
F# for Trading - QuantLabs 2014
Machine learning from disaster - GL.Net 2015
F# in your pipe
F# in Finance Tour
F# for Trading - Øredev 2013
F# for C# devs - Copenhagen .Net 2015
Beyond lists - Copenhagen 2015
Keyboard warriors #1 copenhagen performance
Beyond Lists - Functional Kats Conf Dublin 2015
Building a web application with ontinuation monads
FSharp eye for the Haskell guy - London 2015
Generative Art - Functional Vilnius 2015
F# Eye 4 the C# Guy - DDD Cambridge Nights 2014
FSharp On The Desktop - Birmingham FP 2015
Write Your Own Compiler in 24 Hours
Creating own language made easy
FParsec Hands On - F#unctional Londoners 2014
Let's build a parser!
Real World F# - SDD 2015
Ad

Similar to 24 hours later - FSharp Gotham 2015 (20)

PPT
F# and the DLR
PDF
Functional Programming for Busy Object Oriented Programmers
PDF
Functional programming is not about complicated things
PPTX
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
PDF
Functional Programming in C# and F#
PPTX
"The F# Path to Relaxation", Don Syme
PPTX
Php extensions
PPTX
F# for Trading
PDF
Functional Programming in JavaScript
PPTX
F# for functional enthusiasts
PPTX
FSharp in the enterprise
PPT
name name2 n2.ppt
PPT
ppt2
PPT
name name2 n
PPT
ppt30
PPT
ppt18
PPT
Ruby for Perl Programmers
PPT
name name2 n2
PPT
name name2 n
PPT
ppt21
F# and the DLR
Functional Programming for Busy Object Oriented Programmers
Functional programming is not about complicated things
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
Functional Programming in C# and F#
"The F# Path to Relaxation", Don Syme
Php extensions
F# for Trading
Functional Programming in JavaScript
F# for functional enthusiasts
FSharp in the enterprise
name name2 n2.ppt
ppt2
name name2 n
ppt30
ppt18
Ruby for Perl Programmers
name name2 n2
name name2 n
ppt21
Ad

More from Phillip Trelford (9)

PPTX
How to be a rock star developer
PPTX
Ready, steady, cross platform games - ProgNet 2015
PPTX
F# for C# devs - NDC Oslo 2015
PPTX
F# for C# devs - Leeds Sharp 2015
PPTX
F# for C# devs - SDD 2015
PPTX
FSharp for Trading - CodeMesh 2013
PPTX
All your types are belong to us!
PPTX
F# Eye for the C# guy - Øredev 2013
PPTX
F# Eye for the C# Guy - DDD North 2013
How to be a rock star developer
Ready, steady, cross platform games - ProgNet 2015
F# for C# devs - NDC Oslo 2015
F# for C# devs - Leeds Sharp 2015
F# for C# devs - SDD 2015
FSharp for Trading - CodeMesh 2013
All your types are belong to us!
F# Eye for the C# guy - Øredev 2013
F# Eye for the C# Guy - DDD North 2013

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
history of c programming in notes for students .pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Cost to Outsource Software Development in 2025
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
Design an Analysis of Algorithms I-SECS-1021-03
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Internet Downloader Manager (IDM) Crack 6.42 Build 41
iTop VPN Free 5.6.0.5262 Crack latest version 2025
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Odoo Companies in India – Driving Business Transformation.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Salesforce Agentforce AI Implementation.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
history of c programming in notes for students .pptx
CHAPTER 2 - PM Management and IT Context
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Why Generative AI is the Future of Content, Code & Creativity?
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Cost to Outsource Software Development in 2025
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Reimagine Home Health with the Power of Agentic AI​
Navsoft: AI-Powered Business Solutions & Custom Software Development

24 hours later - FSharp Gotham 2015

Editor's Notes

  • #8: http://blogs.msdn.com/b/smallbasic/archive/2014/08/11/small-basic-game-programming-vertical-scrolling-game.aspx
  • #11: http://blogs.msdn.com/b/smallbasic/archive/2014/08/11/small-basic-game-programming-vertical-scrolling-game.aspx