20 Python libraries you can’t live without

Python Tips

Hi there fellas. Today i am going to list 20 python libraries which have been a part of my toolbelt and should be a part of yours as well. So here they are

View original post 538 more words

Advertisements

Chrome is written in C++, Assembly and Python. How were they able to write three different languages and come up with one product?

Answer by Anoop Aryal:

Most of the popular applications are a mix of languages. It’s been a general “technique” for the longest time to write the base system using C/C++, embed a scripting language, build the rest of the application in that scripting language. I don’t have the exact details right – but generally speaking:

1. Adobe family of products (photoshop, acrobat, illustrator etc) are written in C/C++, embed a Javascript (adobe calls their implementation ActionScript), and then the UI etc. are written in Javascript.

2. Microsoft products (word, excel, powerpoint) are written in C/C++, embed a VB engine and the UI etc. are written in VB. Or were, at some point. Not sure what the state of the state is there anymore. Haven’t kept track in a long time.

3. Emacs – base is implemented in C. Embeds an elisp interpreter. Rest of the system is written in elisp. They have been trying to move to Guile instead of elisp for a long time. Don’t know where that’s at.

4. AutoCAD: embeds a lisp engine of some type.

So much so that there are languages created for the sole purpose of embedding into an app and building out the rest of the app in that language. Tcl, LUA, Guile to name a few.

This is done so that you get an “easy” language that you do most of your work in (UI’s don’t need raw speed since most of the time they are waiting for user input anyhow), but the base system — written in C/C++ — integrates with the OS well and is fast.

Just google LUA and look up where that’s used. You might be surprised how many apps are using it this way.

TL;DR: it’s nothing new. Most big application suites embed a higher level language that allows extending the core that’s in C/C++.

Update (05/09/2015):
Some have commented asking about how to actually do it. So I’m including this update to get you started in the right direction.

The steps, at a very high level, are:
1. Figure out what the fundamental “primitives” are. It’s like settling/standardizing on 2″x4″x8′, 4″x4″x8′ etc. wood pieces for the basic building material.
2. Implement that in C/C++
3. Pick an imbedded language you want to use (Lua, Python, Tcl are the go-to open source options)
4. Follow the documentation to embed the language interpreter inside your app. Lua is arguably the simplest/easiest to do this with. See Embedding a scripting language inside your C/C++ code for Lua and specifically read the sections “Calling from C into a Lua script” and “Call from Lua into your C application“.
5. If you expose all the “primitives” from #1 using the steps from “Call from Lua into your C application”, you can now write the rest of your app in Lua.

For C/C++/Python:
Embedding Python in Another Application

For the rest, google “Embedding ” and you’ll find plenty of tutorials…

Chrome is written in C++, Assembly and Python. How were they able to write three different languages and come up with one product? What i…