top | item 40300964

(no title)

williamjackson | 1 year ago

The fact that this is not a manual reimplementation, but a "transpilation" of the psql source from C to JavaScript, makes this super interesting to me.

    From the Postgres master branch (17devel), we take exec_command_d, exec_command_list and exec_command_sf_sv from command.c, and all of describe.c and sql_help.c, from src/bin/psql.
    We use plenty of RegExp search-and-replace to turn this C code into valid JS syntax.
    We implement some C library functions, such as strlen and strchr, and some Postgres support functions, such as printTable and printQuery, in JavaScript.
Read more here: https://neon.tech/blog/bringing-psqls-d-to-your-web-browser

discuss

order

ivanjermakov|1 year ago

When I started my programming journey I thought I could just "translate" Pascal to C++ just with search/replace and minor adjustments. Turns out sometimes it's the best approach :)