Friday 30 January 2015

Python vs C++

  1. C++ is a "statically typed" language, while Python is a "dynamically typed" language. In one case, the types of the main components of the set of instructions (the computer program) are explicitly declared while in the other case they aren't.

  2. C++ is "faster" than Python
    C++ is typically a "compiled" language while Python is typically an "interpreted" language. With C++, the instructions are very well understood with all types specified and so they are translated into machine code (they are compiled) and executed unambiguously by the computer ...while with Python a separate computer program has to figure out what the Python instructions really mean [2,3] and how to "interpret" them to produce an output. The overhead of running this extra program versus simply just running the well defined machine code typically ensures that C++ runs much faster than Python.

  3. Python is more concise than C++Though this is certainly not an absolute truth, the example also shows one of the reasons why Python code tends to be shorter than that written in C++ (i.e. there is no need to declare types explicitly and this literally saves space in written code). Smaller code size for the same task leads to "rapid prototyping" and this is partly why one would use something like Python when speed of development is important.

  4. Automatic memory management in Python, whereas there is an overhead in explicitly managing memory in C++.

  5. C++ is a general-purpose programming language regarded as middle-levelas it is a combination of both high and low-level language features. It is a much lower-level programming language than Python. Python is a high-level programming language.
C++ places considerable burden on the programmer by requiring that he delve into the intricacies of memory management, exception safety and the like. The resulting code is complex, verbose and often difficult to read. The learning curve for C++ is steep and there is a high barrier to entry.

Python with its "programming for everyone" idealogy, is ideally suited for scientific computing and quantitative finance, as it can be quickly adopted by people with no formal background in programming. Yet historically most of such systems were developed in C++.

Thus we have a gap that needs to be bridged, the gap between the core C++ code and Python.
This is where Boost.Python comes to the rescue.

It must be noted that Boost.Python is not the only technology for creating hybrid systems in Python and C++. There is also the "Simplified Wrapper and Interface Generator(SWIG)". Swig connects programs written in C and C++ with a variety of high-level programming languages, including Python.

References :

http://www.thalesians.com/finance/index.php/Knowledge_Base/CPP/Boost_Python_Step_By_Step#Python_versus_C.2B.2B

https://www.quora.com/What-is-the-difference-between-programming-languages-such-as-Python-C-C++-and-Java

Issues faced wrapping C++ to Python using Boost

CMake - CPack - NSIS

 CMAKE


Cmake is a cross-platform, open-source build system, created by Kitware, in response to the need for a powerful, cross-platform build environment for open source projects.
  • controls software compilation process using simple, platform and compiler independent configuration files.
  • Generates native makefiles and workspaces that can be used in the compiler environment of your choice.
  • CMake Generator writes input files for a native build system. It is platform specific and is available only on certain platforms. Option -G can be used to specify the generator.
From my experience, with CMake(Cross-platform Make), it is one of the most powerful, sophisticated, flexible and easy to use build system. I used it for the project we were working on. It was my first time hands on experience with CMake. Though I was skeptical about it initially, I totally cherished the learning experience. I love the concept of shadow building - meaning you can separate source data from the binary data, giving your project a clean environment. The build directory is allowed to be either in-source or outside source directory.

CMake consists of a series of macros and functions which helps one in finding the required components in a simple and precise way.

[Note : Using CMake with QT5]

CPACK

CPack is a powerful, cross-platform software packaging tool, distributed along with CMake. Though it seems to be tightly integrated with CMake, it can also function without it.
CPack can be used to generate different kind of packages based on CPack Generators.
It allows you to generate
  • NSIS(Nullsoft Scriptable Install System) files for Microsoft Windows
  • Linux RPMdeb and gzip distributions of both binaries and source code.
  • MAC OSX Packages
Reference : Fabula 

Thursday 29 January 2015

Read EDID info from Registry

Finally got relieved from the current team. Had to say good bye to the product I have been working, for the past six months. 

Moved to a new team, experiencing and learning new stuff under an efficient Lead.

Excited to know what's in store for me.

  1. Started with knowing how to read EDID information from the registry.
    This guy really had great stuff on how to do that. Thanks to him
    http://ofekshilon.com/2011/11/13/reading-monitor-physical-dimensions-or-getting-the-edid-the-right-way/
    I was able to read the friendly name, even when the API DISPLAYCONFIG_TARGET_DEVICE_NAME failed to retrieve the name.
  2. There came a checkpoint on how to read the edid, given a device name. I figured a workaround with the DISPLAYCONFIG_TARGET_DEVICE_NAME .monitorDevicePath, which gives nothing but DeviceId, Thanks to the same guy again, his blog really helped me out.
    http://ofekshilon.com/2014/06/19/reading-specific-monitor-dimensions/