Altabel Group's Blog

Archive for the ‘Python’ Category

Working with many startups I was wondering recently why Python and Ruby are so popular and common with young and promising startups, especially Scandinavian ones as my experience shows. I am curious if anyone has analyzed the trend towards Python over Ruby with startups? Also I would like to find out what are the advantages of Python over Ruby if they are so?

I think a lot about choices and decisions at startups. Picking the language/platform to use at a startup is one of the harder decisions. Here I would like to mention the fact that most of startups today make their choice toward Python or Ruby over PHP or Java. From what I have read, PHP is just an inferior language to Python and Ruby. Even though a lot of people are using PHP because it is easy to get started, it seems to be easier to develop bad habits with PHP. Why jump on a bandwagon when you obviously know is broken? I’ve come to realize that the main reason why PHP gets into trouble with the purists is that there are just so many ways of doing one thing — it is not that standardized. I think it became the most popular language only because it’s so easy to pick up!

Python/Ruby win over Java on speed of development, and conciseness of code. This generally makes Python/Ruby a better choice for small startups for whom speed to market, and ability to implement new features matters most. Most of the modern sites chose Python when they were small startups. Only later did they have to scale. Websites tend to be horizontally scalable, meaning that for a surprising range of volumes of traffic you can just throw more webservers at it and the bottlenecks will be at other layers (for instance the database).

Searching for relevant information to compare both Pyton vs Ruby languages and analyzing customers’ demand on the software development market I found out that Python appeared to be the more popular choice for startups trying to get a minimum viable product launched and seek out potential venture capital.

This has less to do with the merits of either language and more to do with the philosophies of the frameworks represented by either language. RoR really can’t be beat as a rapid application development framework, and developers discussing Ruby on the web are generally referring to RoR. Django purports to do the same, but the overall philosophy of the python community is more minimalistic – python developers generally prefer to make their own selection of tools such as ORMs, Persistency layers and libraries.  A lot of people start Python web development with Django but move on to something more minimalistic like Flask, simply because the community seems predisposed to building its own stack in this way. RoR is more opinionated, and developers who are more predisposed to hitting the ground running, especially in the startup field, often take the Ruby fork in the road.

There is a “coming of age” point for startups coming from RoR or PHP, however.  I’ve heard about several companies who had this exact same experience and ended up moving towards something like Python or Scala.  I’m not certain this is specific to python, but I can say that as startups grow and become more ambitious, they move into problem domains poorly represented strictly by web frameworks/languages.  Search features and data extraction increasingly rely on advanced data mining techniques utilizing things like natural language processing and find they need to reengineer their stack a little to accommodate new ideas. Increasingly I see companies not abandoning their RoR/PHP/Django frontends, but creating separate REST APIs that almost always use bare python or a JVM language to take advantage of more complex computation outside of the HTTP req/response model.  Ruby could be used for this kind of offline processing, but the toolkits are just better and more mature in other languages since RoR is so prevalent in the Ruby community and consumes a great deal of the mindshare.

The fact of the matter is that most web startups represent feature sets early on where development speed is the prime concern, and so the language/framework with the biggest potential hire base and best RAD features typically win out early on.

As my personal point of view that no single language can answer every problem satisfactorily, and it is foolish to stubbornly stick to a single language for every case. Nevertheless a lot of our clients stick to Python when starting up their business. Let’s try to see what are the advantages of Python over Ruby?

The two are more similar than they are different, in everything from design to disadvantages to common uses – you can’t really go wrong either way, and shouldn’t base your decision on syntactical differences.

As Ruby developers say, Python’s main advantage has nothing to do with the language’s features. It’s more subjective: it seems that Python has more momentum amongst serious computer scientists. It’s increasingly popular in academic and scientific applications, and a lot of the technologists I respect the most seem to prefer it. By comparison, the Ruby community feels more designer-y and relatively more novice.

What this means is that while the Ruby world has very slick out-of-the-box product solutions, the Python world seems to produce more exceptionally well-written components like Tornado (web framework). Combined with it being used at Google and the potential for stuff like LiveNode to be released as open-source, I’d cast my lot with Python if I were starting today.

Thinking Python may be the best choice of startups, what is your opinion on this?

Looking forward to hearing from you!

 

Polina Mikhan

Polina Mikhan
Polina.Mikhan@altabel.com 
Skype ID: poly1020
Business Development Manager (LI page)
Altabel Group – Professional Software Development

