HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
facebookarchive
pfff
OCaml2011–2025
facebookarchive / pfff · Archived

pfff

Tools for code analysis, visualizations, or style-preserving source transformation.

25Distinct people
39Mentions
1Explicit recommenders
2.4KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Tools for code analysis, visualizations, or style-preserving source transformation.

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

That's definitely a consideration, depending on your goals. For many language projects, I don't think you need more than one person for the front end. For libraries and code…

chubot used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 4:00:59 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year39 dated mentions

Observed mentions: 2011-07-18 17:03:36 UTC to 2025-02-15 03:20:35 UTC.

02468102011-01-01 00:00:00 UTC to 2012-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20112012-01-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 7 mentions; 3 submissions, 4 comments2013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 5 mentions; 0 submissions, 5 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 10 mentions; 1 submissions, 9 comments2016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20112011-01-01 00:00:00 UTC2012-01-01 00:00:00 UTC312
20122012-01-01 00:00:00 UTC2013-01-01 00:00:00 UTC734
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC303
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC505
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC1019
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC101
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC211
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC101
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC202
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC211
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC000
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

From the project README

An excerpt from the repository, fetched Nov 13, 2026.

Read the project’s introduction
pfff pfff is a set of tools and APIs to perform static analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code. There is good support for C, Java, Javascript and PHP. There is also preliminary support for other languages such as C++, Rust, C#, Html, CSS, Erlang, Lisp, Haskell, Python, OPA and SQL. There is also very good support for OCaml code so that the framework can be used on the code of pfff itself. For each languages there are mainly 2 libraries, for instance parsing_php.cma and analysis_php.cma, that you can embed in your own application if you need to process PHP code. See the demos/ directory for example of use of the pfff API. See also docs/manual/Parsing_xxx.pdf and docs/manual/Analyzis_xxx.pdf for more documentation on how to use or extend pfff. pfff is also made of few tools: pfff, which allows to test the different parsers on a single file scheck, a bug finder stags, an Emacs tag generator sgrep, a syntactical grep spatch, a syntactical patch codemap, which is a gtk and cairo based source code visualizer/navigator/searcher leveraging the information computed previously by pfff_db and codegraph. codegraph, a source code indexer and package/module/class dependency visualizer codequery, an interactive tool a la SQL to query information about the structure of a codebase using Prolog as the query engine pfff_db, which does some global analysis on a set of source files and store the data in a marshalled form in a file somewhere (e.g. /tmp/db.json) For more information, look at the pfff wiki here: http://github.com/facebook/pfff/wiki/Main as well as the docs/manual/ directory. Usage for pfff: $ ./pfff -parse_php demos/foo.php or $ ./pfff -dump_php demos/foo.php You can also look at ./pfff --help Usage for pfff_db: $ ./pfff_db -lang ml -o /tmp/pfff.json ~/pfff to analyze all the .ml and .mli files under ~/pfff and store metadata information (the database) in /tmp/pfff.json Usage for codemap: $ ./codemap ~/pfff This should launch a gtk-based GUI that allows you to visualize source code and perform some code search. Usage for codegraph: $ ./codegraph -lang cmt -build ~/pfff to generate a graph_code.marshall file in ~/pfff containing all dependency information about the pfff codebase using the typed bytecode .cmt files generated during the compilation of pfff. $ ./codegraph ~/pfff This should launch a gtk-based GUI that allows you to visualize source code dependencies. More information Look at the pfff wiki here: http://github.com/facebook/pfff/wiki/Main
Read the full README on GitHub

What Hacker News says

