Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, V8's regex library is not written in C. V8 compiles its regular expressions to machine code at runtime. The availability of the compiler at runtime can be a liability for things like startup time or memory use, but can also be a key advantage in situations like regular expression parsing or packet processing.


You need a regex library to turn a regex into machine code. What the parent means is that the V8 regex library compiles them, while the one used in the C code merely interprets the regex.

(The C and C++ thing is just adding confusion here)


Well it's not written in JavaScript, so as the OP said it's either C or C++.


The code that's doing the actual matching is not written in C or C++. It's an internal regex bytecode compiled directly to machine code.


Regular expressions are part of the JavaScript language, so they're as much "written in JavaScript" as any other language construct.

The point is that a regular expression compiled by V8 (which is not written in JavaScript) is faster than a regular expression as compiled by some particular C compiler. Of course a C compiler could possibly be written to understand calls to a standard regexp API and compile those to binary.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: