C or C ++ for writing a compiler?

I want to write a compiler for a custom markup language, I want to get optimal performance, and also want to have a nice scalable design.

A multi-paradigm of a programming language (C ++) is more suitable for implementing modern design patterns , but I think it will degrade performance a bit (like RTTI ), which more or less can make C a better choice.

Interestingly, this is the best language (C, C ++, or even Objective-C) if someone wants to create a modern compiler (in the sense of adhering to modern software engineering principles as software), which is fast, efficient and well designed.

+3
source share
6 answers

The “expensive” C ++ functions (for example, exceptions, virtual functions, RTTI) simply don't exist in C. By the time you mimic them in C, you are likely to get something, at least as expensive as it is in C ++, but less known, less documented, etc. (let it look like this: the authors of the compilers are not stupid, but perhaps you can implement the function "better" than they are, this is not particularly likely).

In the other direction, templates (in one example) often make it relatively easy to write code that is much faster than practical in C. For just one obvious example, C ++ code using std::sortwill often be two to three with as fast as the equivalent C code using qsort.

: , ++ , C, , ( - ) . - . , ++ - . , , - .

+18

++ " , ". - . .

+4

OCaml? . - , .

OCaml , C ++. , .

F # - , .NET.

+3

, C , .

, lex yacc ( flex bison).

, , ++, Java - .

+1

, , , C/++ - . , , ? ? ? 60 + , , , .

( + flex , ). C ++ . C, bison C, C, . , , ++, AST .

ML . , , ( , ). , , bison ( , C/++ bison).

. . C . , - , , (, , , , )

+1

, , , , , C/++ ( ) .

/ , . , - : "OO - ", - : " , , ".

+1

Source: https://habr.com/ru/post/1783986/


All Articles