10 sources
Cheers for the efforts, but that's a poor DSL or an atempt to create an Aspect-oriented version of Hack. You've gorgeous tools at facebook like for example 'pfff' [0] to play with ASTs, these could be used to build wonderful things given enough time. I suppose the ultimative goal is to allow business people to design workflows and let the tool generate the required code automatically. (I guess that's what Flow Based Programming is trying to achieve.) Kinda possibly with high-level specifications defined in languages better suited to the task like Racket, Rebol/Red, Xtend/Scala etc. There is an interesting presentation by ThoughtWorks – Neil Ford: Building DSLs in Static and Dynamic Languages [1] However I thought you might find this the EPFL / ETH Summer School on DSL Design and Implementation very useful. They not only come with presenta
Read the rest
tions, but also code in Scala, Racket, Haskell et. al. I am currently working in a huge project with about >30 people working on building an MDD (Model Driven Development) platform for visually/declaratively writing things for the systems we use internally. These will be able to create models out of code and even fix API incompatibilities automatically. [2] Excuse the Unicode, I got bored ⬬══════━━━━━━──⋯𝅖܅܅܅܅﴿⌁⏧⌁﴾܅܅܅܅𝅖⋯──━━━━━━═══════⬬ [0] https://github.com/facebook/pfff [1] http://www.intertech.com/resource/usergroup/Neal_Ford-Buildi... [2] http://vjovanov.github.io/dsldi-summer-school/program.html
In Writing code that writes code – Hack Codegen
I work on AOSP, which is a fairly larger code base. During the early years, the documentation on the internals of Android was close to non-existent. Plenty of tutorials in Mandarin/Cantonese, but not many in English. A good way to get hang of the code base was to read it (usually using a tool like sourcegraph [0], pfff [1], open-grok [2], doxygen [3], javadocs [4]). Although a lot of people have argued that code is to be not treated like literature [5], but in this case, there was no choice. The second step was to see if assumptions about the what the code does is correct. This is usually achieved by adding log statements, writing sample apps, and debugging in general. Repeat the steps above, over and over again. Checklist: 1. No matter what you do, you absolutely need to document everything you understand / misunderstand about the code b
Read the rest
ase. 2. Never underestimate value of having a different pair of eyes look at code you have hard time reasoning about. 3. Be in constant search for resources (like books, blogs) available on the code / topic of your interest. You'd learn amazing amount by reading through other people's analysis. Stackoverflow is a great start. Heck, you can even ask well thought-out questions on Quora/Stackoverflow. 4. Hang out on related IRC channels / community mailing lists. For things written in esoteric languages such as OCaml, I found these to be pretty helpful. 5. You could blog about it, share the information you know over email lists, setup wikis; and people who know better would correct you. Its a win-win. Good luck. [0] http://sourcegraph.com/ [1] https://github.com/facebook/pfff [2] https://opengrok.github.io/OpenGrok/ [3] http://www.stack.nl/~dimitri/doxygen/ [4] http://www.oracle.com/technetwork/articles/java/index-jsp-13... [5] http://www.gigamonkeys.com/code-reading/
In Ask HN: How do you familiarize yourself with a new codebase?
I'm not sure how Facebook does it, but there are a lot ways to get something like this up and running. I have experience with using Facebook's pfff [0]. Its codegraph feature builds up a graph of code that you can query. Doing something like 'get me a list of all classes this node depends on' on Java code is as simple as executing 'Graph.use(node name)' where nodename can be a class, package, method... Pfff supports many more languages, and its built on OCaml. Facebook has a history of open sourcing stuff, I hope they open source their tools mentioned in the talk. [0] https://github.com/facebook/pfff
In Notes from Facebook's Developer Infrastructure at Scale F8 Talk
chubot·Mar 12, 2015Recommendation phrase
That's definitely a consideration, depending on your goals. For many language projects, I don't think you need more than one person for the front end. For libraries and code gen, you definitely need contributions. IMO it's actually advantageous to have a compact description of a lexer, parser, and AST that one person edits or very few people edit. That's your language design. At one point I thought: "If ML is so great, then why don't you see it more often in the real world?" And then the revelation was that Python essentially uses ML to describes its AST: http://svn.python.org/projects/python/tags/r32b1/Parser/Pyth... This is Zephyr ASDL, an ML-inspired DSL for describing ASTs. A lot of ML people may recognize Andrew Appel from the authors list: https://scholar.google.com/scholar?cluster=11682730813888505... So my favorite language's
Read the rest
AST is described with ML!!! And has been for 10+ years. (Python has a Grammar file as well in a different syntax). I'm actually interested in a hybrid architecture: an interpreter where OCaml generates the byte code, and then C++ executes it. I think you can produce extremely compact and flexible interpreters with this architecture, and there are several other advantages to dividing it this way. The downside is perhaps a more complex build process, but the OCaml toolchain is quite nice actually, and I have compiled it from scratch. It's head and shoulders above Haskell in that regard. OCaml can produce .o files and link with C/C++, so you still get one executable. I looked at your Wren language which I like a lot. I did wish the front end was more high level and not in C, but that's just me :) There are a lot of people coming around to OCaml. Facebook is using it for Flow and pfff language manipulation: https://github.com/facebook/pfff (I suspect Google's code analysis tools would be cut down in size by 5x if written like this in OCaml.) And Hack, the statically typed PHP, is written in OCaml. And there are several more minor languages like HaXe and another one that are OCaml. So if you're looking for contributions from language experts, there's definitely a lot that are familiar with OCaml.
In How to Implement a Programming Language in JavaScript

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.