When planning the application you have to choose the right programming language to make your application work appropriate. The choice depends on many factors you need to consider. Such as but not limited: you need to think over on what platform the application will run, how easily new features would be added to the existing platform, the code size, performance, support and community etc.

There are various web programming languages and selecting the right one makes a website function properly. In my article I would like to focus on three of them, so called three “P”: PHP, Perl and Python to answer which of these languages is the best one.

Let’s have a look at them and try to make a comparison analysis

PHP – is free of charge open source scripting language and widely used in web environment. The best advantage of PHP is that it is easy to learn and easy to use. It is flexible and used for developing from small websites to giant business and organizational websites. Most common are informative forums, chatting platforms, CRM solutions, e-commerce shopping carts, community websites, e-business, shopping carts.

In terms of efficiency it is executed by the server and server parses the code at its source, executes and send properly formatted html to the client computer. Therefore it increases the speed of PHP applications.
What concerns the advantage of running, PHP is multiplatform language and compatible with all operating systems and platforms.

Being open source language, a large group of PHP developers help in creating a support community, so it’s maintained and when bugs are found, it can be quickly fixed.
A lot of websites including such giants as Wikipedia, Yahoo!, Facebiook, Digg, WordPress and Youtube are written in PHP. The popularity of PHP is based on its simplicity and coding style that is quiet easy to understand.

Nevertheless, the simplicity in developing, precisely principle so called «structure is not important» in PHP has its reverse side, precisely it’s hard to maintain for large applications since it is not very modular.

Also it’s weak in terms of security since its open source, all people can see the source code, and if there are any bugs it could be used to explore the weakness. About 30% of all vulnerabilities listed on the National Vulnerability Database are linked to PHP. The last summary on vulnerabilities you may find following the link: http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2013-0427

Perl –refer to all purpose languages. Perl was developed as a text editor for converting or processing large amounts of data for tasks such as creating reports. Nowadays it intended improvements and suited for web development, game programming, GUI development, popular among system administrators etc.
The Perl reusable code structure provides flexibility in apps development and at the same time creates the problem of code reading after. As there are so many ways to do, there are a lot more ways to mess up in what you’ve done. If the code was written without proper care, the reading could even take 6 months.

So from one hand Perl is a good language for small programs because of its messy syntax structure it’s hard to write and maintain large programs. On the other hand if you’re planning to develop big web application you need to consider good coordination between developers work on discussing the code stile, mentoring and managing work in the team.

In terms of portability Perl code doesn’t use system specific features, so can be run on any platform.
Among popular websites created on Perl could be named bbc.co.uk, Amazon.com, LiveJournal.

In respect of vulnerability Perl takes the second place – 9.4%. I assume that it’s not bad taking into consideration its complexity and its long history.

It has fallen out of popularity lately a bit because of the slow development of Perl 6. Most people still use Perl 5.

Python – is considered to be very elegant programming language. It’s general purpose, high level programming language. On the one hand Python’s syntax and semantics are minimal; on the other it has complex standard libraries.

Python supports multiple paradigms: object-oriented, imperative and functional programming styles and has features including fully dynamic type system and automatic memory management.

In comparison with Perl Python is easy to read language. And its key idea is vice versa “there should be one—and preferably only one—obvious way to do it”. It means that the code written by one developer could be easily developed and supported by the others. Besides to delimit blocks Python uses whitespace indentation, rather than curly braces (C, C++, ….) or keywords (Delphi).

Python is often used as a scripting language, but is also used in 3D animation (Maya, Softimage XSI, Blender) and image editors (GIMP, Inkscape, Scribus, Paint Shop Pro). It was also used for writing several video games.

Python is actively used by Google, Yahoo!, CERN and NASA. But it has problems with popularity, precisely with spreading. The reason is that it’s less simple than PHP. Working with Python you need to learn numerical libraries. So that’s why some people prefer choosing PHP instead of Python. But only the betrayed ones could explain why they choose Python, the answer is easy the development on Python is faster on 30% and his vulnerability consists only 0.67% against 36% of PHP.

Conclusion

PHP at first sight seems to be a leader in this so called comparison race. It’s simple, easy to learn and efficient for building small and middle size websites. Going further with analysis in terms of scalable large system it turns out that here Python will perform better than PHP. The reason is in readability that makes Python easier to maintain and extend. Besides, Python is object-oriented. PHP is not. Moreover, Google supports Python with its Google App Engine where web sites can be hosted on Google’s server for free. What concerns Perl, analysis showed that it’s simple programming language with cross platform running and open source modular architecture that provides to develop interesting things. If the task is to perform administration scripts Perl is much better to use here than PHP.

