Top
Best
New

Posted by yakkomajuri 1 day ago

Why we migrated from Python to Node.js(blog.yakkomajuri.com)
221 points | 264 commentspage 6
pphysch 1 day ago|
Who is the audience for a post like this? Presumably HN, since the author invoked PG.

But who is "we rewrote our stack on week 1 due to hypothetical scaling issues" supposed to impress? Not software professionals. Not savvy investors. Potential junior hires?

rs186 1 day ago|
Probably people who write too little code but read too many blog posts
adamnemecek 1 day ago||
This feels like an article from 2013.
danudey 1 day ago||
I had a python script I was writing that basically just needed to the same shell command 40 times (to clone images from X to Y) and a lot of the time was spent making the request and waiting for the data to be generated so I figured I'd parallelize it.

Normally I do this either through multiprocessing or concurrent.futures, but I figured this was a pretty simple use case for async - a few simple functions, nothing complex, just an inner loop that I wanted to async and then wait for.

Turns out Python has a built in solution for this called a TaskGroup. You create a TaskGroup object, use it as a context manager, and pass it a bunch of async tasks. The TaskGroup context manager exits when all the tasks are complete, so it becomes a great way to spawn a bunch of arbitrary work and then wait for it all to complete.

It was a huge time saver right up until I realized that - surprise! - it wasn't waiting for them to complete in any way shape or form. It was starting the tasks and then immediately exiting the context manager. Despite (as far as I could tell) copying the example code exactly and the context manager doing exactly what I wanted to have happen, I then had to take the list of tasks I'd created and manually await them one by one anyway, then validate their results existed. Otherwise Python was spawning 40 external processes, processing the "results" (which was about three incomplete image downloads), and calling it a day.

I hate writing code in golang and I have to google every single thing I ever do in it, but with golang, goroutines, and a single WaitGroup, I could have had the same thing written in twenty minutes instead of the three hours it took me to write and debug the Python version.

So yeah, technically I got it working eventually but realistically it made concurrency ten times worse and more complicated than any other possible approach in Python or golang could have been. I cannot imagine recommending async Python to anyone after this just on the basis of this one gotcha that I still haven't figured out.

pdhborges 1 day ago||
Why don't you post the original broken Python code.
triyambakam 1 day ago||
I mean I know it sounds snarky but it just sounds like you weren't awaiting the tasks properly
submeta 1 day ago||
I was about to migrate a legacy system written in Python/ Flask to FastAPI and React (frontend). But the sentiments here seem to suggest that FastAPI is not the best solution if I need async? So go with Next.js?
oceansky 1 day ago|
Fastapi is perfectly fine for async. In fact, it's built with async in mind.

I say that as someone who prefers JS promises: you likely won't face issues with either.

fnord77 1 day ago||
Do we still need ORMs in the age of AI-assisted coding?

I started ripping them out of a java system even before that.

dionian 1 day ago|
We're on the same wavelength, i have decades of ORM experience. It was the first thing i woudl do in any project. Now it can just be vanilla JDBC with tons of duplicated boilerplate. AT least in the early stages.
fnord77 1 day ago||
spring's JdbcTemplate has a nice query pattern that gets rid of a lot of boilerplate by passing each fetched row to a lambda
zzzeek 1 day ago||
Good decision, judging by their general level of impatience with things they would have hated my ORM :).

Also I think the node approach is probably still more performant than FastAPI but that's just a hunch.

Hopefully they won't have security issues because someone hijacked the node package that sets the font color to blue or passes the butter or something.

jgehrcke 1 day ago||
Thank you for that comment, Mike :-) I was looking for that type of response here :-). As expressed many times: thank you for your work.
antod 1 day ago||
Passes the butter is a euphemism for churn?
zzzeek 1 day ago||
it's from rick and morty that was referenced here last week with a post about robots that pass butter
zeroq 1 day ago||
"We've decided to fix our problem by using Perl. Now we have two problems."
goalieca 1 day ago||
It sounds like they are just saying they should have used the tool they were most familiar with on day 1.
pier25 1 day ago|
They did. That's why they used Django.
nurettin 1 day ago||
python async is just a phase you grow out of and go back to mpsc where you don't see color and stack starts to make sense again.
gjvc 1 day ago|
djanko (sic) out fastapi in
More comments...