1

For my undergraduate final year project, I want to study functional programming and intraoperation parallelism in DBMS. Specifically, I am going to investigate into whether FP could be useful for implementing operations as selection, projection, and join (these operations could easily be parallelized and FP's referential transparency could give some benefits here).

I figured that Postgres is a good DBMS to study since it makes use of intraoperation parallelism. However, Postgres is written in C. There is no meaningful support for FP in C. Is there a way to achieve what I have in mind? I want to modify some parts of Postgres source code and these modifications involve functional programming.

  • 2
    *"Postgres is written in C. There is no meaningful support for FP in C."* Sounds like you need to have a long talk with your advisor. – user3386109 Dec 10 '20 at 09:00
  • So you mean that it's not doable at all? @user3386109 – BovineScatologist Dec 10 '20 at 09:08
  • I think that there are probably easier paths to follow, and your advisor is the one to help you find the best path. – user3386109 Dec 10 '20 at 09:15
  • "FP's referential transparency" Are you one of those FP people who thinks referential transparency doesn't apply to stateful/non-F programming (for which it was developed)? – philipxy Dec 10 '20 at 09:42
  • I think one can write referentially transparent imperative programs, although I did not know that referential transparency was developed for non-functional programs. Can you give a reference to that? However, other features of FP languages such as first-class functions (which can be achieved in a messy way in C using function pointers) and lazy evaluation could be useful too when it comes to parallel processing of large records. – BovineScatologist Dec 10 '20 at 10:11
  • See Reddy's 2 answers [here](https://stackoverflow.com/q/210835/3404097), which also link to Strachey's seminal paper & address the common FP culture misconception. See Scott & Strachey, Stoy, Reynolds, Tennent for early stuff. See textbooks on programming language semantics. – philipxy Dec 10 '20 at 11:11

1 Answers1

2

It gonna be an endless, unspoken pain... but, technically, you can do that. C natively supports higher order functions. Generics are supported as well either through metaprogramming or void *. In theory that's sufficient.

However.. as I said, on practice you gonna suffer as hard as sinner in hell. Runtime won't provide you desired support, nor compiler, nor IDE. You gonna be all alone.

Zazaeil
  • 3,900
  • 2
  • 14
  • 31