After the analysis it follows that the choice any of three P is a good choice. Also it means that for a certain purpose there is a right tool to choose. Besides the analysis showed that all three “P” have in common the following:

• are cross platform;
• have open source code;
• have well written documentation;
• have large user communities;
• extend libraries and big amount of code written;
• have high-level frameworks (PHP – Symfony, php.MVC; Python-Django, CherryPy, Pylons; Perl -Catalyst, CGI::Application, Gantry);

So I hope that summary based on technical analysis we made could help to make a right decision in future web projects you might have.

Thank you for your attention and if you have anything to add, please feel free to leave a comment.

Katerina Bulavskaya

Katerina Bulavskaya
Katerina.Bulavskaya@altabel.com
Skype ID: katy.bulavskaya
Business Development Manager (LI page)
Altabel Group – Professional Software Development

Debates about which programming language is the best are always hard and heated. Likewise, there’s no ideal language that works for all web application project requirements. Wikipedia is written in PHP. Gmail is written in Java. Python is number one choice of Google and YouTube. Ruby is used to create Twitter and Hulu. Slashdot is written in Perl. Stackoverflow is written in C#.

Browsing for the best web programming languages, among dynamic ones, you’ll mostly see PHP, Python and Ruby listed. Back in the days several years ago PHP was admitted the best tool for web job but since then both Python and Ruby have matured and grown robust libraries and frameworks around them that make them better candidates for many web projects now.

Today many consider PHP to be great for average everyday web systems. Python and Ruby are thought to be more suitable than PHP for most web applications in general and for more advanced things in particular. Just like PHP, they are free, open source, run on an open source stack (Apache and Nginx / linux, windows and BSD), and play well with any database engine. However, Ruby and Python have better syntax and they both enforce good programming habits by their nature, especially Python. PHP encourages sloppy spaghetti code by its nature. Also, the object oriented features in PHP are very ugly because of its arcane, retarded syntax.

Let’s get deeper insights into these two web programming languages from various standpoints:

As mentioned before, Python and Ruby are two of the most popular dynamic programming languages used in high level application development. In fact, Ruby was built using some of the design elements from Python. Developers often prototype using these two languages before implementing on compiled languages because of their modularity and object oriented features. Many use Python or Ruby instead of Perl as simple scripting languages. Python and Ruby are popular among web developers as well because of their rapid development cycle, with Python boasting computation efficiencies and Ruby boasting code design.

a/ Philosophy
Python really believes that code readability is the most important thing. Hence, there is one-true way of writing code, or as it has been reformulated lately: “There’s a most understandable way to do something and that is how it should be done”. Python is designed to strongly emphasize programmer productivity and it likes things to be structured, consistent, and simple. Python syntax enforces strict indentation rules; in fact, indentation has semantic meaning in Python.
Ruby believes in giving programmer the flexibility, freedom and power. It was designed, first and foremost, to make programming fun for its creator, with guiding concepts as follow: “The Principle of Least Surprise” and “There’s more than one way to do the same thing”. The latter philosophy principle inherited from Perl is the reason why many Ruby methods have alternate names, which may lead to some API confusion among new practitioners. However, this flexibility enables Ruby to be used as a meta language for describing DSL. Also Ruby provides a better way to write concise and compact code. More into the expressiveness of the code and writing code that is clever.
Python people like libraries to be transparent and obvious how they work and hence is easier to learn, while Ruby people tend to provide clean and pretty interfaces with “magic” behind the scenes. This makes development very fast when you understand the magic, but frustrating when you don’t.

b/ Ease of Use
Python is known for its ease of use. It allows beginners to start building powerful sites more quickly, and has the power to grow in complexity keeping its ease of comprehension. For example, one of the hardest parts of coding is going back to what you coded long ago and trying to remember the logic of it. Because Python uses natural language with white spaces and indenting, it is much more clear and easier to read than languages like Ruby. That makes it easier to fix mistakes or do updates. Also, there are literally thousands of pre-built modules that can be snapped on to let you get up and running on the web immediately. Its intuitive introduction to object-oriented coding concepts, such as communities, modules, and libraries, allows you to move on to other related programming languages as they develop.

