Live data from Hacker News

Ask HN: Why Python?

news.ycombinator.com

1–10 of 22 posts

Ask HN: Why Python?

#1
I am not looking to be controversial. It is something I have been genuinely thinking for sometime.

I don't understand the need for Python as a general-purpose programming language. How are organizations using Python at scale? I understand that it is a good scripting language but other than does it offer anything substantial compared to other general-purpose languages like - Node, Go, C# or even Java? These languages can also be used at scale without worrying about the low-level details, however, I cannot say the same for Python.

Apart from AI / ML, where Python is heavily used by interfacing with C/C++/CUDA libraries is there any place where Python stands out on its own without merely acts as a frontend to other languages?

Am I missing something here?

Re: Ask HN: Why Python?

#2
You bring up a valid question. The value of Python as a general-purpose programming language comes from a variety of its attributes.

Readability and Simplicity: Python was designed to emphasize readability and simplicity, making it an excellent language for beginners and for prototyping complex systems. This simplicity means developers can spend less time understanding the code and more time creating functional elements. Even experienced programmers appreciate Python for its simplicity and how it encourages good programming style.

Wide Range of Libraries: While you mentioned AI/ML/Data, it's worth noting that Python's rich set of libraries (both built-in and third-party) makes it useful for a massive array of tasks beyond just those fields. It has powerful libraries for web development (Django, Flask), data manipulation (Pandas), image processing (PIL, OpenCV), GUI development (Tkinter, PyQt), and many others. This versatility allows Python to be used in many different problem domains.

Glue Language: Python is also often used as a "glue" language to connect different components of an application. Since it's easy to interface with C/C++, it can be used to control and orchestrate low-level modules while providing a high-level interface to the user.

Automation and Scripting: Python's simplicity and wide range of libraries make it a popular choice for automating tasks, which is a large part of what any scaled system needs to handle. These tasks range from managing file and directory operations to web scraping or interacting with network resources.

Testing: Python is often used in the development environment for testing other code. Its simplicity allows for writing tests quickly, and its wide range of libraries allows for testing various programs.

Education and Research: Python is also widely used in education and research due to its ease of learning and wide range of applications. As these researchers move into industry, they often continue to use the tools they are most comfortable with.

In terms of using Python at scale, Python's indeed interpreted nature and Global Interpreter Lock (GIL) can limit its performance in some scenarios compared to compiled languages. However, many organizations find that Python's benefits outweigh these costs, especially when the limitations can be mitigated. For instance, using Python as a high-level interface to low-level modules written in C/C++, or using multiprocessing to take advantage of multiple cores and systems.

So while it's true that Python might not be the best choice for every situation (for instance, real-time systems, high-performance computing, or mobile app development), it's a powerful tool with a wide range of uses that many organizations find valuable. Different programming languages often have different strengths and weaknesses, and the best language to use often depends on the specific needs and constraints of the project.

Re: Ask HN: Why Python?

#4
>Like I can use Node, Go, C#, and Java at scale without being concerned about the low-level details, however, that's not the case for Python.

Well, if you chose not be concerned about the low-level details with these languages, then you can chose not to be concerned about the low-level details with Python. There's nothing inherent in Python or those other languages that makes it otherwise.

Or you mean "but Python is slow"? That's mostly irrelevant for many use cases, which either don't need the speed (web, administration, glue, controllers, etc), or depend on Python packages written in C/Fortran and plenty fast (which is the case for AI / ML / DS and such).

>it doesn't seem to offer any benefits compared to Node, Go, C# or even Java

Ease of use, less ceremony, huge package ecosystem including several de-facto standards for many use cases/industries, suitable for glue work, are benefits.

Re: Ask HN: Why Python?

#6
Python is easy to use and easy to start programming in. Much easier than the other alternatives you mention. This from a guy who uses python but does not particularly care for it. I love me some curly braces and hate significant whitespace but there is no getting around the ease of teaching in python and its beginner friendliness.

Why cant you use python at scale? Many ML/AI/Data tasks are exceedingly resource intensive but python still plays in thoses spaces as you elude to.

Are people writing realtime systems in python? Probably not but dont be quick to dismiss python before you know it is not performant enough for your use case.

I'm not saying python is the best choice, but it is often the easiest choice.

Re: Ask HN: Why Python?

#7
There are advantages working in an interpretive (scripting) language and there are several science applications that use Python as the top level control language and a c-like language as the heavy lifting code. This plays to the strength of each language and casual users can use the complex functionality without looking at the complex code.

Re: Ask HN: Why Python?

#8
post #5

> however, that's not the case for Python in what way?

My experience has been that to efficiently write computationally expensive operations I need to know the low-level libraries that Python interfaces with. Other languages provide me this functionality natively and I only go to the low-level stuff only after a few iterations.

Re: Ask HN: Why Python?

#9
post #4

> Like I can use Node, Go, C#, and Java at scale without being concerned about the low-level details, however, that's not the case for Python. Well, if you chose not be concerned about the low-level details with these languages, then you can chose not to be concerned about the low-level details with Python. There's nothing inherent in Python or those other languages that makes it otherwise. Or you mean "but Python is…

> Ease of use, less ceremony, huge package ecosystem including several de-facto standards for many use cases/industries, suitable for glue work, are benefits.

Sure, these are operational advantages. But purely from an computational perspective (GPUs, multi-core, concurrency, etc) does it offer anything natively without interfacing with C/C++ that validates it to be called a general purpose language.

Re: Ask HN: Why Python?

#10
post #9
post #4

> Like I can use Node, Go, C#, and Java at scale without being concerned about the low-level details, however, that's not the case for Python. Well, if you chose not be concerned about the low-level details with these languages, then you can chose not to be concerned about the low-level details with Python. There's nothing inherent in Python or those other languages that makes it otherwise. Or you mean "but Python is…

> Ease of use, less ceremony, huge package ecosystem including several de-facto standards for many use cases/industries, suitable for glue work, are benefits. Sure, these are operational advantages. But purely from an computational perspective (GPUs, multi-core, concurrency, etc) does it offer anything natively without interfacing with C/C++ that validates it to be called a general purpose language.

> does it offer anything natively without interfacing with C/C++ that validates it to be called a general purpose language.

In fairness, a huge amount of C/C++ functionality is managed by the kernel anyways. I'd bet most of the stuff C is used for in this situation could be replaced with Python code, but isn't for maintainability and performance purposes.

Post reply on HN