Tag: Python

  • Why, When, and How to use Celery with Python

    “Celery is an asynchronous task queue based on distributed message passing.”

    Let’s break that down:

    (more…)
  • Php’s performance improvements — HHVM, JIT, and ‘Hack’

    Facebook deprecated HipHop for PHP, a PHP to C++ translator (trans-compiler) which they had been using since Feb 2010 in favour of HipHop Virtual Machine (HHVM), in 2013.

    HHVM is a PHP interpreter that uses just-in-time(JIT) compilation techniques. Or to put it another way, HHVM is a virtual machine that compiles PHP bytecode to native instructions at runtime. HHVM now runs the Facebook backend instead of the default PHP interpreter.

    On March 20 2014, Facebook introduced the Hack programming language for HHVM, which integrates seamlessly with PHP. Hack seems quite interesting; it’s like the good parts of PHP with some nice extras, more attuned to Facebook’s requirements. Along came a few new releases of HHVM in 2014 to improve compatibility.

    In Nov-Dec 2014, Wikipedia moved its Application servers to use HHVM giving them a 2x faster load time for (uncached) page requests while drastically reducing the Load on their CPUs from 50% to 10%. Here are few more details on how Wikipedia’s move from zend to HHVM was carried out.

    Image: Wikipedia’s page save time with HHVM is just 45% of what it used to be previously (http://hhvm.com/blog/7205/wikipedia-on-hhvm)

    All and all, HHVM is a cool update for the PHP community. It points to a maturing platform that now powers two of world’s most visited websites. For all the flak that PHP gets, Facebook’s continued commitment has really helped the language infrastructure grow impressively.

    All this triggered action in the PHP’s Zend Engine team and they have been busy updating the default interpreter. Here’s a great gist of features and improvements coming in PHP7 (also read why there’s no PHP6 on this link.) The PHP7 team are working to make the performance match up with HHVM, using JIT and Asynchronous programming support. PHP7 will probably be ready for production use by this year end.

    I still love to work in Python or Go more than PHP — Python is more expressive and easier to read and navigate. But the Python 2.x Vs Python 3.x debate has done some serious damage to the language. When the Python PEP Community should have taken the path to fix some of the nagging performance and concurrency concerns, they ended up breaking the backward compatibility with a new language spec. On the other hand, Facebook/Php took the pragmatic approach of keeping things compatible with every update. This must be great news for thousands of PHP developers out there who were feeling the heat from Python, Go, and JS(Node.js).

  • Python for beginners

    Getting functional in Python programming took me about a month and I’ve several years of C++ programming experience. I feel this is ok time for experienced programmers to get started, given you have something else going on in life as well. For beginners though, learning a new programming language in a useful manner is not as casual an affair as some YouTubers and Tech bloggers would tend to suggest on the internet (looking at you people, who write the ‘learn X in 1 hour’ guides 🙄).

    Computer systems need a fixed syntax and grammar which needs practice to get comfortable with. Python is easier than many other languages, but still, if you’re a beginner, you need to set aside a good amount of time learning it. People will forget to mention this when recommending books, but there are broadly two categories of programming books out there:

    • 1) for experienced programmers/Web Developers, and
    • 2) for beginners, with the language basics.

    If you’re a beginner to programming, don’t pick the former.

    If you just want to write some standalone scripts, then avoid books targeting Web Developers (Web developers would have to learn other topics, like a web framework, HTML rendering, REST APIs, etc., stuff that you can skip). I learnt it from Dive into Python, which is a bit advanced and not for you if this is the first computer language you are learning. It’s a great book though!

    If you’re a beginner, just focus on the language syntax, keywords and the style of writing code. The book Byte of Python might be it for you. Or try Think Python.

    Don’t try to learn by collecting tips from forums on random Python-related FAQs. It’s best if you start with a complete book. The forums will come in handy later when you have started coding and are stuck at some specific point. I haven’t studied programming through interactive online websites yet; I prefer working with native tools and find practising on the browser a bit cumbersome. It’s always better to practice coding in the environment you would be working on. Online interactive tutorials will give you a sense of accomplishment, with a quick start, but without actually building a good foundation. Having said that, there are a few good resources out there.

    There are also some very good online video courses available now. “sentdex” on youtube has some awesome content.


    P.S.: Python like most scripting languages uses Regular Expressions for a lot of text operations: it would help you greatly if you learn a bit of RegEx as well (You have definitely encountered some RegEx already if you’re an active computer user).

    If you’re preparing for Web Development: then learning about web frameworks (ex. Django), file I/O, REST API, Databases etc. will be the next steps. Pick the advanced topics after you’ve learnt the language basics though.