Skip to content
0:00 / 0:00

#compile-timeregularexpressions#metaprogramming#c++20

CppCon 2018: Hana Dusíková “Compile Time Regular Expressions”

CppCon

189K subscribers • 101 videos on Hallway • Conference channel

YouTube
  • Recommended by 2 people: 1 on Hacker News and 1 on Lobsters.
  • Presented by Hana Dusíková, Avast Senior Researcher
  • Linked in the descriptionCppCon/CppCon2018

Advanced. Deep dive for people who know the field.

14K views8 years ago2 recommendations

Programming languagesSystems programmingC++Compilers and interpretersPerformance and optimization

Hana Dusíková presents a C++ library that builds regular expressions from compile-time strings to avoid runtime parsing costs.

CppCon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2018 — I will present a library that utilizes a feature of C++20 to build regular expressions from compile-time strings. This is a novel approach that doesn't have ordinary disadvantages of other regular expression implementations like having to use a linked library or a run-time cost of parsing and interpreting an internal finite machine. You will see implementation details of the library and problems I have run into during its writing. In the last part of the talk, I will compare other implementations of regular expression engines and show compiled code in Compiler Explorer. — Hana Dusíková, Avast Senior Researcher Hana is working as a senior researcher in Avast Software. Her responsibility is exploring new ideas and optimizing existing ones. She also propagates modern C++ techniques and libraries in internal techtalks and gives talks at local C++ meetups. She studied computer science at Mendel university and subsequently taught several courses there, including: Data Structures, Computability and Complexity, and Formal Languages and Automata. — Videos Filmed & Edited by Bash Films: BashFilms.com *-----* *--* *-----*

Why it's here

2 people recommend this

What people say. Recommended as an excellent demonstration of C++ metaprogramming and compile-time regular expression optimization.

canucker2016on Hacker News • Recommends

On “The Impossible Optimization, and the Metaprogramming to Achieve It”

FYI: This is a C++ template version of compile time regex class. A 54:47 presentation at CppCon 2018 is worth more than a thousand words... see link to this video followup CppCon 2019 video at link As the above github repo mentions, more info at link

olliejon Lobsters • Recommends

Compile Time Regular Expressions (2018)

nikki93on Hacker News • Mentions

On “C++20 has been approved”

> Passing strings into a templates ... wouldn't work in C++ ... link to this video Here's an example of parsing regular expressions in C++ at compile time. Code here: link

lcvwon Hacker News • Mentions

On “Compile time regular expression in C++”

One of the stated benefits is that the compiler optimizer can optimize the regex state machine that gets created, resulting in significantly faster match times at runtime. There are some benchmarks if you look up her cppcon talk about the library iirc. Edit: here is her talk, at 39 minutes she shares the benchmarks. link to this video

u/open_source_guavain r/ProgrammingLanguages • Mentions

On “Video: Derivative of a Regex?! (Brzozowski Derivative)”

Added this video to my list, thanks for posting. I'll only at one minor caveat to your comment about all DFAs being equally efficient. Since DFAs can be quite large, many implementations never explicitly instantiate them. Instead, they directly simulate their NFAs, and it's actually quite fast. E.g.: https://swtch.com/~rsc/regexp/regexp1.html and link to this video So in practical terms, I won't necessarily conclude they have the same runtime just because they are all DFAs. Having a compact data structure can mean huge gains in speed if it can be loaded into a CPU cache.