Live data from Hacker News

Ask HN: Why use Python or similar?

news.ycombinator.com

1–10 of 72 posts

Ask HN: Why use Python or similar?

#1
Hi,

I am a .Net developer. I love C#, I think it is a great language with fantastic features. I'm looking at new startups job offerings and open source projects source codes a lot. I see a lot of Python or Ruby generally.

I know C# is not open source. That is not the case. You can use Java even Scala. But when I look at performance Python is not near C# or Java. And I can't seem the find features of C# in Python. In my opinion, I feel more comfortable writing C# than Python. What is the reason behind choosing Python if it is slower and lack a lot of features when compared to my preferred language?

I'm not trying to say Python is bad or anything. If a lot of people using it there must be a reason. But I can't see that reason. I'm trying to find it so I can give my time to the langauge.

Thanks

Re: Ask HN: Why use Python or similar?

#2
If you like C# then use C#.

I think there are some people who see C# as a "Microsoft Thing" and won't have anything to do with it.

As for Python, I don't particularly care for it, but many people find it to be a satisfactory language in the sense that you find C# satisfactory. That is, there are lots of good libraries that you can do to get many tasks done quickly. Performance doesn't matter much in applications that are limited by network latency, disk I/O or waiting for database calls to come back.

Re: Ask HN: Why use Python or similar?

#3
In a lot of cases, the "performance" people care about when making language choice is "developer performance". People choosing Python feel (perhaps incorrectly) that they will be more productive and able to build things faster with that language than any of the other ones they considered.

Contrived example: If it will take you 8 hours to write something in Language A that takes 30 seconds to run, or 30 hours to write it in Language B and have it run in 15 seconds, which do you choose? If raw performance isn't the thing that's valuable to your company, maybe Language A is a better choice (even if it's slower than Language B).

Re: Ask HN: Why use Python or similar?

#5

If you like C# then use C#. I think there are some people who see C# as a "Microsoft Thing" and won't have anything to do with it. As for Python, I don't particularly care for it, but many people find it to be a satisfactory language in the sense that you find C# satisfactory. That is, there are lots of good libraries that you can do to get many tasks done quickly. Performance doesn't matter much in applications that…

I'm writing a lot of little batch programs in my job. Like get those 1M records from db. Process them with an algorithm and write to results to this other table. I think you should write faster with Python. But performance of the processing is also important and LINQ helps a lot with the writing time.

Re: Ask HN: Why use Python or similar?

#6
Use what works for you.

In my case, that's python.

It's portable (cross platform), the final product is (usually) the script files themselves vs. an architecture specific "executable", and the language includes "batteries" I find useful in the standard distribution: XML, JSON, and (a limited amount of) HTML parsing, URL parsing and retrieving, regular expressions - stuff that makes what I love to do (data wrangling) easy.

Additionally it has the benefit of being pre-installed on my OS of choice, OS X, and in that specific distribution a very useful third-party library comes pre-bundled: pyobjc

This means that I can write what is, in essence, a plain text file that "runs" on most any recent version of OS X and has almost full access to Apple's ObjC (and C) APIs for controlling their systems. Talk about power!

And if someone on OS X wants to change the program? Nothing more than a text editor is needed. No need to re-compile, install an IDE, or a set of developer tools (outside of the python interpreter itself, which is pretty much on everything but Windows out of the box).

This last reason is specifically why python is very popular in the OS X sysadmin world right now. A large number of great open source OS X tools are written in python.

Re: Ask HN: Why use Python or similar?

#8
And I can't seem the find features of C# in Python.

Which features of C# are you looking for in Python that you can't find?

Also, keep in mind that something that is written in good, idiomatic C# might need to use different idioms in Python in order to make sense as a Python program (and vice versa).

Re: Ask HN: Why use Python or similar?

#9
If you're a C# programmer and you want to stay one, then stay one. There are many startups out there that would love to have a skilled C# programmer, I'm sure.

It might depend on where you're living, I'm not sure.

Also, afaik C# is open source, check out Mono. (somebody correct me if wrong)

Re: Ask HN: Why use Python or similar?

#10
Performance is not the only reason to choose a language. Suitability to the particular project, availability of useful libraries, developer productivity, team members' existing skillset, health of the language's community, speed of change in the language, integration of the language with tools already in use, ease of learning for new team members.

In my experience as a sysadmin running hundreds of different applications written in a wide variety of languages over the years, I've seen some of the worst performing apps written in the "fast" languages you mention, and some of the best performing written in Ruby and Python. Of course, it can go the other way as well. My point is that the quality of the code has as much to do with "speed" as the language chosen.

And I could go on and on about maintainability, ease of refactoring, and more. But I think you probably get the point.

If you're curious about why people like Python, the best way to understand it is to learn it yourself. There are lots of free tutorials online and if you are already a skilled OO programmer, you should have no trouble picking it up. Spend a few weeks investigating it, and you might find that you prefer it, too!

Post reply on HN