12. A non-transitory computer readable medium comprising instructions that, when executed by a computer processor, perform a method for staged compilation of a declarative program comprising: receiving the declarative program; parsing and semantically checking the declarative program; translating the declarative program into a relational algebra machine (RAM) using a modified semi-naïve algorithm, wherein the modified semi-naïve algorithm is a semi-naïve algorithm with modifications comprising unrolling two iterations of a fixed-point loop; performing a translation of the RAM into code of an imperative programming language to obtain a translated RAM; generating specialized extractor code in the imperative programming language, wherein the specialized extractor code comprises a reduced set of relations extracted from the declarative program; generating query API code in the imperative programming language; compiling the translated RAM, the specialized extractor code, and the query API code to obtain a program analysis module; receiving a program for analysis; providing the program as input to the program analysis module; extracting a plurality of input relations from the program; and performing, using the plurality of input relations, a static program analysis on the program.
12. A non-transitory computer readable medium comprising instructions that, when executed by a computer processor, perform a method for staged compilation of a declarative program comprising: receiving the declarative program; parsing and semantically checking the declarative program; translating the declarative program into a relational algebra machine (RAM) using a modified semi-naïve algorithm, wherein the modified semi-naïve algorithm is a semi-naïve algorithm with modifications comprising unrolling two iterations of a fixed-point loop; performing a translation of the RAM into code of an imperative programming language to obtain a translated RAM; generating specialized extractor code in the imperative programming language, wherein the specialized extractor code comprises a reduced set of relations extracted from the declarative program; generating query API code in the imperative programming language; compiling the translated RAM, the specialized extractor code, and the query API code to obtain a program analysis module; receiving a program for analysis; providing the program as input to the program analysis module; extracting a plurality of input relations from the program; and performing, using the plurality of input relations, a static program analysis on the program. 18. The non-transitory computer readable medium of claim 12 , wherein the declarative program is expressed in Datalog.