What application or problem classes do you prefer Python for strictly OO languages?

I have a pretty strong background in C-style languages. And they worked on several different types of projects. I just started looking seriously at Python after reading Programming Collective Intelligence . I understand that Python can solve any problem that C # can use, and vice versa. But I am curious to learn from those who use them regularly when they choose each other. Removing other factors, such as peer experience, etc.

When do you choose to create a Python application instead of a static typed, purely OO language such as C # or Java?

Edit:

I was afraid that we would talk a little bit on this issue. Python is an object oriented language. But, as indicated below, this may not be the preferred language when your application will have a very heavy business domain, etc. I know that Python makes extensive use of objects and that even functions are objects, which does not correspond to all the “OO” languages ​​that I brought up before.

Despite my poor choice of words in the question (there are almost no languages ​​that fit well in two or three word descriptions, and it’s really difficult to point out the differences in languages ​​without discovering that you speak up to a specific developer class.), I'm still very interested what you can say about when you prefer Python in other languages.

+4
source share
8 answers

My motto (and for a long time) is "Python, where I can, C ++, where I should" (one day I will find the opportunity to really use Java, C # and C & C in a real world project, but I have not been, except for the pilot a project in Java 1.1, more than ten years ago ... ;-) - Javascript (with dojo), when the code should run in the client browser, and SQL when it should run on the database server, of course, but C ++ and Python are my daily bread is on the “normal” servers and clients that I develop, and that’s the problem in all parts of Google, where I have been working for 4+ years (there are many parts using Java, too, I just never worked there ;-). Hmm, there is pure C when I also work on the Python core and related extensions, -).

Neither Python nor C ++ is "strictly OO" - they are a multi-paradigm, and in this they are a good part of their strength in the hands of programmers who are highly skilled in OO and other paradigms such as functional, general, declarative, etc. d. I believe that C # also draws in some of them (sometimes surpassing C ++, for example, by offering lambdas), and even Java had to succumb to some (at least generic) to a tiny degree, so it’s clear, of course, that “one size fits all - no - programming with multiple paradigms is alive and well! -)

C ++ (like C) forces me to carefully manage all the memory (our internal C ++ style guide forbids the use of smart pointers, which equals poor garbage collection implementations!), Which multiplies my work many times, but helps make sure that I do not use one bit of memory more than is necessary at any time: therefore C ++ (or C if necessary) is a choice when the memory is dense and precious. Otherwise, the extremely high performance of Python (and Ruby or Javascript is not that different if that's what you're used to) makes it preferable.

I'm sure there is some kind of niche between the garbage collection language, but mostly static, like Java (or C #, before it starts to accumulate more and more functions, including dynamic ones in 4.0, I hear), or else these languages ​​and related ones would not be so common - I never found that I inhabit this peculiar niche.

+10
source

I choose Python as often as possible. This is the most useful and productive programming environment that I know of.

If I come across projects in which Python cannot be used directly or for the entire project (for example, for a .NET application), my approach is usually to use Python as much as possible. Depending on the situation, which may mean:

  • Insert python interpreter
  • Use jython
  • Using IronPython
  • Use some IPC mechanism (usually http or sockets) to call an external python process.
  • Data export - process using python data - import
  • Generate Code Using Python

From my answer to the previous question: I know C #. Will I be more productive with Python?


In my experience, what makes me more productive in Python against C # is:

  • This is a dynamic language. Using a dynamic language often allows you to remove entire architectural layers from your application. The dynamic nature of Pythons allows you to create reusable high-level abstractions in a more natural and flexible (syntactic) way than you can in C #.
  • Libraries The standard libraries and the many open source libraries provided by the community are of high quality. The range of applications used by Python means that the range of libraries is wide.
  • Faster development cycle. Without a compilation step, I can test the changes faster. For example, when developing a web application, the development server detects the changes and reloads the application when the files are saved. Running unit test from my editor is just a keystroke and it is instantaneous.
  • Easy access to frequently used functions: lists, lists, generators, tuples, etc.
  • Less verbose syntax. You can create a WSGI-based Python web infrastructure in fewer lines of code than your typical .NET web.config
  • Good documentation. Good books.

+4
source

I almost exclusively use Python to support software development in other languages. I should emphasize that this is not the result of some crashes in Python, rather that the software domains I work in usually have other languages ​​/ frameworks that are more suitable or just the only option:

  • Web development: I would like to test Python on the Google App Engine, but at the moment I'm doing my personal web development in PHP.
  • Desktop Application Development: I use the Ogre SDK to develop window savers and use C ++ / Win32 for this.
  • Server Application Development: Professional server-side programming for Windows is almost always in C ++.

However, for all these application domains I use Python, regularly writing tools, process data and, as a rule, to optimize my development efforts. A few examples here are probably the best way to describe how I tend to use Python:

  • Into scape data from existing websites.
  • Create reports based on XML data.
  • Creating sets of SQL queries to populate databases based on other data formats.
  • Parse all C ++ projects and pull out a separate set of error messages and corresponding error codes.
  • Compare data sets to find data that I lost by accident.
  • Image processing to generate data for other sotware.

Python is such an expanding and useful language that, although I have never used it as the main language for software development, I would like to.

+3
source

JavaScript and Python have influenced the way I program even in C now. I think it’s best to know several languages, because you get more tools for mental use, because you often don’t have a choice of which language to use.

+2
source

Python is much more strictly OO than Java and C #.

But if your question is when to use Python and when Java or C #, I find Python useful for small programs that are based on existing libraries and do not require much domain modeling. For example, small desktop utilities written using Python Gtk bundles or website maintenance scripts written using lxml and elementtree.

When a lot of application modeling is required, especially if the domain is poorly understood or changes quickly, I find that limited Python tooling makes code changes very difficult compared to Java (not so important for C # because the .NET support tool tracks Java for several years). Therefore, for such projects I will use Java and IntelliJ.

+1
source

Both C and python are my choice languages, but I almost always start doing something in python for correctness, and then dive into C when necessary. I mainly use programming for research / numerical code, where the specifications keep changing, and C is a terrible language for prototyping (this is true for most statically typed languages ​​in my experience). When something works for you in C, you rarely change it so that it is “better” because you do not have time. But sometimes C is easier than python when you need to manage resources (be it CPU, memory, etc.).

Thus, in fact, the question is: "when python is not enough for the task", and not vice versa.

0
source

As a rule, the language is dictated by work, who wants everything to be done and who you work with. I use only java and c / C ++ for my programming needs, mainly because the people I work with use it. At the same time, ive used python for rapid prototyping, etc.

0
source

All of them.

Except for code that is already written in another language, obviously.

Even if something seems too big to handle python, I usually make a Python prototype, mainly because it runs so smoothly. Often I will stick with Python anyway and just use the C API or ctypes to solve the bottlenecks (after I rewrite the prototype in its purest form, that is).

0
source

Source: https://habr.com/ru/post/1286528/


All Articles