C# vs. Python. These two programs do exactly the same thing: load test data from a JSON file and run each line in the data as a test (xUnit vs. Pytest). 51 lines in C# vs 15 lines in Python.
Define a class as the model to use for desearilization and the parsing becomes a single line.
Your point is still valid, python works better for code golf than c# but that c# is either purposefully extra verbose to get the point across or born out of ignorance of c# (hint: expression bodied properties, records and JsonSerializer.Deserialize<T>)
So you wrote a terrible C# implementation and used it to "prove" that Python is a better language?
I would take C#’s superior performance any day of the week
Is this a joke? You've written the c# example to be as long as possible. Programming languages are just tools, for some reason you're producing propaganda. Why? Programming languages are not political parties.
One should see the hoops Python developers have to jump through just to get simple things like properties, or to exclude a few fields from JSON serialization.
No need to have a competition between the languages, and using LoC as comparsion is like comparing a truck and a motorcycle by top speed — it misses the point. C# often forces you to be explicit and Python allows the implicit behavior. So more code doesn’t mean worse — it often means clearer contracts and fewer runtime surprises. OBS! They’re designed with different priorities and trade-offs in mind. So, bottom line: C# = faster runtime, more structure, better for large systems (in my opinion) Python = faster to write, slower to execute and better to use in Data science, ML, AI, and scientific computing than C#. So comparing apples to pears, no need. :)
90% of you C# code is just very awkward handrolling of the parametrize() attribute.
Yeah I’m gonna have to concur with the crowd: the C# is unnecessarily verbose. Not sitting at a computer to golf it, but the intermediate conversion and manual interation of the JSON just to build the data almost feels intentional. There are many factors to consider when choosing between compiled C# vs interpreted Python, but lines of code in a Unit test isn’t one of them.
I would take C# any time. The curly braces alone add to clarity and eliminate formatting errors that lead to different behavior.