HackerTube

Lexical Scanning in Go - Rob Pike

GoogleFOSSSydney13 HN recommenders · recommended in 12 months, 2012–2025
YouTube
talk · intermediate · evergreen · 2012–2025 on HN

Rob Pike shows how the Go text/template lexer is built, using state functions, goroutines and channels. The talk was given at a Google Technology User Group in Sydney in 2011.

HN returns to it for years as an elegant introduction to writing a lexer that is easy to follow even without a parsing background.

12 comments from Hacker News

@hu32024-11 · in “Rust for tokenising and parsing”

Related, I love Rob Pike's talk about lexical Scanning in Go (2011). Educational and elegant approach. ▶ this video

Strongly recommends View on HN
@grose2016-10 · in “Ask HN: What's your favorite tech talk?”

Lexical Scanning in Go by Rob Pike ▶ this video I love everything about this talk. It walks you through building a lexer from scratch in a simple and elegant way, through a very interesting use of coroutines. I appreciate the bits of humor in the talk as well.

Strongly recommends View on HN
@TomNomNom2014-05 · in “Templating in Go”

Rob Pike did a really good talk entitled 'Lexical Scanning In Go'[0], which covers how the lexing for text/template works. It's far more interesting than it sounds, and even if you don't know much about lexing/parsing it's easy to follow. [0] ▶ this video

Strongly recommends View on HN
@willvarfar2012-06 · in “Parsing huge XML files with Go”

Personally, I have a penchant for writing my own pull parsers. Its a mind-expanding exercise. The neat thing about Go is that parsers can return functions that consume the next token. Rob Pike has an excellent video about this: ▶ this video

Strongly recommends View on HN
@Xeoncross2025-06 · in “Datalog in Rust”

If you enjoyed the state machine + parsing part and also I recommend the older "Lexical Scanning in Go" talk that Rob Pike gave: ▶ this video It's in Go, but you can apply most of it easily in other languages. I'm so happy that modern languages like Rust, Zig, and Go support unicode/runes/graphemes natively. So many problem just disappear compared to Java, .net, C++, or scripting languages.

Recommends View on HN