Adrian Sampson

cs.cornell.edu/~asampson · Personal blog · on HN since 2016

Adrian Sampson, a Cornell computer science professor, writes about compilers, LLVM, program synthesis, and programming language tools.

What HN saysHN commenters recommend his LLVM for Grad Students post as a strong get-started tutorial and as a good intro to writing compilers.
33HN people shared it
14linked it in comments
37stories submitted
1.5Kstory points
4 months agolast shared
2016people per year2026

Most-shared posts

  1. 1
    Flattening ASTs and other compiler data structures (2023)
    10 people · 173 points · first shared 2023 · 49 comments on HN
  2. 2
    LLVM for Grad Students (2015)
    8 people · 272 points · first shared 2018 · 28 comments on HN
  3. 3
    Program Synthesis is Possible (2018)
    4 people · 102 points · first shared 2018 · 14 comments on HN
  4. 4
    Let's Fix OpenGL [pdf]
    3 people · 106 points · first shared 2017 · 51 comments on HN
  5. 5
    Bril: An Intermediate Language for Teaching Compilers
    2 people · 182 points · first shared 2024 · 28 comments on HN
  6. 6
  7. 7
    Geometry types for graphics programming [pdf]
    2 people · 6 points · first shared 2020 · discussion on HN
  8. 8
    Spectacular
    2 people · 4 points · first shared 2018 · discussion on HN
  9. 9
    Snapshot Testing for Compilers and Compiler-Like Things
    2 people · 4 points · first shared 2022 · discussion on HN
  10. 10
    Statistical Mistakes and How to Avoid Them
    1 people · 292 points · first shared 2016 · 76 comments on HN
  11. 11
    FPGAs Have the Wrong Abstraction for Computing
    1 people · 253 points · first shared 2019 · 135 comments on HN
  12. 12
    Automated Test-Case Reduction
    1 people · 102 points · first shared 2024 · 29 comments on HN
  13. 13
    Help Me Solve an Old Approximate Computing Problem
    1 people · 3 points · first shared 2019 · discussion on HN
  14. 14
  15. 15
    Closed Problems in Approximate Computing
    1 people · 2 points · first shared 2017 · discussion on HN

What HN people wrote when they linked it

