If you like DNray Forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...

 

From PHP to Python (Django): Optimizing Tasks and Language Learning

Started by comdali, Jul 06, 2023, 07:12 AM

Previous topic - Next topic

comdaliTopic starter

Hey everyone,
I've been working as a programmer for just over a year in an SEO specialist team. My responsibilities include creating internal websites, handling urgent client site tasks, and gradually developing an internal application tailored specifically for our team. This application involves various site scans, analytics API work, serpstat, and other tools that simplify our daily project analysis.

The internal application was initially initiated by another programmer (who taught me some of the basics) and was entirely built from scratch without a framework. It was essentially their own creation, though it's debatable whether it qualifies as a framework at all. At the time, I wasn't too concerned about its implementation details as long as it worked. Moreover, I quickly adapted to it, which made things even easier for me. Once I became proficient in handling certain tasks independently, the original programmer moved on from the development.

Now, with an increasing number of tasks at hand, I've started contemplating whether to redevelop the entire application using a "conventional" framework - by conventional, I mean tried-and-tested and reliable. After careful consideration, I've settled on Yii2. However, there's one challenge: PHP might not be the optimal choice for certain tasks.

For example, consider the scenario where we need to extract all links from a sitemap and process each one, saving specific data. Given the large size of these sitemaps, it would take PHP around a week to complete the traversal of just one sitemap, and it ideally needs to be done on a weekly basis. Consequently, I've made the decision to handle such tasks using Python, which I am currently studying.

To summarize, as I delve into choosing Yii2, I'm contemplating whether it would be more advantageous to rewrite the PHP framework altogether. Perhaps the best solution would be to rebuild it in Python, specifically using Django. This would enable me to learn the language faster and expedite many tasks that are comparatively slower in PHP.

I'm keen to hear your opinion: do you think it's worth pursuing this route, or should I stick with PHP (Yii2) and handle specific tasks using Python chunks?

Apologies for the lengthy question and description, but I felt it was necessary to provide you with a comprehensive overview.
  •  


AffGonzo

Python is not faster than PHP, and if it is indeed faster, it's only in applied tasks. When it comes to "bypassing the sitemap," Python won't provide any significant advantages.

It is always necessary to rewrite everything, as refactoring is an essential part of development. However, what specifically needs to be rewritten depends on your discretion. Personally, I do not recommend Yii.

However, if you have a desire to learn Python, now is probably the best time to start practicing it as it is much more productive.
  •  

fandevb

It is advisable to focus your writing on subjects you are knowledgeable about or curious to learn about. Don't assume that Python is markedly faster than PHP; in fact, certain benchmarks indicate that the latter can be marginally swifter. Engage in a conversation with your team regarding this matter, and if no strong preferences exist, make a decision based on your personal preference.
  •  

GrahamJohn

Here's a tip: when rewriting, avoid doing it all at once. Instead, start by creating a wrapper for the framework, which can handle requests and redirect them to the old code. This enables you to utilize both the framework components and the existing code simultaneously. Then, gradually rewrite and release portions of the code.

I've witnessed many instances where attempting to rewrite everything simultaneously resulted in failure. It's important to approach the process strategically and take it step by step.
  •  

Marker

Based on your description, it seems like you have identified a specific bottleneck in your application, which is the long runtime for traversing large sitemaps using PHP. In such cases, using Python, which is known for its efficient handling of processing tasks, could be a good solution.

Rebuilding your entire application in Python using Django might be an option worth considering, as it would allow you to leverage the strengths of Python and potentially expedite tasks that are slower in PHP. Additionally, if you are currently studying Python, it could be a good opportunity to apply your learning directly to the project.

However, before making a decision, it's important to carefully evaluate the trade-offs involved. Consider factors such as the existing codebase, the time and effort required for a complete rewrite, the familiarity and expertise your team has with PHP versus Python, and the impact on future maintenance and scalability.

If the performance bottleneck is limited to specific tasks, another approach could be to keep the existing PHP codebase and integrate Python modules or scripts where necessary to handle those specific tasks. This way, you can leverage the strengths of Python without requiring a full application rewrite.

Here are a few more factors to consider when deciding whether to rebuild your application in Python using Django or stick with PHP (Yii2) and use Python for specific tasks:

1. Compatibility and Integration: Evaluate how well Python integrates with your existing infrastructure and systems. Consider whether there are any limitations or challenges in integrating Python components into the current PHP framework.

2. Development Speed: Assess the time and effort required to rebuild the entire application versus integrating Python modules or scripts into the existing PHP framework. Rebuilding in a new language and framework may take considerable time and resources, whereas integrating Python into the current PHP codebase could be faster and more efficient.

3. Team Skills and Familiarity: Consider the expertise and familiarity of your team with PHP and Python. If your team is already proficient in PHP and Yii2, it might be easier and more cost-effective to continue using PHP for the core application and leverage Python for specific tasks.

4. Maintenance and Support: Evaluate the long-term maintenance and support implications of each approach. Consider factors such as community support, availability of libraries and frameworks, and the ease of finding developers with expertise in PHP or Python/Django.

5. Scalability and Performance: Take into account the scalability requirements of your application. Assess whether either PHP (Yii2) or Python (Django) would better meet your future scaling needs in terms of performance, concurrent processing, and managing larger datasets.
  •  

rahul verma

In this PHP vs. Python comparison, Python wins by 2 points. But this doesn't mean you have to choose Python and neglect PHP. Both PHP and Python are excellent programming languages suitable for web and app development. PHP has been the go-to choice for the majority of web development projects for quite a while.


If you like DNray forum, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...