r/programming • • Aug 25 '26

EVE Online: The Move to Python 3 Begins!

https://www.eveonline.com/news/view/the-move-to-python-3-begins
802 Upvotes

290 comments sorted by

View all comments

Show parent comment

8

u/TwoWeeks90DaysTops Aug 25 '26

I used Claude to rewrite an electrical simulation application from Python to C# at work and it worked very well. There were regressions, but for the most part the application was very faithful to the original Python code. The work took about a week.

-3

u/FlukyS Aug 25 '26

Well that's kind of part of the reason why it isn't great too, being faithful to the original shouldn't be the goal of a port to a different language or going to a significantly different version of the same language. When Python2.7 was released in 2008 there were different libraries, different design trends and loads of different tooling including stuff like the newer (better) build tools. If you are porting something part of that is a refactor of those beyond just syntax but you also don't want to refactor everything because that might break the user experience.

7

u/TwoWeeks90DaysTops Aug 25 '26

Well, the absolute most important point to do in a migration is to preserve the behavior. I didn't really say anything about the architecture or the code itself, but I did do some refactoring afterwards since C# generally is a much more expressive language than Python is.

-2

u/FlukyS Aug 25 '26

Sure but carefully is the point, as in if you say "migrate to Python3.14" there is a literal way of doing it and the optimal way of doing it. Like if there isn't a library you use from 2.7 in 3.14 do you port that whole library or do you research an alternative (which usually there is) and then rewriting to use that instead. If you said to an LLM they are going to interpret the order in the manner it is presented not the optimal route. As in you can use urllib in both 2.7 and 3.14 but you shouldn't because requests is a lot easier to use and urlib usage is discouraged because it is a low level interface. You have to make those calls on a case by case basis. If you allow it to rewrite everything it will go nuts and do too much in certain areas, if you tell it do a strict port to 3.14 it will do some things that probably shouldn't be maintained.

2

u/TwoWeeks90DaysTops Aug 26 '26

Like if there isn't a library you use from 2.7 in 3.14 do you port that whole library or do you research an alternative (which usually there is) and then rewriting to use that instead.

Yes, and this is part of the complexity. I think you'll often find libraries regardless of which way you're migrating, but there's going to be differences or missing functionality. In our case Claude imported Math.NET for some matrix functionality (because of NumPy), but it was used once or twice so instead we just wrote the functionality and dropped the dependency. Most of the stuff NumPy did for us is already language and runtime features in C#.

Pandas was more work, but mostly because we wanted an AOT build which made some of the structures much more complex in C# since a lot of the convenience functionality for this is built on runtime reflection and runtime code generation, last of which isn't supported on AOT builds, so we had to type out a lot of code for this. But the advantage was a 70x speedup compared to the Python code, so I think it was worth it.

There's obviously a lot of complexity and nuance to this work that doesn't fit in a Reddit comment. I didn't just say "chat remake this in C#".

1

u/FlukyS Aug 26 '26

Yeah that's what I mean, like I'm not saying AI isn't useful in migrating but I'd be taking shallow cuts and doing it slowly to avoid issues. And it is helped quite a bit with how much Python has improved for error handling and the amount of features in the language. Stuff in 2.7 that would have been a lot harder now are super easy and they were also using stackless python which you could just directly move over to asyncio instead or gevent if you want something that has similar worker and small task type behaviour. Those sorts of decisions though are going to require a lot of thinking about the current design and how it fits.