Rapture in Everything

C# keeps getting better! Probably!


I've discovered C# and Python around the same time. I think C# 3 was new then, which places it... some 14 years ago. (😱😱🤯)
Over the years I've used both, for hobby projects as well as professionally (Python professionally only a little, though.)

I tended to use C# for more complex projects (like the book club app, Obskurnee) and Python for simpler stuff (such as csv-to-sqlite), one-off scripts and the like. I've also attended a handful of conferences for both, and the Python ones were always better in all significant ways.

When it comes to the languages themselves though, I've recently realized I almost never use Python anymore.

C# and .NET are both open-source and cross-platform now, and with C# 10 and .NET 6 (LTS) released recently, even more changes making C# a viable language for one-off scripts have been introduced. Even before then, LINQPad made it as approachable as it can get.

Let's assume you have downloaded the software you need, you open up an editor (here's to hoping you knew not to use Python's default IDLE), and start coding. Python's dynamic nature (most notably, its use of duck typing) is often praised for its flexibility in scenarios like these - you don't have to dance around static typechecking constraints with every little change. And yes, that often is true. But it often ended up shooting me in the foot. With one-off scripts, I tend to change things around a lot, and making the typechecker happy tends to be quicker than troubleshooting the same issues at runtime. Add to that the occasional annoyances with encodings, virtualenvs and pip, running on Windows and similar little issues, and it seems to me that rather than trying to solve them and not forgetting to use type annotations, I might as well do it over in C#. That way I also automatically get executables that simply run on both Windows and Ubuntu.

In some areas I do stil find Python more comfortable: things like reading CSV files or working with SQLite databases require less boilerplate (though again, I've encountered plenty issues with the latter on Windows.)

And perhaps there's also something to be said about C# getting more and more complex with each iteration. Yes, many changes are aimed at making it more accessible, more flexible, more able to cover various common use-cases. Added support for top-level namespaces, global usings, immutable records, improved options for interface definitons, and many others, do help. And LINQ is just astoundingly useful.  However, there also are more and more artefacts of its evolution visible (like the one with delegates and lambdas and associated mechanisms), and understanding the language as a whole is a more difficult task each year.

I guess I'm glad I've started ages ago with both these languages when they were 'simpler' and only need to keep up a bit. 😁 I'm really quite enjoying C# at the moment. And I hope to go to the next PyCon, if I get the chance.