Hacker News new | past | comments | ask | show | jobs | submit login

Embed V8 into Python, then tell me how great C++ is.

In other words, C++ is great until something else has to call it. Then you're hosed and end up wrapping everything in C anyway.




Hi Zed! Actually my code (unreleased but working prototype for a year) is an nginx server with a CMS module using V8 for scripting and templating web pages. Code is C (nginx module + w/ nginx-api) and C++/JS for the CMS. So I cross 3 languages. Works like a charm: ~6K req/s for complex queries (cached disk access with 1+ lstat() call every second.) Memory usage contained very well (always <20MB.) It's so good I don't touch the GC. Also since its security model for Chrome is among the best the "workers" can be recycled very fast if you create a good context.

The problem with V8, as with almost anything, is it doesn't support well threading and its GC can be a bit unpredictable like any other automagic memory management interpreter. But even so, there are ways to control it.

I certainly relate to what you wrote because I used to be a C++ dev in mid-90s (wintel, shivers.) But if you have some time, have a look at V8 for developers. It rocks. Also the newsgroup has a great community.


That's what I've written a library to fix - it makes it quick and easy to bind C++ api's to make them callable from a dynamic language. Not only can you bind a C++ function with 1 line of code, but if that function returns an object, the returned object's member functions are callable on its scripted instance:

http://github.com/dennisferron/LikeMagic

Currently there is only an Io backend, but the library is designed so that the same C++ bindings can be used with multiple different backend languages. It's like Boost::Python on steroids.


I've seen you talk about this on the Io list for a while now, but you never seemed to have posted a link to it. Glad I can finally take a look at it :)


http://www.swig.org/ automatically binds existing C++ software to other programming languages. I use it a lot to call C++ from Python and Java and I must say it is really amazing piece of software.

And there is also Boost.Python.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: