3 ms·
How would you implement something like Google Protocol Buffers without code generation for C++ clients? What about lex and yacc, or ANTLR? They all use code ge
by jzwinck 14y ago
How would you implement something like Google Protocol Buffers without code generation for C++ clients?
What about lex and yacc, or ANTLR? They all use code generation. Should we always write parsers by hand?
- meaty 14y agoYou can talk to protobufs without code generation. I'd implement something zeromq style instead however with a higher level payload abstraction I.e. BSON. Lex, yacc and antlr are pretty primitive tools to be honest. Ive written NFA->DFA parser engines which have no code generation step. The parser state and model are just data as per any other piece of functionality. To boot, they are safer than the numerous holes that bison etc leave open through their templating approach. I've written a couple of fairly extensive compilers so please don't assume I'm ignorant of the problem domain.