
Ask HN: How to Evolve a Legacy .NET Application with Python - ninjamayo
We have a legacy application that is built in Windows Forms and C# but in recent years we&#x27;ve been doing a lot of work in Python. We want to evolve this tool and gradually move all of the backend code to Python but still have a Windows desktop front-end either in Windows Forms (as is currently) or WPF.<p>I have already looked at different options building parts of the core libraries in IronPython or even using a REST web server to call the Python core but quite sure yet. Has anyone does this and are there any example applications that you know off using this idea?
======
eksemplar
Why do you want WPF or windows forms for your application? Especially if
you’re doing a web based backend any way.

I know it’s a tad silly to use web uis for everything, but the truth is, that
it’s where almost all of the ui innovations lie right now.

It’s not just for design either, it’s also automation. Like if you use Django,
a lot of the basic forms for inputs will actually write themselves based on
you’d datamodel.

------
shoo
I've seen:

* .net product with embedded ironpython for scripting ;

* desktop client talking to a backend server that happened to be implemented in python ;

* desktop application implemented as a collection of command line tools for batch processing, with a windows desktop frontend. Some of the command line tools were implemented in python and bundled using py2exe, other command line tools were written in other languages

these were all proprietary things with varying numbers of enterprisey
customers, apologies, no sample code.

~~~
ninjamayo
A collection of command line tools is something we tried years ago and didnt
work very well unfortunatelly. Tempted to go down the REST server route.

------
backslash_16
Using Python via IronPython and trying to get C# to talk to Python sounds like
it could have lots of issues. I would go with a Python HTTP(S) API that gets
called by the Winforms or WPF UI.

This has the added benefit of forcing you into a more decoupled architecture
and allows you to easily add a different type of UI (web, phone app, etc..)

~~~
ninjamayo
I think I prefer the RESTful API idea more than anything because it could keep
the architecture decoupled. The only thing that worries me is having issues
installing this to client desktops. A lot of our clients are banks and
insurance companies so I wouldn't want to create issues with our installation
and get things blocked by client IT.

~~~
shoo
yep, you'll definitely have to work through issues around getting network
access, meeting requirements for keeping data adequately secured in transit
and at rest. some places might really not want to run external servers, and
run the server(s) on their premises

------
LiamPa
Nearing completion of something similar:

Phase I C# -> python / Django / some simple html forms

Phase II (in progress) Django rest backend / react front end

We host the application internally, all our team members know at least basic
python so updates are easy and deployment is much quicker.

------
penetrarthur
What is the reason to rewrite a legacy c# code to python?

~~~
eksemplar
Why wouldn’t you?

C# is so unproductive compared to python. Everything is so low level and
verbose, nuget packages are mostly undocumented and unsupported, entity
framework is terrible, no graphql tools.

I mean, we still do a lot of c# at our place, but every chance we get, we use
either python or JavaScript with an end goal of completely leaving c# behind.