c/ Object Oriented Programming
Both Python and Ruby support object oriented programming. Still Ruby’s object orientation is considered to be more ‘pure’ in that all functions exist inside a class of some sort. Python’s object orientation is more akin to that of C++, which allows functions and statements that exist outside of classes. In Ruby, even global variables are actually embedded within the ObjectSpace object. Python doesn’t have global variables, instead using attributes of module objects. In Python and Ruby, an instance of literally any type is an object. However, where in Ruby all functions and most operators are in fact methods of an object, in Python functions are first-class objects themselves.

d/ Syntax
Ruby includes several syntactic features which make dynamic extension of and higher-order interaction with external (library) code more straightforward. In particular these are blocks and mix-ins. Most things implementable with block and mix-in syntax are also achievable in Python, they are simply less syntactically natural and clear, and so less commonly form the centerpiece of major libraries or common styles of programming. These features, combined with a lighter-weight syntax with fewer restrictions (whitespace flexibility, optional parentheses, etc), make Ruby more suitable to pervasive and relatively transparent use of metaprogramming.
At the same time, while this flexibility and the Ruby community’s tendency to use it for metaprogramming can facilitate aesthetically pleasing code, they can also create stylistic variation in how the language is used, and obscure the mechanisms by which code actually works. Python’s more restrictive syntax is intentionally designed to steer developers towards one canonical “pythonic” style to improve accessibility and comprehension.

e/ Style
Ruby code is organized into blocks, with blocks starting with various constructs and ending with the keyword “end”. Python code is indentation-sensitive, with successively larger indentation meaning tighter (nested) scopes. Python’s syntax has been described as executable pseudocode.

f/ Functional Programming
Both languages support some functional programming constructs, but Ruby is arguably better suited to a functional programming style. Lambdas in Python are generally very short, because lambdas in Python are restricted to expressions and cannot contain statements. Ruby’s lambda support is far more flexible, allowing for lambda expressions of arbitrary length.

g/ Speed
The standard CPython implementation is generally regarded as executing code slightly faster than Ruby.If speed is really an issue for a Python project, you also have the option to use Cython, Pyrex,Pypy (JIT) or the ShedSkin tools to compile your code into C or C++.

j/ Features
Both Python and Ruby are high level application development languages. Each of them is estimated to have a Capers Jones language level of at least 15. Both languages promote test driven development.
Both languages have full Unicode support, although the way that support is implemented varies. Python distinguishes between “Unicode strings” and “byte-strings”. Ruby, on the other hand, treats all strings as byte-strings with a semi-hidden flag which causes problems when dealing with badly-encoded data from third-party sources.
Both Python and Ruby support multithreading. Python has the Global Interpreter Lock (GIL), which negates much of the potential advantage of using threads; Ruby has a comparable Global VM Lock (GVL).
There are a number of functions that are available by default in Ruby but for which in Python it is necessary to import a module from the standard library. Python supports generators and generator expressions.

k/ Community
There are great communities behind both frameworks. Some people believe that Python has a more developed community in terms of libraries suited for data analysis, machine learning, natural language processing, scientific libraries. As for community folks, Python ones are believed to be conservative and afraid of change, while Ruby guys welcome changes and love new shiny stuff even if it breaks older things. Consequently, Python world is more stable, and you can update your installation without much troubles, but that also means new technology is only added very slowly.

l/ Frameworks
There are a number of Web frameworks based on both Ruby and Python. The most notable and leading are Ruby on Rails (Ruby) and Django (Python) based on MVC. Django is more declarative, with it you’ll have a clearer understanding of what’s actually going on. It lets you specify most configuration details yourself. Django creates a much simpler project structure. On the other hand, the centerpiece of Rails’s philosophy is called convention over configuration. Rails provides you with more defaults.

m/ Popularity
Python is generally more widely used than Ruby, according to most measures, but in the wake of the rising popularity of the Ruby on Rails Web application development framework Ruby’s popularity too has seen rapid growth.
Python is more mature general purpose nature vs Ruby’s more niche (Rails) usage. Python is stronger and sees use in automating system administration and software development, web application development, data manipulation, analyzing scientific data (with help of numpy, scipy, and matplotlib modules), biostatistics, and teaching introductory computer science and programming. Ruby+Rails holds a slight edge over Python+Django for web development and sees use in general programming, and has more mindshare.
In terms of cloud deployment, Python can run on Google-Cloud (Google-App engine). Though Ruby has very strong cloud deployment options in the shape of Heroku and Engine Yard.