hashtag-til · 2025-12-10
For modern compiler and a more direct approach I recommend https://www.cs.cornell.edu/~asampson/blog/llvm.html
photochemsyn · 2023-03-13
Jumping ahead to the video on LLVM, the instructor mentions his prior LLVM tutorial/intro which looks really helpful as an overview, with more informative links. Probably the best get-started tutorial I've come across yet: https://www.cs.cornell.edu/~asampson/blog/llvm.html This is a great resource, I've wanted to learn how to use LLVM to compile to RISCV assembly for a while, e.g. https://llvm.org/docs/RISCVUsage.html
CalChris · 2020-03-07
Retards? No, but I can give you the next best thing. LLVM for Grad Students. https://www.cs.cornell.edu/~asampson/blog/llvm.html
rvz · 2019-11-12
> What would be a good starting point to learn about writing compilers? You also might find the LLVM/Clang kaleidoscope based tutorials interesting to get started having an insight into writing an LLVM-based compiler. Also Adrian Sampson has a great article in introducing LLVM for new-comers [1]. [0] https://llvm.org/docs/tutorial [1] https://www.cs.cornell.edu/~asampson/blog/llvm.html
cvwright · 2017-07-28
Ivy looks great. That said, every time I see a new SSG in Python, I get all excited about it for a minute. Then I remember this bit of advice: "Just use Jekyll". > Jekyll is not better than the rest for any fundamental design reason; it’s better because it’s enormously popular and therefore excels in the long tail of details. > ... > If, like me, you secretly believe that everything is better if it’s written in Python, I still suggest you start with Jekyll (which is done in Ruby). In my experience, using Jekyll does not require writing or reading a single line of Ruby. http://www.cs.cornell.edu/~asampson/blog/jekyll.html This matches my own experience pretty well.
pjmlp · 2020-09-21
Well, I find this even more ironic, giving how wannabe game developers just blindly following Carmack's advises. > Speaking to bit-tech for a forthcoming Custom PC feature about the future of OpenGL in PC gaming, Carmack said 'I actually think that Direct3D is a rather better API today.' He also added that 'Microsoft had the courage to continue making significant incompatible changes to improve the API, while OpenGL has been held back by compatibility concerns. Direct3D handles multi-threading better, and newer versions manage state better.' A few paragraphs below > 'It is really just inertia that keeps us on OpenGL at this point,' Carmack told us. He also explained that the developer has no plans to move over to Direct3D, despite its advantages. https://www.bit-tech.net/news/gaming/pc/carmack-directx-better-opengl/… And for a more up to date remarks > "Lets fix OpenGL" http://cs.cornell.edu/~asampson/media/papers/opengl-snapl2017-preprint… some interesting thoughts, but the shading language is the least broken part of OpenGL. > For everyone saying "Vulkan!", the conclusion is that there is an opportunity for an API between Vulkan and the game engines. I agree. https://twitter.com/id_aa_carmack/status/851397231320150017?lang=en So I can definitely feel the irony.
viraptor · 2023-10-02
https://www.cs.cornell.edu/~asampson/blog/flattening.html Flattened AST. Not conceptually different, but a much better performance of implementation.
dylukes · 2023-09-18
AoVA lacking its own total ordering on indices might be a problem for some use cases, but not for the one that is suggested here: AST nodes. In these cases, the arrays can be just one component (could think of it as an arena) of a heap-ish structure. [1] The cost is that your indices now need to be two dimensional (tag_idx, va_for_tag_idx). But the number of tags is known at compile time and you can optimize storage by packing so that tag_idx is the upper 4-5 bits and va_for_tag_idx uses the rest. See: [1] https://www.cs.cornell.edu/~asampson/blog/flattening.html
fuklief · 2023-08-07
I believe it means flattening the AST, here is a nice blog post about this technique https://www.cs.cornell.edu/~asampson/blog/flattening.html
chubot · 2019-05-02
BTW this is called "program synthesis" and there's a lot of research in the area right now. It only works for tiny programs at the moment. Program Synthesis is Possible https://www.cs.cornell.edu/~asampson/blog/minisynth.html
moyix · 2018-01-17
It's interesting to pair this with Adrian Sampson's (an academic who works on hardware architecture) thoughts, particularly his musings about other vectors: > The second thing is that it’s not just about speculation. We now live in a world with side channels in microarchitectures that leave no real trace in the machine’s architectural state. There is already work on leaks through prefetching, where someone learns about your activity by observing how it affected a reverse-engineered prefetcher. You can imagine similar attacks on TLB state, store buffer coalescing, coherence protocols, or even replacement policies. Suddenly, the SMT side channel doesn’t look so bad. http://www.cs.cornell.edu/~asampson/blog/spectacular.html
Rendello · 2025-10-20
TL;DR: I'm trying to Forth a Lisp. This is long winded, but maybe you have some thoughts here. I've been building a DOM-builder API recently in Rust. The existing options (there are many) tend to use textual templating, which can't reason well about anything, or basic macros, which never support indentation. I wanted something that was just code, where I'd be in full control on the indentation (or lack thereof) programmatically. The closest equivalent is Python's Dominate [1], though its indentation mechanisms are buggy. So I built a system using the traditional tree where Nodes own other Nodes at random addresses, and I built a renderer that renders those nodes and concatenates their strings recursively. It ended up working but it was hacky and very slow for the large inputs. In release mode, it was taking almost a minute to render 70 files, and I want about two orders of magnitude lower. I ran it through profilers and optimized it a bit, but wanted to see if I could simplify the architecture and reduce the amount of work the computer could do. I read about flattening ASTs [2] and how through optimizing that format, you can end up with a sort of bytecode [3]. I also looked into Data-Oriented Design, watching Mike Acton's famous talk [4], Andrew Kelley's talk about DoD in Zig [5], and reading through the DoD book by Richard Fabian [6]. I ended up with something that works quite well for traversing and rendering, which is a stack that can be traversed and rendered in…
Ethan_Barry · 2024-06-11
You got it! By approximate category and in no particular order: ## MISCELLANEOUS - [Low Tech Magazine](https://solar.lowtechmagazine.com), a solar-powered website showcasing the amazing low-tech things you can do with a little ingenuity, - [Stephen Wolfram's Blog](https://writings.stephenwolfram.com) on math, compsci, and everything else, - [Cool Macrophotography](https://www.barrywebbimages.co.uk/Images/Macro/Slime-Moulds-Myxomycete… for amazing pictures of tiny things (WARNING: Time Sink!), ## COMPUTER SCIENCE - [While-True-Do](https://blog.while-true-do.io) has lots of stuff on Linux administration and self-hosting, - [Backend Banter](https://www.backendbanter.fm) for a great podcast on backend development, - [Two Wrongs](https://two-wrongs.com) for statistics and functional programming, - [Math ∩ Programming](https://www.jeremykun.com/) where math and programming intersect! Written by a Googler... - [Paul Bourke's site](https://paulbourke.net/) where you can get happily lost exploring old pages on every topic CS touches, - [Jason Punyon's blog](https://jasonpunyon.com) for some fun algorithms and things, - [Yossi Kreinin's blog](https://yosefk.com/blog) for C, Python, and plenty of non-technical topics, - [Adrian Sampson's academic blog](https://www.cs.cornell.edu/~asampson/blog) for an academic's perspective, - [Cool polyhedra viewer project](https://georgehart.com/virtual-polyhedra/vp.html) if you like geometry, - [Another academic blog on…

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close