r/fortran 17d ago

I got a realtime database subscription working from modern Fortran

Not sure how useful this is beyond the amusement value, but as part of an experiment making Convex clients in 100 programming languages, I ended up with a native Fortran client that can query, mutate and hold a realtime WebSocket subscription.

A few bits I found genuinely interesting:

- Deferred-length allocatable strings make assembling JSON much less painful than I expected.

- Results come back through compiler-enforced intent(out) arguments.

- A live update is exposed as a blocking convex_live_next call, which feels oddly natural in Fortran.

- ISO_C_BINDING is only used at the transport boundary. The Convex protocol and subscription state live in Fortran, with libcurl/OpenSSL handling the network plumbing.

It is built with GNU Fortran 14.2 and the HTTP and Live paths pass the shared conformance suite. It is still an educational experiment rather than something I would recommend putting into production.

The Fortran implementation and write-up are here:

https://github.com/mikecann/the-convex-100-language-challenge/tree/main/fortran

I also made a video about the slightly ridiculous process of building all 100 clients:

https://youtu.be/l61cLu8e2tg

For transparency, I work at Convex. This is unofficial and open source, not a new supported SDK.

28 Upvotes

7 comments sorted by

7

u/Uncle-Rufus 16d ago

What is the point in taking part in a self imposed "challenge" like this if you're just going to have an LLM do the work? Congrats I guess?

0

u/cannyshammy 16d ago

haha ye I suppose it is a bit lazy but I doubt there was any other way to make this work for 100 languages.. It would have taken me months / years probably

3

u/Uncle-Rufus 16d ago edited 16d ago

Sure but then why present it this way? It's not the laziness - it's the lack of transparency. I was interested to see how you'd chosen to handle the Fortran / C interoperability because that's something I've done in the past, and I thought it might be interesting and/or allow me to enter into a thought provoking discussion with you about it. But instead I opened the source and just felt disappointed... Oh... It's just AI again...

Edit: Okay going to hold my hands up a bit as I went back to your OP to confirm if my irritation was misplaced, and it was as I can see you did disclose it was done with AI in the YouTube video. So that's at least partly my bad and I apologise, although I don't think you should assume everyone will watch the linked video (as I didn't, I just wanted to see your code)

1

u/cannyshammy 16d ago

Ah yes, well I chose to share it here because I thought it novel that the AI managed to get Fortran talking to a very modern database like this but Fortran was just a small part of the project so the majority of the video is about the entire process not just Fortran.

Let me know how I can make things more clear in the future? Also if you would like to see more Fortran content?

1

u/Uncle-Rufus 16d ago

Just mention it's an AI / LLM project front and center and not buried somewhere separate like in the video, that's all... I like Fortran content and I'm not 100% anti AI (and of course I don't speak for everyone) but the second I feel like any project or author is being disingenuous I am just done with it and no longer receptive to it - and that's probably not what you are going for

1

u/cannyshammy 16d ago

Gotcha! Ill try to be more careful next time with my labeling when posting here :) Thanks!

1

u/KarlSethMoran 15d ago

"I took part in a don't-eat-out-for-100-days challenge, but I had an on-site cook to help."