Would you prefer Python or Ruby over PHP for implementation of your web project? And is it indeed a philosophy that you chose while selecting between Python and Ruby? Interested to hear your thoughts.

Helen Boyarchuk

Helen Boyarchuk
Helen.Boyarchuk@altabel.com
Skype ID: helen_boyarchuk
Business Development Manager (LI page)
Altabel Group – Professional Software Development

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

It’s surprising that in our blog we have never written about Python frameworks and Python itself either. So, I’ve decided to help out the omission :)

When choosing a framework for site development you have many things to consider. If the criterion is a programming language, for Microsoft and C# followers the choice is clear – ASP.NET. Those who are in love with Ruby don’t have to think too much either – Ruby on Rails will be their choice. It’s much more complicated for Python, PHP and Java developers to make up their mind: the quantity of frameworks here is tremendous.

Firstly, I want to underline the pluses of Python frameworks in general:

  • Usage of Python language. I’m sure lots of programmers are pretty tired of praising Python. But to write a site on Python is really faster, cheaper and more pleasantly than on  other languages.
  • Wide choice. Frameworks abundance can be scaring only for beginners. A professional always welcomes the freedom of choice, as the chance to find what you really need only increases. Besides, choice entails competition, and healthy competition leads to quality improvement of every framework.
  • Rapid development. New frameworks emerge constantly, and their precursors either give their way to the younger ones, or continue their struggle for leadership: bugs are fixed, new features are implemented. It differentiates Python community from, Ruby community, for instance, which is represented mostly by Ruby on Rails. Due to the lack of new ideas we can see some standstill in Ruby on Rails development.
  • Opensource. They say using quality software on a legal and free basis is really cool :)

For now there are several dozens of Python frameworks. Among them are famous Django, Pylons, Turbogear, and some other interesting ones, as Zope, Twisted, CherryPy.

Today I want to make a short review of the more popular Python framework – Django.

Django was created specially for convenient news site development of The World Company. It had been developed since 2000, but to the general public it was presented only in the middle of 2005. The framework got its name after a Belgian jazz guitarist and composer Django Reinhardt.

Django site is built from one or several applications, which are recommended to be made alienable and interconnected (unlike Ruby on Rails, for example). One of the main Django advantage is excellent documentation, and, I suppose, the biggest community among all the Python frameworks.

When getting acquainted with Django, firstly, his built-in administrator interface wins over. It provides convenient work with the content of a written site. You should change the settings a little bit, then following the link http://127.0.0.1:8000/admin you can start the page through which it is easy to manage the content (for example, to look through the data base content and change it).

Django architecture is a bit different from classic MVC. Controller of the classic model MVC approximately corresponds the level, which is called “View” in Django. Presentation View logic is realized on the level of Templates. Due to this Django level architecture is frequently called “Model-Template-View” (MTV).

For models Django provides an abstraction level which frees from the necessity of writing SQL-requests for getting/saving data to the database. All the tables, that are used in the application, are written as classes in a separate file models.py. Then with the help of these classes methods there happens manipulation of the tables content in the code. Thus, work with database becomes fully object-oriented. Django supports work with the main databases (PostgreSQL, SQLite3, MySQL, Oracle).

Also, it is worth noting about a very flexible way of urls reflection on the application function – with the help of regular expressions.

While developing an application it is convenient to use built-in server. It automatically determines the changes in the files of the project source code and reboots. The result from changes made to the code immediately displays on a browser web-page, but it is not recommended to use it as a working one, as it is single-threaded and do not provide any security measures. For these purposes you will have to set a normal server (Apache, for example).

To be honest till the very end, I will enumerate Django disadvantages as well:

  • Though the template language is simple, still it is not very “pythonic”
  • Not very convenient work with AJAX
  • There can emerge some difficulties while replacing components (if you are in bad relations with regular expressions, which are used widely in urls reflection, you may want to use another dispatcher). It is widely believed that Django developers quite often invent bikes. Though Django allows doing this easily and quickly.

Although Django is one of the most popular Python frameworks, do not forget that framework is just an instrument; the choice should depend on the task set firstly, and only after that on its popularity.

Thank you for consideration. As usual, I would be happy to see your comments :)

Kind regards,

Nadya Klim

Nadya Klim
Nadya.Klim@altabel.com
Business Development Manager
Altabel Group – Professional Software Development

Tags: , , , ,

%d bloggers like this: