<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6860766684752178101</id><updated>2012-02-16T06:02:07.516-05:00</updated><category term='VTK'/><category term='C++'/><category term='clos'/><category term='scheme'/><category term='unique'/><category term='lisp'/><category term='python'/><category term='compyle'/><category term='SPP'/><title type='text'>foobrac</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-8177013366143179415</id><published>2010-11-14T16:39:00.006-05:00</published><updated>2010-11-14T17:01:00.099-05:00</updated><title type='text'>Unique 0.25 : the froodiest version yet</title><content type='html'>When I added the 'search for selected pattern' feature to unique's browser, I realized that hidden in the core library was a full search engine. So I thought that it would be fun to add a google-like interface to this engine.&lt;br /&gt;&lt;br /&gt;Unlike traditional search engines, this one works on pattern matching. Giving it a few random keywords won't work. So... how could one use it? By feeding it sample code. Give it a few lines of code, a sentence or an algorithm and it will search for something similar.&lt;br /&gt;&lt;br /&gt;Here is a scenario where it could shine. Suppose that littered through the code base you have used the same idiom/pattern/copy-pasted code. One day you find a bug in the pattern. Searching for all the instances of the pattern could be difficult with a regex, for many reasons. Variable or function names could be different from module to module, some instances could have changed slightly over time by different maintainers, etc. Unique should be pretty good at finding all those occurrences. Simply feed it one instance of the idiom and launch the search.&lt;br /&gt;&lt;br /&gt;What's next? Not quite sure. Emacs integration is on the list. Better performance that would allow the indexing of very large code bases : that's also on the radar. If you think unique could be useful to you, tell me how - I can help.&lt;br /&gt;&lt;br /&gt;Get your copy here : &lt;a href="https://sourceforge.net/projects/unique/"&gt;https://sourceforge.net/projects/unique/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-8177013366143179415?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/8177013366143179415/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=8177013366143179415' title='8 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8177013366143179415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8177013366143179415'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2010/11/unique-025-froodiest-version-yet.html' title='Unique 0.25 : the froodiest version yet'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-2424409155168711784</id><published>2010-10-27T11:54:00.002-05:00</published><updated>2010-10-27T11:55:40.683-05:00</updated><title type='text'>3D scanning in Montreal</title><content type='html'>VLAM is now offering a 3D scanning service!&lt;br /&gt;&lt;a href="http://www.3d-body-scanner.com/"&gt;http://www.3d-body-scanner.com/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-2424409155168711784?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/2424409155168711784/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=2424409155168711784' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2424409155168711784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2424409155168711784'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2010/10/3d-scanning-in-montreal.html' title='3D scanning in Montreal'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-171549795277316552</id><published>2010-10-26T17:08:00.001-05:00</published><updated>2010-10-26T17:10:11.900-05:00</updated><title type='text'>twitter on n900</title><content type='html'>Is there a twitter client that will integrate in the conversations of a Nokia n900 phone and actually work?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-171549795277316552?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/171549795277316552/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=171549795277316552' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/171549795277316552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/171549795277316552'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2010/10/twitter-on-n900.html' title='twitter on n900'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-4446450844422908257</id><published>2010-10-18T13:20:00.002-05:00</published><updated>2010-10-18T13:27:38.035-05:00</updated><title type='text'>How to properly tag python source files</title><content type='html'>Situation : emacs + ctags + python source&lt;br /&gt;&lt;br /&gt;Problem : import statements are tagged just like definitions, which means that find-tag never jumps to the location I am interested in.&lt;br /&gt;&lt;br /&gt;Solution : add "--python-kinds=-i" to  the ~/.ctags file. On Windows that would be c:\users\[username]\.ctags&lt;br /&gt;&lt;br /&gt;&lt;a href="https://bugs.launchpad.net/ubuntu/+source/exuberant-ctags/+bug/618979"&gt;https://bugs.launchpad.net/ubuntu/+source/exuberant-ctags/+bug/618979&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Voilà.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-4446450844422908257?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/4446450844422908257/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=4446450844422908257' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4446450844422908257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4446450844422908257'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2010/10/how-to-properly-tag-python-source-files.html' title='How to properly tag python source files'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-8034323788793848686</id><published>2009-12-09T17:14:00.002-05:00</published><updated>2009-12-09T17:18:24.603-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unique'/><title type='text'>unique 0.19 is out</title><content type='html'>&lt;a href="http://unique.sourceforge.net/"&gt;Unique&lt;/a&gt; 0.19 is finally out! The new feature is in the browser. You can now select any text in the right pane and search for code similar to your selection. It adds to unique some kind of search engine... maybe I should add a search bar to make it more obvious.&lt;br /&gt;&lt;br /&gt;Anyways... enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-8034323788793848686?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/8034323788793848686/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=8034323788793848686' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8034323788793848686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8034323788793848686'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/12/unique-019-is-out.html' title='unique 0.19 is out'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-5021152413411269042</id><published>2009-11-05T10:58:00.002-05:00</published><updated>2009-11-05T11:03:59.643-05:00</updated><title type='text'>Considering unity</title><content type='html'>Does anybody here have experience with the unity game engine?&lt;br /&gt;We could use it for one of our projects but we don't know how stable and extensible it is. If you can share horror or love stories, they would be most welcome.&lt;br /&gt;&lt;br /&gt;Thanks!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-5021152413411269042?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/5021152413411269042/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=5021152413411269042' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/5021152413411269042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/5021152413411269042'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/11/considering-unity.html' title='Considering unity'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-2778727905482436122</id><published>2009-10-19T11:21:00.003-05:00</published><updated>2009-10-19T11:34:27.990-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='VTK'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>swig bindings of VTK : a call to arms</title><content type='html'>I don't know how common our situation is... We use VTK through it's Python interface but we also need to develop some algorithms in C++ and make them accessible to the Python runtime. The problem is that, as far as I know, the VTK bindings are not inter-operable with swig. The result is that we can allocate VTK data structures from Python but we can't give them to our C++ algorithm.&lt;br /&gt;&lt;br /&gt;There are multiple solutions to this problem. The one we chose is to use swig to wrap our algorithm *and* VTK, in two different but inter-operable modules.&lt;br /&gt;&lt;br /&gt;We will start by wrapping and testing the parts of VTK that we need right now, but if other people out there have a similar need perhaps we could collaborate and come up with better bindings.&lt;br /&gt;&lt;br /&gt;So... is there anyone interested in participating in this not-yet-born open source project?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-2778727905482436122?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/2778727905482436122/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=2778727905482436122' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2778727905482436122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2778727905482436122'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/10/swig-bindings-of-vtk-call-to-arms.html' title='swig bindings of VTK : a call to arms'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-4086451041379329548</id><published>2009-10-04T03:34:00.003-05:00</published><updated>2009-10-04T03:41:39.189-05:00</updated><title type='text'>version control for media</title><content type='html'>Here is a nice idea : &lt;a href="http://alumnit.ca/%7Eapenwarr/log/?m=200910#04"&gt;http://alumnit.ca/~apenwarr/log/?m=200910#04&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I don't know of a version control system that works fine with lots of big files. Maybe this guy's idea will be implemented and allow git, mercurial and bazaar to become better systems for developers and artists working on media-rich applications.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-4086451041379329548?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/4086451041379329548/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=4086451041379329548' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4086451041379329548'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4086451041379329548'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/10/version-control-for-media.html' title='version control for media'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-5632176776726291376</id><published>2009-09-11T16:12:00.001-05:00</published><updated>2009-09-11T16:13:36.236-05:00</updated><title type='text'>VLAM is hiring!</title><content type='html'>We are looking for a junior developer. &lt;br /&gt;&lt;a href="http://www.vlam.ca/emplois/offre_emploi.pdf"&gt;http://www.vlam.ca/emplois/offre_emploi.pdf&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-5632176776726291376?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/5632176776726291376/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=5632176776726291376' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/5632176776726291376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/5632176776726291376'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/09/vlam-is-hiring.html' title='VLAM is hiring!'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-2487728231217148230</id><published>2009-07-19T12:26:00.002-05:00</published><updated>2009-07-19T12:29:26.072-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unique'/><title type='text'>I need feedback!</title><content type='html'>Unique users : I would really appreciate some feedback. Please take ~30 seconds and fill in this survey.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.surveymonkey.com/s.aspx?sm=qjXVaOIor_2f0gBgX4VweEgg_3d_3d"&gt;Click Here to take survey&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Thanks!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-2487728231217148230?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/2487728231217148230/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=2487728231217148230' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2487728231217148230'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2487728231217148230'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/07/i-need-feedback.html' title='I need feedback!'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-1896433312620974953</id><published>2009-06-15T05:45:00.003-05:00</published><updated>2009-06-15T05:57:39.539-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unique'/><title type='text'>unique has a browser</title><content type='html'>The last few releases were mostly about the new browser. The idea is to be able to spot right away where are the file with the most obvious duplication. Once you know where are the problem files, you can launch a pattern search in the right direction.&lt;br /&gt;&lt;br /&gt;If some files displayed in the browser are not actually problematic (3rd party, build artifact, ...) you can right-click to hide it. The color of the labels will be renormalized automatically.&lt;br /&gt;&lt;br /&gt;The browser also displays metric when the root node of the tree is selected. You can think of it as an anti-SLOC metric. People keep using SLOC as a productivity metric, keeping track of how much bloat is in those Source Line Of Code should give a better idea of the work done and the refactorings ahead.&lt;br /&gt;&lt;br /&gt;You can always get the latest version on sourceforge : &lt;a href="http://unique.sourceforge.net/"&gt;http://unique.sourceforge.net/&lt;/a&gt;. There is also the freshmeat page that's always up-to-date : &lt;a href="http://freshmeat.net/projects/unique"&gt;http://freshmeat.net/projects/unique&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-1896433312620974953?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/1896433312620974953/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=1896433312620974953' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1896433312620974953'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1896433312620974953'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/06/unique-has-browser.html' title='unique has a browser'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-399858412496998307</id><published>2009-06-11T21:10:00.000-05:00</published><updated>2009-06-11T21:16:56.108-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ interview questions/inspiration - part 4</title><content type='html'>&lt;span style="font-weight: bold;"&gt;One, two, three&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;This is part 4. You can read the first three here :&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://foobrac.blogspot.com/2008/12/c-interview-questionsinspiration-part-1.html"&gt;Part 1&lt;/a&gt;&lt;br /&gt;&lt;a href="http://foobrac.blogspot.com/2009/01/c-interview-questionsinspiration-part-2.html"&gt;Part 2&lt;/a&gt;&lt;br /&gt;&lt;a href="http://foobrac.blogspot.com/2009/04/c-interview-questionsinspiration-part-3.html"&gt;Part 3&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;This fourth question is the bonus.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I didn't get to ask it very often. There is never enough time in an interview, that's why I prefer to have a small number of good questions. The questions need to be orthogonal and good predictors. This fourth question is not a very good predictor. Almost every candidate will flunk it. That's why I ask it last. Since the other three questions are good predictors, I often abandon before the fourth question.&lt;br /&gt;&lt;br /&gt;Having questions that are good at detecting bad candidates is not enough. Interviewers often forget that interviews work both ways. Candidates judge companies too. It's very frustrating to leave an interview without having been asked at least one difficult question. If the candidate can't answer the difficult question, it's no big deal. If he succeeds, then you have learned something very important : it's a keeper.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The statement&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Write a smart pointer. In the general case, it shall only keep a reference to the pointed object. If the pointed object's class inherits from IRefCountable, the smart pointer shall call the AddRef and Release member functions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;In case of silence&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If there is an uncomfortable silence, ask more specific questions. What is a smart pointer? Do you know C++ templates? Have you ever used boost? Boost::mpl?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Runtime vs compile-time&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Most candidates will try to use dynamic_cast. Does he know what are the limits of RTTI? What if the pointed object is an int?&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-399858412496998307?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/399858412496998307/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=399858412496998307' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/399858412496998307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/399858412496998307'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/06/c-interview-questionsinspiration-part-4.html' title='C++ interview questions/inspiration - part 4'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-3689677813103315721</id><published>2009-05-15T15:37:00.002-05:00</published><updated>2009-05-15T15:43:50.043-05:00</updated><title type='text'>unique is getting faster</title><content type='html'>Version 0.8 is out and it brings serious improvements. I worked a lot on search speed and you will see the difference - it's a lot faster. Also, the new search wizard lets you choose files by type. The UI still sucks, but it's not as bad as it used to be :-)&lt;br /&gt;&lt;br /&gt;Give it a try and tell me what you think about it!&lt;br /&gt;&lt;br /&gt;&lt;a href="http://unique.sourceforge.net/"&gt;http://unique.sourceforge.net/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-3689677813103315721?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/3689677813103315721/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=3689677813103315721' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3689677813103315721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3689677813103315721'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/05/unique-is-getting-faster.html' title='unique is getting faster'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-4107883041880845881</id><published>2009-05-03T16:49:00.003-05:00</published><updated>2009-05-03T16:59:48.054-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unique'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>unique : now usable</title><content type='html'>I have just released unique 0.3. The big changes are in the UI : the match results are now displayed using the source code as it is formated in the files instead of a flat list of tokens. It makes all the difference in the world :-)&lt;br /&gt;&lt;br /&gt;The search process is still slow for projects that are not tiny, I'll see what I can do about that. I do have a few ideas on how to fix that - can't wait to see how they work out.&lt;br /&gt;&lt;br /&gt;&lt;a href="https://sourceforge.net/projects/unique/"&gt;https://sourceforge.net/projects/unique/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-4107883041880845881?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/4107883041880845881/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=4107883041880845881' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4107883041880845881'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4107883041880845881'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/05/unique-now-usable.html' title='unique : now usable'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-2155302621529265986</id><published>2009-04-28T18:16:00.003-05:00</published><updated>2009-04-28T19:31:47.089-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unique'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>unique 0.2</title><content type='html'>Python source files are now processed more intelligently : tokens within comments are now ignored. Also, the filtering procedure has been improved a bit. You should get less repetitive results... of the repetitive patterns in your code :-)&lt;br /&gt;&lt;br /&gt;get it from &lt;a href="https://sourceforge.net/projects/unique/"&gt;https://sourceforge.net/projects/unique/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-2155302621529265986?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/2155302621529265986/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=2155302621529265986' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2155302621529265986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2155302621529265986'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/04/unique-02.html' title='unique 0.2'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-7782862191641286417</id><published>2009-04-26T14:17:00.004-05:00</published><updated>2009-04-26T15:47:06.719-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unique'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>unique</title><content type='html'>Last weekend I wrote a little prototype to help me find patterns in my source code. It was a little python script. This weekend I revisited the script and transformed it into a small wxpython application.&lt;br /&gt;&lt;br /&gt;You can get it from http://unique.sourceforge.net/&lt;br /&gt;&lt;br /&gt;I labeled it as pre-alpha. It's really only a prototype. Ugly and bare-bones.&lt;br /&gt;&lt;br /&gt;Ideas, bug reports et compagnie are all welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-7782862191641286417?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/7782862191641286417/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=7782862191641286417' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/7782862191641286417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/7782862191641286417'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/04/unique.html' title='unique'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6910564841306830493</id><published>2009-04-15T06:03:00.002-05:00</published><updated>2009-04-15T06:22:37.123-05:00</updated><title type='text'>The evil of long-lived branches</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Long-lived branches make good practices bad.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;When coding in a branch that will eventually be merged, it's a bad idea to refactor. All the global changes required to correctly implement the feature you need to code will send lines flying all over the code base and there is no VCS capable of dealing with that automatically.&lt;br /&gt;&lt;br /&gt;I mean, the VCS will be able to apply the changes you have made to some other codeline, but the changes done in the branched code that has been moved &amp;amp; refactored won't be merged properly.&lt;br /&gt;&lt;br /&gt;Because you are on a branch, you can't code as local as possible anymore. You can't, because you won't be able to refactor when you will need to re-use this local code. You need to know in advance what will be re-used and how. That sends all those agile tricks out the window. Overdesign becomes the only solution. It means that the quality of the code is getting worse every day those branches are maintained apart. And if this situation lasts for a couple of months, it comes to a point where you don't even want the different branches to be merged anyway.&lt;br /&gt;&lt;br /&gt;Features go in the mainline, stabilization in a short-lived regularly-merged (towards the mainline) branch. Doesn't it make sense?!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6910564841306830493?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6910564841306830493/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6910564841306830493' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6910564841306830493'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6910564841306830493'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/04/evil-of-long-lived-branches.html' title='The evil of long-lived branches'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6103319233755004848</id><published>2009-04-13T18:00:00.002-05:00</published><updated>2009-04-14T21:36:33.021-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='lisp'/><category scheme='http://www.blogger.com/atom/ns#' term='scheme'/><title type='text'>What is Lisp?</title><content type='html'>Confusing. Misunderstood. Lisp is plural.&lt;br /&gt;&lt;br /&gt;Is it fast? Yes and no - it depends.&lt;br /&gt;Isn't it old? &lt;a href="http://www.dreamsongs.com/NewFiles/Hopl2.pdf"&gt;Almost the oldest&lt;/a&gt;. But it's not a bad thing because it never stopped to &lt;a href="http://www.r6rs.org/"&gt;evolve&lt;/a&gt;. New doesn't mean &lt;a href="http://www.paulgraham.com/power.html"&gt;powerful&lt;/a&gt;, by the way.&lt;br /&gt;Is it object-oriented? If you need it to be, &lt;a href="http://en.wikipedia.org/wiki/Common_Lisp_Object_System"&gt;sure&lt;/a&gt;. Even when it's not, &lt;a href="http://barzilay.org/Swindle/"&gt;it is&lt;/a&gt;.&lt;br /&gt;Is it only good for research? It's &lt;a href="http://dynamo.iro.umontreal.ca/%7Egambit/wiki/index.php/Main_Page"&gt;reliable and fast&lt;/a&gt;, but not always. It has &lt;a href="http://docs.plt-scheme.org/"&gt;huge&lt;/a&gt; &lt;a href="http://chicken.wiki.br/chicken-projects/egg-index-4.html"&gt;libraries&lt;/a&gt;, but not always. It's been used in &lt;a href="http://en.wikipedia.org/wiki/AutoLISP"&gt;big commercial systems&lt;/a&gt;, too. It sure is good for research, but it can also be used commercially.&lt;br /&gt;&lt;br /&gt;Lisp sure is hard to explain briefly. But I think I found a way to keep it to a minimum when I'll have to say something about Lisp to my future collegues.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Lisp is syntax.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The only constant between the various dialects, platforms, interpreters, compilers... is the syntax. I used to repeat that lisp has no syntax. That may be true, but if everything else is blurry and contradictory about lisp, you end up with lisp being nothing and everything. It's nothing because it's only syntax and it has no syntax. It's everything because that nothingness of a syntax is fully programmable - and people have made everything with it.&lt;br /&gt;&lt;br /&gt;Please pardon this nothing-of-a-post. I am myself trying to understand what my new favorite programming language is. If you can light the lantern of the newb that I am, go ahead - flame at will :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6103319233755004848?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6103319233755004848/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6103319233755004848' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6103319233755004848'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6103319233755004848'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/04/what-is-lisp.html' title='What is Lisp?'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-4440872443851871047</id><published>2009-04-13T12:51:00.007-05:00</published><updated>2009-06-17T06:23:02.577-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ interview questions/inspiration - part 3</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Back to basics&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Early exit is a nice and simple optimization strategy. If you are designing an interview algorithm to help you select &lt;a href="http://www.paulgraham.com/gh.html"&gt;great hackers&lt;/a&gt;, you can expect most candidates to fail the test. That's why you should try to sort your interview questions. By putting the better discriminants first, you will know sooner if the candidate is not quite as good as you would like him to be.&lt;br /&gt;&lt;br /&gt;Knowing how good the candidate is early in the interview does not necessarily mean asking fewer questions, it means making the most of the little time you've got. If the guy looks like a super star you will want to skip one or two easy questions and get with the fun stuff. With super stars, it's the interviewer that has to show how good he is. Stars like to be asked tough, relevant questions. An easy interview indicates that anyone could get the position - and that the 'winner' will be surrounded with mediocre coders.&lt;br /&gt;&lt;br /&gt;All this to say : don't focus on this 3rd question if the candidate looks like a star. Don't skip it entirely either, it's not that bad a discriminant. You definitely want to be sure that everyone that works with you can answer it straight, it's just not very challenging to experienced C++ programmers.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The feature presentation&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;a) What is printed on the console after the execution of this program?&lt;br /&gt;b) What would you have done differently?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre&gt;&lt;br /&gt;&lt;span class="preprocessor"&gt;#include&lt;/span&gt; &lt;span class="string"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;animal&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    ~&lt;span class="function-name"&gt;animal&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="constant"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string"&gt;"bye\n"&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="keyword"&gt;virtual&lt;/span&gt; &lt;span class="type"&gt;void&lt;/span&gt; &lt;span class="function-name"&gt;print&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="constant"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string"&gt;"I am an animal.\n"&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;bird&lt;/span&gt; : &lt;span class="keyword"&gt;public&lt;/span&gt; &lt;span class="type"&gt;animal&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    ~&lt;span class="function-name"&gt;bird&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="constant"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string"&gt;"bye bye birdie\n"&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    &lt;span class="keyword"&gt;virtual&lt;/span&gt; &lt;span class="type"&gt;void&lt;/span&gt; &lt;span class="function-name"&gt;print&lt;/span&gt;()&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="constant"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string"&gt;"I am a bird.\n"&lt;/span&gt;;&lt;br /&gt;    }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="type"&gt;void&lt;/span&gt; &lt;span class="function-name"&gt;print&lt;/span&gt;( &lt;span class="type"&gt;animal&lt;/span&gt; &lt;span class="variable-name"&gt;a&lt;/span&gt; )&lt;br /&gt;{&lt;br /&gt;    a.print();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="function-name"&gt;main&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;    &lt;span class="type"&gt;animal&lt;/span&gt;* &lt;span class="variable-name"&gt;a&lt;/span&gt; = &lt;span class="keyword"&gt;new&lt;/span&gt; &lt;span class="type"&gt;bird&lt;/span&gt;();&lt;br /&gt;    print( *a );&lt;br /&gt;    &lt;span class="keyword"&gt;delete&lt;/span&gt; a;&lt;br /&gt;    &lt;span class="keyword"&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Low level&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Can he spot the obvious errors? The &lt;span style="font-style: italic;"&gt;print&lt;/span&gt; free function taking its argument by copy. The destructor of the super class not being virtual. Can he explain what the default copy constructor does? Does he know how to disable it? What about the assignment operator - did he think about it by himself? Virtual member functions - how do they work? What happens if the derived class's destructor is specified as virtual but not the super class? What if it's the other way around? Ever heard of a &lt;a href="http://en.wikipedia.org/wiki/Virtual_table"&gt;vtable&lt;/a&gt;? A vpointer?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;High level&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Will the candidate only worry about the low level details or will he think about the design globally? Does he know his sacred books? Can he actually recite Meyers and say "Make non-leaf classes abstract". Why make the super class's destructor virtual if there is nothing to free? &lt;a href="http://c2.com/cgi-bin/wiki?ProgramInTheFutureTense"&gt;Program in the future tense,&lt;/a&gt; of course.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Dazed and confused&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Only the best will be able to speak about high level concerns easily, others will need a little help. You can help them with a derived example&lt;br /&gt;   &lt;pre&gt;&lt;br /&gt;&lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="function-name"&gt;main&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;   &lt;span class="type"&gt;animal&lt;/span&gt;* &lt;span class="variable-name"&gt;a&lt;/span&gt; = &lt;span class="keyword"&gt;new&lt;/span&gt; &lt;span class="type"&gt;bird&lt;/span&gt;();&lt;br /&gt;   &lt;span class="type"&gt;animal&lt;/span&gt; &lt;span class="variable-name"&gt;other&lt;/span&gt;;&lt;br /&gt;   *a = other;&lt;br /&gt;   print( *a );&lt;br /&gt;   &lt;span class="keyword"&gt;delete&lt;/span&gt; a;&lt;br /&gt;   &lt;span class="keyword"&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;Is it sending them on the wild goose chase of virtual assignment operators or do they know better? It's ok to need a little help - it's not ok to become confused and disoriented.&lt;br /&gt;&lt;br /&gt;Stay tuned for the next episode - it's a tough one.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Update&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://foobrac.blogspot.com/2009/06/c-interview-questionsinspiration-part-4.html"&gt;Part 4&lt;/a&gt; is now available.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-4440872443851871047?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/4440872443851871047/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=4440872443851871047' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4440872443851871047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4440872443851871047'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/04/c-interview-questionsinspiration-part-3.html' title='C++ interview questions/inspiration - part 3'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-3180568763319651998</id><published>2009-03-12T21:39:00.003-05:00</published><updated>2009-03-13T11:21:36.064-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='compyle'/><title type='text'>The design of VLAM Compyle - the slides</title><content type='html'>Tonight I gave the presentation "The design of VLAM Compyle : A tower of languages from python to C++ using scheme" before &lt;a href="http://schemeway.dyndns.org/mslug/mslug-home"&gt;MSLUG&lt;/a&gt;. A special thanks to Guillaume for inviting me.&lt;br /&gt;&lt;br /&gt;For those who didn't show up (you should have, MSLUG is a fun group - plus, we were happy to have pythonistas join us from &lt;a href="http://montrealpython.org/"&gt;Montreal Python&lt;/a&gt;) all is not lost! You can &lt;a href="http://www.vlam.ca/CompyleDesign.pdf"&gt;get the slides&lt;/a&gt;. Also, I'll be happy to answer questions you might have.&lt;br /&gt;&lt;br /&gt;Bonne nuit.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-3180568763319651998?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/3180568763319651998/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=3180568763319651998' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3180568763319651998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3180568763319651998'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/03/design-of-vlam-compyle-slides.html' title='The design of VLAM Compyle - the slides'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-8757464769837769443</id><published>2009-03-05T06:30:00.005-05:00</published><updated>2009-03-13T11:21:36.065-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='compyle'/><title type='text'>How Compyle works</title><content type='html'>I will give a presentation before the &lt;a href="http://schemeway.dyndns.org/mslug/mslug-home"&gt;Montreal Lisp/Scheme User Group&lt;/a&gt; about the design of &lt;a href="http://www.vlam.ca/compyle_en.html"&gt;VLAM Compyle&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Title&lt;/span&gt; : The Design of VLAM Compyle : a tower of languages from Python to C++ using Scheme&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;When:&lt;/span&gt; Thursday March 12th 7pm&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Where&lt;/span&gt;: Room 3195, André-Aisenstadt Building, Université de Montréal, 2920 chemin de la Tour&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Alternative title&lt;/span&gt; : VLAM Compyle ; a strange, erotic journey from Python to C++.&lt;br /&gt;&lt;br /&gt;Come to meet hackers, stay for the beer. Venez en grand nombre.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-8757464769837769443?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/8757464769837769443/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=8757464769837769443' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8757464769837769443'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8757464769837769443'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/03/how-compyle-works.html' title='How Compyle works'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6060979969135402429</id><published>2009-02-18T21:21:00.005-05:00</published><updated>2009-03-13T11:20:40.677-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>Throw those error codes out</title><content type='html'>What to answer when asked to justify your use of exceptions:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;It makes the main flow of the program obvious&lt;/li&gt;&lt;li&gt;It's the only sane way to signal an error from a constructor&lt;/li&gt;&lt;li&gt;It avoids partially constructed objects&lt;/li&gt;&lt;li&gt;You can't avoid them anyway&lt;/li&gt;&lt;li&gt;The information carried by exceptions is better structured than error codes&lt;/li&gt;&lt;li&gt;Error codes don't scale, exceptions do&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;It makes the main flow of the program obvious&lt;/span&gt;&lt;br /&gt;When using exceptions, you don't need to check every single function call for error condition. This removes a lot of repetitive, useless code that gets in the way when trying to understand what is the first purpose of a single piece of code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;It's the only sane way to signal an error from a constructor&lt;/span&gt;&lt;br /&gt;You could choose to only have useless constructors and &lt;span style="font-style: italic;"&gt;init&lt;/span&gt; methods on every class... and you'd be wrong to do it. &lt;span style="font-style: italic;"&gt;init&lt;/span&gt; methods are often the result of an inadequate error management strategy.  More on that later, for now it should be clear that constructors don't have return values, and if you give a constructor an output parameter, you are in a fight against the language you can't win.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;It avoids partially constructed objects&lt;/span&gt;&lt;br /&gt;This one is huge! People underestimate it - big time. A good deal of what makes a class difficult to design &amp;amp; maintain is the number of states its instances can have. If any member of a class can be either constructed and non-initialized, constructed and initialized, constructed and partially initialized, constructed and uninitialized and , finally, destroyed.... what was I saying? Oh yeah, if any member can be in any one of those states, you are in trouble. You get destructors that are impossible to write, you have live objects everywhere in your system that are time bombs. Ever seen code like this?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;if ( is_init() )&lt;br /&gt;{&lt;br /&gt;    do_it();&lt;br /&gt;}&lt;br /&gt;else&lt;br /&gt;{&lt;br /&gt;    return E_FAIL;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;That means that the object can be in an invalid state. The class is not doing its job : the class's invariant is ill-defined. You don't get that when you use constructor with exceptions.&lt;br /&gt;&lt;br /&gt;It all makes sense when you consider how members initialization/finalization works. First, members are destroyed in the reverse order of construction : it makes sense. When members are constructed {that's before the body of the parent's constructor begins its execution}, if the Nth member's constructor throws, the previous members {those that are fully constructed} will see their destructor called : it makes sense. If the Nth members fails, the destructor of the following members won't be called : that is &lt;span style="font-weight: bold;"&gt;very&lt;/span&gt; useful.&lt;br /&gt;&lt;br /&gt;And memory leaks? If you have this :&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;my_object* obj = new my_object();&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and if the constructor of my_object throws, the memory allocated by new will be freed automatically! No leak! :-) Of course, if would be a good idea to use some kind of smart pointer because if this object's constructor won't fail maybe something else will throw before the call to delete.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;You can't avoid them anyway&lt;/span&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;new&lt;/span&gt; throws. The standard library throws. Boost throws. The world throws. Accept it. You not throwing does not spare you from writing exception-safe code.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The information carried by exceptions is better structured than error codes&lt;/span&gt;&lt;br /&gt;It's easier to choose the right exception class when throwing than to structure error codes returned by functions. You will find tons of functions returning an int as an error code, I hope you will find a lot less functions throwing an int :-)&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Error codes don't scale, exceptions do&lt;/span&gt;&lt;br /&gt;Error code management implementation size grows with the number of functions called. Exception catching is pretty much O(1) and exception throwing implementation is proportional to the number of possible failed postconditions, I don't see how you could do better than that.&lt;br /&gt;&lt;br /&gt;Shit happens. For the love of code, throw the shit out.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6060979969135402429?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6060979969135402429/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6060979969135402429' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6060979969135402429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6060979969135402429'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/02/throw-those-error-codes-out.html' title='Throw those error codes out'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-1317055914584148795</id><published>2009-02-15T17:16:00.006-05:00</published><updated>2009-02-15T19:07:14.724-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>One possible path</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_u7kA1Q_ggW4/SZiXQx6ZjvI/AAAAAAAAAA8/L2Q5GGZ1_2E/s1600-h/cpp-flow.gif"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 242px; height: 320px;" src="http://3.bp.blogspot.com/_u7kA1Q_ggW4/SZiXQx6ZjvI/AAAAAAAAAA8/L2Q5GGZ1_2E/s320/cpp-flow.gif" alt="" id="BLOGGER_PHOTO_ID_5303154875760742130" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;VLAM will soon hire an intern. This brings a host of questions about cv selection, which school to choose, the interview process, etc. What interests me the most at this point is how to educate a junior programmer up to the point where we will be able to trust his code.&lt;br /&gt;&lt;br /&gt;One possible path I think can work is the one displayed on the left.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Procedural&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;VLAM is a real-world software production environment and we need our programmers productive right-away. I find that even if functional programming has a definite mathematical beauty and simplicity, juniors don't get it right away. They do get that variables can refer to different values as the program is executed.&lt;br /&gt;&lt;br /&gt;On a very practical note, we use 3rd party software that have very procedural interfaces. Procedural programming is the basis, the starting point and the common denominator. I hope I won't actually have to teach basic structs, unions, file handling, printf and C function pointers ; but if I have to, I'll try to get it out of the way right from the start.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Object&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Inheritance, overloading, overriding, constructors, destructors - a junior coder has to master all of that before he can tackle exceptions (with of course exception-safe software design) and functional programming. Object-oriented programming is not a goal, but it is full of very usefull tools. Please, for the love of gods, don't stop here. Don't end up with "object-oriented programmers". Teach juniors patterns, so they can detect and factor them out in the future.&lt;br /&gt;&lt;br /&gt;Key concepts :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The construction, allocation, destruction and deallocation of objects&lt;/li&gt;&lt;li&gt;Overloading, overriding&lt;/li&gt;&lt;li&gt;Multiple inheritance (and the diamond of death)&lt;/li&gt;&lt;li&gt;Patterns&lt;/li&gt;&lt;/ul&gt;Books to read :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The effective C++ series&lt;/li&gt;&lt;li&gt;Agile Software Development, Principles, Patterns, and Practices&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Contracts, error handling and exceptions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I won't go on here about why you should use exceptions - that can be the subject of another post. Needless to say, proper error handling, asserts and exception safety is very important. Unfortunatly very few programmers in the real world are able to write code that won't leak or fail miserably when not everything goes as expected.&lt;br /&gt;&lt;br /&gt;Key concepts :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;RAII&lt;/li&gt;&lt;li&gt;asserts &amp;amp; contracts&lt;/li&gt;&lt;li&gt;try/catch&lt;/li&gt;&lt;/ul&gt;Books to read :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;The exceptional C++ books&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Functional&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;By this point, it should be clear to the new programmer that it's easier to write correct, extensible code when it's stateless. If C++ is your main tool, now is the time to fully understand how to use boost::function and boost::bind.&lt;br /&gt;&lt;br /&gt;Key concepts :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Closures&lt;/li&gt;&lt;li&gt;Declarative-style programming&lt;/li&gt;&lt;/ul&gt;Books to read :&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Structure and Interpretation of Computer Programs&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Generic&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is a big one. Templates in C++, generics in Java and C#. They can be as painful as they can be useful. You absolutely need to cover object-oriented programming before, because you will need all the tools of classes to actually implement to opposite idea : the separation of algorithms from data structures.&lt;br /&gt;&lt;br /&gt;Key concepts:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Runtime vs compile-time&lt;/li&gt;&lt;li&gt;SFINAE&lt;/li&gt;&lt;li&gt;Code generation&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Books to read:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;C++ Templates - The Complete Guide&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On Lisp&lt;/li&gt;&lt;li&gt;Modern C++ Design&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Scripting&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Many would start with scripting, and yet I put it at the end. I don't mean that a junior programmer should wait to learn python or ruby until he masters C++ templates - quite the opposite. I think juniors should already know a scripting language before you hire them in the first place. I'm talking about the integration of scripting in applications.&lt;br /&gt;&lt;br /&gt;After a programmer has suffered through C++ templates, once he understands what it take to write statically-typed reusable code, he is ready to bridge the gap between static and dynamic languages. Swig is no easy piece of cake, but if it allows you to write most of the code in a sane language, it's a small price to pay!&lt;br /&gt;&lt;br /&gt;Key concepts:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Embedding&lt;/li&gt;&lt;li&gt;Foreign interfaces&lt;/li&gt;&lt;li&gt;Domain-specific languages&lt;/li&gt;&lt;/ul&gt;Any book suggestions?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-1317055914584148795?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/1317055914584148795/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=1317055914584148795' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1317055914584148795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1317055914584148795'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/02/one-possible-path.html' title='One possible path'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_u7kA1Q_ggW4/SZiXQx6ZjvI/AAAAAAAAAA8/L2Q5GGZ1_2E/s72-c/cpp-flow.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-2195220323345789039</id><published>2009-01-20T19:49:00.007-05:00</published><updated>2009-02-15T19:07:56.156-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>functional abstraction of data members with boost::bind</title><content type='html'>I just wanted to share a little trick I learned some time ago : you can use boost::bind to transform pointers to data members into functors.&lt;br /&gt;&lt;br /&gt;For example, if you have a struct that looks like this :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;my_struct&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;span class="keyword"&gt;explicit&lt;/span&gt; &lt;span class="function-name"&gt;my_struct&lt;/span&gt;( &lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="variable-name"&gt;value&lt;/span&gt; )&lt;br /&gt;      :m_some_member( value )&lt;br /&gt;  {&lt;br /&gt;  }&lt;br /&gt;  &lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="variable-name"&gt;m_some_member&lt;/span&gt;;&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You can use boost::bind( &amp;amp;my_struct::m_some_member, _1 ) as a valid functor that will take an instance of my_struct as a parameter and return an int.&lt;br /&gt;&lt;br /&gt;Admit it, it's pretty cool :-) You don't have to write the getter, bind will generate it for you.&lt;br /&gt;&lt;br /&gt;What this kind of technique does to code readability is a matter you have to consider if you want to use it in a professional environment... I myself would most definitely write the getter in the vast majority of situations.&lt;br /&gt;&lt;br /&gt;It's always fun to close with a little program that shows I cared enough to test the subject prior to publication ; here it is&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span class="preprocessor"&gt;#include&lt;/span&gt; &lt;span class="string"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="preprocessor"&gt;#include&lt;/span&gt; &lt;span class="string"&gt;&amp;lt;algorithm&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="preprocessor"&gt;#include&lt;/span&gt; &lt;span class="string"&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="preprocessor"&gt;#include&lt;/span&gt; &lt;span class="string"&gt;&amp;lt;boost/bind.hpp&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;my_struct&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;span class="keyword"&gt;explicit&lt;/span&gt; &lt;span class="function-name"&gt;my_struct&lt;/span&gt;( &lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="variable-name"&gt;value&lt;/span&gt; )&lt;br /&gt;      :m_some_member( value )&lt;br /&gt;  {&lt;br /&gt;  }&lt;br /&gt;  &lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="variable-name"&gt;m_some_member&lt;/span&gt;;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;printer&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;  &lt;span class="keyword"&gt;typedef&lt;/span&gt; &lt;span class="type"&gt;void&lt;/span&gt; &lt;span class="type"&gt;result_type&lt;/span&gt;;&lt;br /&gt;  &lt;span class="keyword"&gt;template&lt;/span&gt;&amp;lt; &lt;span class="keyword"&gt;typename&lt;/span&gt; &lt;span class="type"&gt;T&lt;/span&gt; &amp;gt;&lt;br /&gt;  &lt;span class="keyword"&gt;inline&lt;/span&gt; &lt;span class="type"&gt;void&lt;/span&gt; &lt;span class="keyword"&gt;operator&lt;/span&gt;()( &lt;span class="keyword"&gt;const&lt;/span&gt; &lt;span class="type"&gt;T&lt;/span&gt;&amp;amp; &lt;span class="variable-name"&gt;anything&lt;/span&gt; )&lt;br /&gt;  {&lt;br /&gt;      &lt;span class="constant"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; anything &amp;lt;&amp;lt; &lt;span class="constant"&gt;std&lt;/span&gt;::endl;&lt;br /&gt;  }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="function-name"&gt;main&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;  &lt;span class="constant"&gt;std&lt;/span&gt;::&lt;span class="type"&gt;vector&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;my_struct&lt;/span&gt; &amp;gt; &lt;span class="variable-name"&gt;my_vector&lt;/span&gt;;&lt;br /&gt;  my_vector.push_back( my_struct( 0 ) );&lt;br /&gt;  my_vector.push_back( my_struct( 1 ) );&lt;br /&gt;  my_vector.push_back( my_struct( 1 ) );&lt;br /&gt;  my_vector.push_back( my_struct( 2 ) );&lt;br /&gt;  my_vector.push_back( my_struct( 3 ) );&lt;br /&gt;  my_vector.push_back( my_struct( 5 ) );&lt;br /&gt;  &lt;span class="constant"&gt;std&lt;/span&gt;::for_each(&lt;br /&gt;       my_vector.begin(), my_vector.end(),&lt;br /&gt;       &lt;span class="constant"&gt;boost&lt;/span&gt;::bind( printer(),&lt;br /&gt;              &lt;span class="constant"&gt;boost&lt;/span&gt;::bind( &amp;amp;&lt;span class="constant"&gt;my_struct&lt;/span&gt;::m_some_member, _1 ) ) );&lt;br /&gt;  &lt;span class="keyword"&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-2195220323345789039?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/2195220323345789039/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=2195220323345789039' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2195220323345789039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2195220323345789039'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/01/functional-abstraction-of-data-members.html' title='functional abstraction of data members with boost::bind'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-760050243266195719</id><published>2009-01-17T13:09:00.000-05:00</published><updated>2009-01-17T13:08:33.208-05:00</updated><title type='text'>The selfish idiom</title><content type='html'>This is yet another post inspired by neodarwinism.&lt;br /&gt;&lt;br /&gt;Code duplication happens all the time, no programmer doubts that. Because duplicating a piece of code is easy as hell and initially very cheap you quickly get yourself into some kind of a living mess. Big code bases do have a life of their own and the forces driving it are most interesting.&lt;br /&gt;&lt;br /&gt;What makes a code fragment successful? It's like our own genes, it has to be reproduced at a high rate without copying errors. When that happens the replicating idiom slowly invades the code base. A growing number of similar duplicates increases the probabilities that one of them will be noticed by a programmer and copy-pasted once more ; so there is a positive feedback loop. Even if all programmers will tell you it's bad practice to help a piece of code multiply, when a specific instance of an idiom is all over the place it becomes standard practice. Give it a few more months, and it's a local 'best practice'.&lt;br /&gt;&lt;br /&gt;The fragments of code that get copy-pasted are over-represented in our code bases... that says almost nothing about them. After all, they don't really replicate by themselves, they need our help. All these little code samples must have some kind of mind controlling power to force us to do their bidding. Successful code knows how to exploit our pride and laziness. I think that one of the super-powers self-duplicating code have is incomprehensibility.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;survival of the misunderstood&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That was the original title of the post. Control-C control-V is the standard prayer of our &lt;a href="http://en.wikipedia.org/wiki/Cargo_cult_programming"&gt;cargo cults&lt;/a&gt;. It's also the fertility dance that our code gene overlords make us do on those last-night hacking sessions. We get ourselves in a caffeinated transe and dance the dance of life!&lt;br /&gt;&lt;br /&gt;Actually, the whole process is celebrated in a long mass. First we have the high priest creating the original code, with the original sin hidden inside of it. Then it's presented as an offering to a less experienced follower, that will a little while later pass the good news to colleague. It's very important that the followers don't quite understand what is going on inside the code, or else they might be tempted to factor it as a function and put an end to an evolution branch. The use of global state, counter-intuitive interfaces and weird 3rd-party libraries are all on the code's side.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;how to kill it&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What do we do now? It's very tempting to simply say "writer simpler code" ; but that would be very wrong. Of course you should not write code that's needlessly complicated, but stating the obvious never helps. My point is that there is very often a true need for the complexity we put in code. The complexity in good code simply represents the true complexity of the underlying problem and helps prevent code duplication. Otherwise you get &lt;a href="http://www.artima.com/intv/simplexityP.html"&gt;simplexity&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;There are two players in this game : the code and the coders. If we can't simply make the code simple, maybe we can make the coders better. After all, this high priest that created the original sin probably understands a good deal of it. He should work more at explaining his creations to his followers, and put a little less time in changing the colors of buttons, documenting, or whatever the boss of his boss thinks is valuable, billable hours.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-760050243266195719?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/760050243266195719/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=760050243266195719' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/760050243266195719'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/760050243266195719'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/selfish-idiom.html' title='The selfish idiom'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-3370231730317404334</id><published>2009-01-15T19:01:00.004-05:00</published><updated>2009-02-20T16:12:04.718-05:00</updated><title type='text'>Beauty in code</title><content type='html'>We should write beautiful code.&lt;br /&gt;&lt;br /&gt;Saying that of course begs the question, what is beautiful code? And I won't answer it... not really. We should write beautiful code because we are equipped with hardware that can tell really really fast if something is beautiful.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Beauty is not useless&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Without getting into the usefulness of live, physical beauty is synonymous with sexy for really good reasons. It is supposed to be an indicator of health in us, humans. Facial asymmetry, for example, can be an indicator of brain damage in early life. Someone with a koala face has more chances of being healthy. I am not sure of that at all, but for the argument's sake, let's say it's true. {When you think about it, beauty is not in the eye of beholder. It's in the dick of the fucker :-) }&lt;br /&gt;&lt;br /&gt;So, should we abandon the use of our consciousness in favor of our guts when programming? {Let's call that Colbert style} Kind of, I guess :-) It would be more fun for the guy creating the new code, that's for sure!&lt;br /&gt;&lt;br /&gt;We can do something a little less stupid by teaching us what &lt;span style="font-weight: bold;"&gt;should&lt;/span&gt; be beautiful code. But how?&lt;br /&gt;&lt;br /&gt;The first thing to do is to reject beauty as criteria when programming and conducting code inspections. There is no contradiction! If you surround yourself with code you feel is beautiful, than you get beauty for beauty's sake - that's circular and retarded. You should surround yourself with code that's right, with the hope that in time you'll get used to it. Familiar code quickly becomes beautiful.&lt;br /&gt;&lt;br /&gt;If we ever get to the point where ugly code is probably wrong, life will be sweet! Coding will be so much easier - but don't get comfortable! You'll still have to refrain from rejecting code on the basis of ugliness, or your sense of beauty will drift and once again become your worst enemy.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-3370231730317404334?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/3370231730317404334/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=3370231730317404334' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3370231730317404334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3370231730317404334'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/01/beauty-in-code.html' title='Beauty in code'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-8989541049228982022</id><published>2009-01-11T19:20:00.004-05:00</published><updated>2009-06-17T06:20:22.571-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ interview questions/inspiration - part 2</title><content type='html'>So, the candidate has given an ok answer to the &lt;a href="http://foobrac.blogspot.com/2008/12/c-interview-questionsinspiration-part-1.html"&gt;first question&lt;/a&gt;  and/or you feel they deserve a second chance to impress you. I looooove this second question. It can really show how much of a professional the candidate is.&lt;br /&gt;&lt;br /&gt;Here is the question :&lt;br /&gt;&lt;br /&gt;Read the following program (the code is at the end of the post).&lt;br /&gt;&lt;br /&gt;a) If the second dynamic memory allocation fails by throwing an exception, what is printed on the console?&lt;br /&gt;&lt;br /&gt;b) Where is the bug in the application ; how would you fix it?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I love it because there is fun to be had for everyone. If the candidate is kinda junior, make sure he can tell the difference between the objects that are dynamically allocated vs those that are allocated on the stack. If the candidate can't tell the stack from the heap, you can skip the rest ; it's hopeless.&lt;br /&gt;&lt;br /&gt;The key to the first part of the answer is to know that the members of an object are initialized in the order they are declared in the class, not in the order of the initialization list. The door class is written with that in mind. All the rest is straightforward for the first part of the test.&lt;br /&gt;&lt;br /&gt;The question b) is much more interesting. The idea here is to make sure the candidate understands &lt;a href="http://en.wikipedia.org/wiki/Resource_acquisition_is_initialization"&gt;RAII&lt;/a&gt;. Bonus if he can mention it by name, but that's not what is important.&lt;br /&gt;&lt;br /&gt;A senior programmer will jump on the memory leak like a wolf on a sheep, but others might not. I suggest you don't fail those that don't get it right away. Ask them if they know what a smart pointer is ; if they ever used one. If you can get someone to say that it's a good idea to use boost::scoped_ptr in this case, it's a keeper :-)&lt;br /&gt;&lt;br /&gt;I also always ask the hidden sub-question c) What's the difference between boost::shared_ptr and boost::scoped_ptr ; and what is wrong with std::auto_ptr? There is no such thing as a senior C++ programmer that has never heard of boost. Call me elitist all you want, you won't be able to convince me otherwise.&lt;br /&gt;&lt;br /&gt;Now, my favorite interview questions always allows exceptionnal candidates to distinguish themselves. In this case, if you get a pretty good answer to question b), repeat the question a) with the fixed program. It's harder, because the candidate has to know how destructors are called in the stack unwiding process. Once again, if he can't quite do it, help him a little. Tell him "The destructor is called if the object was fully constructed, and an object is fully constructed when the flow of the program leaves a constructor normaly." ; it should help.&lt;br /&gt;&lt;br /&gt;If you ever try it on a candidate, tell me how it goes :-) I hope it will be as usefull to you as it has been to me.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="preprocessor-face-0000"&gt;#&lt;/span&gt;&lt;span class="preprocessor-face-0000"&gt;include&lt;/span&gt; &lt;span class="string-face-0001"&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword-face-0002"&gt;s&lt;/span&gt;&lt;span class="keyword-face-0002"&gt;truc&lt;/span&gt;&lt;span class="keyword-face-0002"&gt;t&lt;/span&gt; &lt;span class="type-face-0003"&gt;door_handle&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;   &lt;span class="function-name-face-0004"&gt;door_handl&lt;/span&gt;&lt;span class="function-name-face-0004"&gt;e&lt;/span&gt;()&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"c-door_handle\n"&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   ~&lt;span class="function-name-face-0004"&gt;door_handle&lt;/span&gt;()&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"d-door_handle\n"&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword-face-0002"&gt;struc&lt;/span&gt;&lt;span class="keyword-face-0002"&gt;t&lt;/span&gt; &lt;span class="type-face-0003"&gt;window&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;   &lt;span class="function-name-face-0004"&gt;window&lt;/span&gt;()&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"c-window\n"&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   ~&lt;span class="function-name-face-0004"&gt;window&lt;/span&gt;()&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"d-window\n"&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword-face-0002"&gt;struc&lt;/span&gt;&lt;span class="keyword-face-0002"&gt;t&lt;/span&gt; &lt;span class="type-face-0003"&gt;door&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;   &lt;span class="type-face-0003"&gt;door_handl&lt;/span&gt;&lt;span class="type-face-0003"&gt;e&lt;/span&gt;* &lt;span class="variable-name-face-0006"&gt;m_door_handle&lt;/span&gt;;&lt;br /&gt;   &lt;span class="type-face-0003"&gt;windo&lt;/span&gt;&lt;span class="type-face-0003"&gt;w&lt;/span&gt;* &lt;span class="variable-name-face-0006"&gt;m_window&lt;/span&gt;;&lt;br /&gt;   &lt;span class="function-name-face-0004"&gt;door&lt;/span&gt;()&lt;br /&gt;       : m_window( &lt;span class="keyword-face-0002"&gt;new&lt;/span&gt; &lt;span class="type-face-0003"&gt;window&lt;/span&gt;() )&lt;br /&gt;       , m_door_handle( &lt;span class="keyword-face-0002"&gt;new&lt;/span&gt; &lt;span class="type-face-0003"&gt;door_handle&lt;/span&gt;() )&lt;br /&gt;   {&lt;br /&gt;      &lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   ~&lt;span class="function-name-face-0004"&gt;door&lt;/span&gt;()&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="keyword-face-0002"&gt;delete&lt;/span&gt; m_window;&lt;br /&gt;       &lt;span class="keyword-face-0002"&gt;delete&lt;/span&gt; m_door_handle;&lt;br /&gt;   }&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword-face-0002"&gt;struc&lt;/span&gt;&lt;span class="keyword-face-0002"&gt;t&lt;/span&gt; &lt;span class="type-face-0003"&gt;car&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;   &lt;span class="type-face-0003"&gt;doo&lt;/span&gt;&lt;span class="type-face-0003"&gt;r&lt;/span&gt; &lt;span class="variable-name-face-0006"&gt;m_left_door&lt;/span&gt;;&lt;br /&gt;   &lt;span class="type-face-0003"&gt;doo&lt;/span&gt;&lt;span class="type-face-0003"&gt;r&lt;/span&gt; &lt;span class="variable-name-face-0006"&gt;m_right_door&lt;/span&gt;;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="keyword-face-0002"&gt;struc&lt;/span&gt;&lt;span class="keyword-face-0002"&gt;t&lt;/span&gt; &lt;span class="type-face-0003"&gt;acura&lt;/span&gt; : &lt;span class="keyword-face-0002"&gt;public&lt;/span&gt; &lt;span class="type-face-0003"&gt;car&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;&lt;span class="type-face-0003"&gt;i&lt;/span&gt;&lt;span class="type-face-0003"&gt;n&lt;/span&gt;&lt;span class="type-face-0003"&gt;t&lt;/span&gt; &lt;span class="function-name-face-0004"&gt;main&lt;/span&gt;()&lt;br /&gt;{&lt;br /&gt;   &lt;span class="keyword-face-0002"&gt;try&lt;/span&gt;&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="type-face-0003"&gt;acur&lt;/span&gt;&lt;span class="type-face-0003"&gt;a&lt;/span&gt; &lt;span class="variable-name-face-0006"&gt;some_car&lt;/span&gt;;&lt;br /&gt;       &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"we have a car!\n"&lt;/span&gt;;&lt;br /&gt;   }&lt;br /&gt;   &lt;span class="keyword-face-0002"&gt;catch&lt;/span&gt;( ... )&lt;br /&gt;   {&lt;br /&gt;       &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"error\n"&lt;/span&gt;;&lt;br /&gt;       &lt;span class="keyword-face-0002"&gt;return&lt;/span&gt; 1;&lt;br /&gt;   }&lt;br /&gt;   &lt;span class="constant-face-0005"&gt;std&lt;/span&gt;::cout &amp;lt;&amp;lt; &lt;span class="string-face-0001"&gt;"bye-bye\n"&lt;/span&gt;;&lt;br /&gt;   &lt;span class="keyword-face-0002"&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;Update&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Parts &lt;a href="http://foobrac.blogspot.com/2009/04/c-interview-questionsinspiration-part-3.html"&gt;three&lt;/a&gt; and &lt;a href="http://foobrac.blogspot.com/2009/06/c-interview-questionsinspiration-part-4.html"&gt;four&lt;/a&gt; are now available.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-8989541049228982022?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/8989541049228982022/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=8989541049228982022' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8989541049228982022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/8989541049228982022'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2009/01/c-interview-questionsinspiration-part-2.html' title='C++ interview questions/inspiration - part 2'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-1709663759279615513</id><published>2008-12-16T19:11:00.004-05:00</published><updated>2011-10-14T14:31:27.827-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>C++ interview questions/inspiration - part 1</title><content type='html'>Interviewing candidates is a tough proposition. Every interviewer has a set of favourite questions that they expect to be good differentiators. In this first part I'll give you one of mine. Others will follow.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;This is not a test&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is a difference between a test and an interview. I consider tests to be &lt;span style="font-style: italic;"&gt;offline&lt;/span&gt; - i.e. it can be done by the candidate alone in a room, the results are compiled later by a corrector. Tests are of course very useful, but I think they are even harder to design, especially if you don't want them to last 8 hours.&lt;br /&gt;&lt;br /&gt;I always ask the candidate to speak to me while he's writing code. Especially when he's changing his mind and uses the eraser. The whole point is know how he thinks. When he's heading down a wrong path, stop him. Ask questions. Can he understand what's wrong?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Don't do this at home&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I mean ; if you are trying to raise the bar at your company, don't design the interview questions alone. Ask your fellow programmers to help. The implicit question is : what's necessary to know to work here? What's the strict minimum one person can master and be helpful? I expect that you will be able to reach a consensus that includes many pieces of knowledge not mastered by all the programmers you work with. If used smartly (no humiliation!), the list can be transformed into a wonderful tool of education.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Question 1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;The procedure &lt;span style="font-style: italic;"&gt;reverse_words&lt;/span&gt; takes a string of characters as input and reverses  the order of the words. For example, the result of &lt;span style="font-style: italic;"&gt;reverse_words( "one two three" )&lt;/span&gt; is &lt;span style="font-style: italic;"&gt;"three two one"&lt;/span&gt;. On the board, code two versions of this procedure. The first in your favourite programming language, the second in C++.&lt;br /&gt;&lt;br /&gt;Runtime performance is important, but you should first consider code clarity and maintainability.&lt;br /&gt;&lt;/blockquote&gt;All the good programmers I know can give a pretty good answer very fast. Yet, many candidates fail miserably.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Deux, c'est mieux&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;There is no such thing as a good C++ programmer that only knows C++. And, of course, if the candidate prefers C++ to anything else, he should have a &lt;span style="font-style: italic;"&gt;very&lt;/span&gt; good excuse :-)  Also, some programmers will have the knee-jerk reflex of using low level constructs when they code in C++ but they are able to come up with quite decent interfaces when they work with a cleaner language. The differences in the implementations they provide can lead to revealing discussions.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Oh -O&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The candidate should be able to talk about the big-O runtime complexity of his algorithms. He should also be able to tell you how much memory is necessary. If he comes up with a O( n2 ) algorithm, now is a good time to ask if he can imagine a cheapest implementation.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The devil is on your side&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Because it's easy enough to think of algorithms that work, it's ok to focus on the implementation details. If memory is allocated, how is it released? What happens if exceptions are thrown? Should there be an error code returned? If the interface takes a &lt;span style="font-style: italic;"&gt;const char*&lt;/span&gt;, what happens if it's null?&lt;br /&gt;&lt;br /&gt;So, what would be your ideal answer?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://foobrac.blogspot.com/2009/01/c-interview-questionsinspiration-part-2.html"&gt;goto part 2&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-1709663759279615513?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/1709663759279615513/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=1709663759279615513' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1709663759279615513'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1709663759279615513'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/c-interview-questionsinspiration-part-1.html' title='C++ interview questions/inspiration - part 1'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6144529678428973505</id><published>2008-12-15T20:54:00.001-05:00</published><updated>2008-12-15T20:57:57.202-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='clos'/><title type='text'>object.method() is not the state of the art</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Mainstream is mediocre&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Mainstream object-oriented programming languages are very lame at what they say defines them. C++, C#, Java and so many other object-oriented programming languages are so far behind the state of the art - it's shameful.&lt;br /&gt;&lt;br /&gt;The simple truth is that Object.Method() is not the state of the art. If that's what it looks like when you invoke a member function, it means you don't have &lt;a href="http://c2.com/cgi/wiki/tour?MultiMethods"&gt;multimethods&lt;/a&gt;. Do you have access to your metaclasses? Can you customize your object model to increase performance, to help migrate code?&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;It's making us worst programmers&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The lack of power of our programming languages means we produce code that's more verbose. Sadly we get used to it. We may even find a visitor beautiful ;-) When there is more code, we get better at ctrl-c ctrl-v ctrl-h. That leads to programmers asking for better refactoring tools for our preferred language. Sometimes, those who sell the refactoring tools also have a big say about the evolution of languages. Of course they'll take the easy path : they will give us what we ask. They won't make the language more powerfull - it would be stupid. First, because it would probably make the refactoring tools less reliable and more complex. Also, they would kill a nice market..... it's not in their advantage to make the languages less verbose.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The solution is our impatience&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;We don't know what we're missing. There is no buzz about CLOS because it's old and there's no big corporation supporting it with millions in marketing. If we find out what's out there and how good it is, the microsofts and suns of the world will understand they have to push for a better - more powerfull - language. We'll tell them! The solution is to read. Here is the deal. I give you a few suggestions of reading material, and you do the same.&lt;br /&gt;&lt;br /&gt;My suggestions :&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;a href="http://www.amazon.com/Object-Oriented-Programming-Common-Lisp-Programmers/dp/0201175894/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1229390757&amp;amp;sr=8-1"&gt;Object-Oriented Programming in Common Lisp: A Programmer's Guide to CLOS&lt;/a&gt; but you probably want to read up &lt;a href="http://www.paulgraham.com/onlisp.html"&gt;on lisp&lt;/a&gt; first.&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.amazon.com/Art-Metaobject-Protocol-Gregor-Kiczales/dp/0262610744/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1229391384&amp;amp;sr=1-1"&gt;The Art of the Metaobject Protocol&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;What should I read?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6144529678428973505?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6144529678428973505/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6144529678428973505' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6144529678428973505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6144529678428973505'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/objectmethod-is-not-state-of-art.html' title='object.method() is not the state of the art'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-3154763874047290036</id><published>2008-12-12T13:46:00.005-05:00</published><updated>2008-12-12T16:02:27.241-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>boost::python vs swig::python - a benchmark</title><content type='html'>Disclaimer : benchmarks are evil, this one is no different. It probably measures something that is completely irrelevant. But, you know, benchmarks are fun.&lt;br /&gt;&lt;br /&gt;What I did : I generated a very simple C++ library : it contains only one-liners that return integer constants. Then I used boost::python and swig::python to make python wrappers for it.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The runtime test&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The test is simple enough : I call one of the trivial functions 1000000 times and measure the time using this : &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;stmt = """&lt;br /&gt;import fun&lt;br /&gt;s = 0&lt;br /&gt;for i in xrange(1000000):&lt;br /&gt;    s += fun.fun0()&lt;br /&gt;"""&lt;br /&gt;import timeit    &lt;br /&gt;T = timeit.Timer(stmt)&lt;br /&gt;print min( T.repeat(10,1) )&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_u7kA1Q_ggW4/SULIXUFbVNI/AAAAAAAAAAM/i-eyUtsNHAc/s1600-h/runtime.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 304px; height: 265px;" src="http://1.bp.blogspot.com/_u7kA1Q_ggW4/SULIXUFbVNI/AAAAAAAAAAM/i-eyUtsNHAc/s320/runtime.gif" alt="" id="BLOGGER_PHOTO_ID_5279002016085660882" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There you have it : swig generates faster code in this useless, totally artificial, case.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;When size matters&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;In many cases (embedded applications, for example) size matters. In the following graphic you can see the size of the linked pyd file (in kb) with 10, 100, 1000 and 10000 nearly identical on-liners generated.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_u7kA1Q_ggW4/SULNMW-4RvI/AAAAAAAAAAU/J6XFqu91mVM/s1600-h/size.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 228px;" src="http://2.bp.blogspot.com/_u7kA1Q_ggW4/SULNMW-4RvI/AAAAAAAAAAU/J6XFqu91mVM/s320/size.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5279007325443081970" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Swig sure has a bigger size overhead when your are binding only a few functions. Then boost grows faster, maybe the infamous code bloat associated with template metaprogramming - but take this with a *huge* grain of salt.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The versions&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I used boost 1.37 and swig 1.3.36 on windows vista with the microsoft toolchain (32 bits C/C++ compiler version 15.00.30729.01).&lt;br /&gt;The C++ compiler flags were &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/FC /O2 /arch:SSE /arch:SSE2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_DEPRECATE /FD /EHsc /GR /W3 /nologo /c /TP /errorReport:prompt&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;and the linker flags were&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/NOLOGO /SUBSYSTEM:CONSOLE /MACHINE:X86 /OPT:REF /OPT:ICF&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;I'm still using python 2.5.2.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-3154763874047290036?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/3154763874047290036/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=3154763874047290036' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3154763874047290036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/3154763874047290036'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/boostpython-vs-swigpython-benchmark.html' title='boost::python vs swig::python - a benchmark'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_u7kA1Q_ggW4/SULIXUFbVNI/AAAAAAAAAAM/i-eyUtsNHAc/s72-c/runtime.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6763856163187369387</id><published>2008-12-11T14:39:00.005-05:00</published><updated>2008-12-11T16:10:29.472-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>boost::python iterators on non-standard contrainers</title><content type='html'>If you use C++, you have to love boost. For one thing, it helps you get away from C++ by offering a nice bridge to python :-) Boost has always great documentation, but from time to time, one or two extra samples would be of help. Here is one very small contribution.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You have a C++ container type that is accessible to python using boost::python. Of course, you want to iterate on all the elements from python code like this :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;my_container_instance = make_a_container()&lt;br /&gt;for x in my_container_instance:&lt;br /&gt;     print x&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When we look at the &lt;a href="http://www.boost.org/doc/libs/1_37_0/libs/python/doc/tutorial/doc/html/python/iterators.html"&gt;documentation&lt;/a&gt;, we find that we need to introduce the binding for __iter__ like this :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;.def("__iter__", iterator&amp;lt;vector&amp;lt;int&amp;gt; &amp;gt;())&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And it works, if your container is a std::vector&amp;lt;int&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My container is a polygon, not a std::vector. It does not have a typedef for &lt;i&gt;iterator&lt;/i&gt;, it has a typedef for &lt;i&gt;Vertex_iterator&lt;/i&gt;. It has no &lt;i&gt;begin()&lt;/i&gt; method, it has a &lt;i&gt;vertices_begin()&lt;/i&gt; method. You could have a similar problem. If that's the case, you can expect a compilation error&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;c:\...\boost\python\iterator.hpp(50) : error C2039:'begin'&amp;#160;: &lt;br /&gt;n'est pas membre de 'Polygon'&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here is the offending code : &lt;br /&gt;&lt;br /&gt;    &lt;pre&gt;&lt;br /&gt;  &lt;span class="comment-delimiter"&gt;// &lt;/span&gt;&lt;span class="comment"&gt;Guts of template class iterators&amp;lt;&amp;gt;, below.&lt;br /&gt;&lt;/span&gt;  &lt;span class="keyword"&gt;template&lt;/span&gt; &amp;lt;&lt;span class="type"&gt;bool&lt;/span&gt; &lt;span class="variable-name"&gt;const_&lt;/span&gt; = &lt;span class="constant"&gt;false&lt;/span&gt;&amp;gt;&lt;br /&gt;  &lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;iterators_impl&lt;/span&gt;&lt;br /&gt;  {&lt;br /&gt;      &lt;span class="keyword"&gt;template&lt;/span&gt; &amp;lt;&lt;span class="keyword"&gt;class&lt;/span&gt; &lt;span class="type"&gt;T&lt;/span&gt;&amp;gt;&lt;br /&gt;      &lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;apply&lt;/span&gt;&lt;br /&gt;      {&lt;br /&gt;          &lt;span class="keyword"&gt;typedef&lt;/span&gt; &lt;span class="keyword"&gt;typename&lt;/span&gt; &lt;span class="constant"&gt;T&lt;/span&gt;::&lt;span class="type"&gt;iterator&lt;/span&gt; &lt;span class="type"&gt;iterator&lt;/span&gt;;&lt;br /&gt;          &lt;span class="keyword"&gt;static&lt;/span&gt; &lt;span class="type"&gt;iterator&lt;/span&gt; &lt;span class="function-name"&gt;begin&lt;/span&gt;(&lt;span class="type"&gt;T&lt;/span&gt;&amp;amp; &lt;span class="variable-name"&gt;x&lt;/span&gt;) { &lt;span class="keyword"&gt;return&lt;/span&gt; x.begin(); }&lt;br /&gt;          &lt;span class="keyword"&gt;static&lt;/span&gt; &lt;span class="type"&gt;iterator&lt;/span&gt; &lt;span class="function-name"&gt;end&lt;/span&gt;(&lt;span class="type"&gt;T&lt;/span&gt;&amp;amp; &lt;span class="variable-name"&gt;x&lt;/span&gt;) { &lt;span class="keyword"&gt;return&lt;/span&gt; x.end(); }&lt;br /&gt;      };&lt;br /&gt;  };&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And it's called by that : &lt;br /&gt;&lt;br /&gt;    &lt;pre&gt;&lt;br /&gt;&lt;span class="comment-delimiter"&gt;// &lt;/span&gt;&lt;span class="comment"&gt;An "ordinary function generator" which contains static begin(x) and&lt;br /&gt;&lt;/span&gt;&lt;span class="comment-delimiter"&gt;// &lt;/span&gt;&lt;span class="comment"&gt;end(x) functions that invoke T::begin() and T::end(), respectively.&lt;br /&gt;&lt;/span&gt;&lt;span class="keyword"&gt;template&lt;/span&gt; &amp;lt;&lt;span class="keyword"&gt;class&lt;/span&gt; &lt;span class="type"&gt;T&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;iterators&lt;/span&gt;&lt;br /&gt;    : &lt;span class="constant"&gt;detail&lt;/span&gt;::&lt;span class="constant"&gt;iterators_impl&lt;/span&gt;&amp;lt;&lt;br /&gt;        &lt;span class="constant"&gt;boost&lt;/span&gt;::&lt;span class="constant"&gt;is_const&lt;/span&gt;&amp;lt;&lt;span class="type"&gt;T&lt;/span&gt;&amp;gt;::value&lt;br /&gt;      &amp;gt;::&lt;span class="keyword"&gt;template&lt;/span&gt; &lt;span class="type"&gt;apply&lt;/span&gt;&amp;lt;&lt;span class="type"&gt;T&lt;/span&gt;&amp;gt;&lt;br /&gt;{&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That's not hard to fix, and there is nothing to modify in boost::python. What a nice illustration of the &lt;a href="http://c2.com/cgi/wiki,%202004?OpenClosedPrinciple"&gt;Open Closed Principle&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The only thing to do is to specialize the iterators template to provide our own begin/end functions. Somewhere in the .cpp file before you added the &lt;i&gt;__iter__&lt;/i&gt; declaration, add something like this code : &lt;br /&gt;&lt;br /&gt;    &lt;pre&gt;&lt;br /&gt;&lt;span class="keyword"&gt;namespace&lt;/span&gt; &lt;span class="constant"&gt;boost&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;    &lt;span class="keyword"&gt;namespace&lt;/span&gt; &lt;span class="constant"&gt;python&lt;/span&gt;&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="keyword"&gt;template&lt;/span&gt; &amp;lt;&amp;gt;&lt;br /&gt;        &lt;span class="keyword"&gt;struct&lt;/span&gt; &lt;span class="type"&gt;iterators&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;Polygon&lt;/span&gt; &amp;gt;&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="keyword"&gt;typedef&lt;/span&gt; &lt;span class="constant"&gt;Polygon&lt;/span&gt;::&lt;span class="type"&gt;Vertex_iterator&lt;/span&gt; &lt;span class="type"&gt;iterator&lt;/span&gt;;&lt;br /&gt;            &lt;span class="keyword"&gt;static&lt;/span&gt; &lt;span class="type"&gt;iterator&lt;/span&gt; &lt;span class="function-name"&gt;begin&lt;/span&gt;(&lt;span class="keyword"&gt;&lt;/span&gt; &lt;span class="type"&gt;Polygon&lt;/span&gt;&amp;amp; &lt;span class="variable-name"&gt;x&lt;/span&gt;) { &lt;span class="keyword"&gt;return&lt;/span&gt; x.vertices_begin(); }&lt;br /&gt;            &lt;span class="keyword"&gt;static&lt;/span&gt; &lt;span class="type"&gt;iterator&lt;/span&gt; &lt;span class="function-name"&gt;end&lt;/span&gt;(&lt;span class="keyword"&gt;&lt;/span&gt; &lt;span class="type"&gt;Polygon&lt;/span&gt;&amp;amp; &lt;span class="variable-name"&gt;x&lt;/span&gt;) { &lt;span class="keyword"&gt;return&lt;/span&gt; x.vertices_end(); }&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And have fun :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6763856163187369387?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6763856163187369387/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6763856163187369387' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6763856163187369387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6763856163187369387'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/boostpython-iterators-on-non-standard.html' title='boost::python iterators on non-standard contrainers'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-2206943630013818667</id><published>2008-12-10T12:29:00.002-05:00</published><updated>2008-12-11T16:11:11.809-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='SPP'/><category scheme='http://www.blogger.com/atom/ns#' term='C++'/><title type='text'>My take on C++ template metaprogramming</title><content type='html'>Fortunate accident or deliberate mistake, C++ template metaprogramming should be a tool in any C++ programmer's toolbox ; or should it? Here is what comes to mind when I think about it (in no order at all)&lt;br /&gt;&lt;br /&gt;C++ template metaprogramming...&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;   useful&lt;/li&gt;&lt;li&gt;painful&lt;/li&gt;&lt;li&gt;functional&lt;/li&gt;&lt;li&gt;long compile times&lt;/li&gt;&lt;li&gt;code bloat&lt;/li&gt;&lt;li&gt;optimization&lt;/li&gt;&lt;li&gt;verbose&lt;/li&gt;&lt;li&gt;typename&lt;/li&gt;&lt;li&gt;necessary to avoid duplication&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;With a little work I can put some order in there.&lt;br /&gt;&lt;br /&gt;The Good : useful, optimization, necessary to avoid duplication&lt;br /&gt;The Bad : painful, long compile times, code bloat&lt;br /&gt;The Ugly : Well, yeah. It's ugly :-) &lt;a href="http://foobrac.blogspot.com/2008/12/syntax-schmintax.html"&gt;Syntax Schmintax&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Good&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;You need it - you really do. Object-oriented programming failed to kill code duplication. In C++, the only way to write code that has a size pretty much proportionnal to the features you implement is with generic programming. Pretty soon you will see that genericity is not free, you need to consider the different types of parameters you can deal with. If all you want to do is dispatch to different implementations based on type properties you will need to know a little about C++ template metaprogramming. If you are up for a challenge and you try to build your algorithms and data structure in a truly generic way, you'll need to go through &lt;a href="http://www.josuttis.com/tmplbook/index.html"&gt;whole&lt;/a&gt; &lt;a href="http://www.boostpro.com/mplbook/"&gt;books&lt;/a&gt;... not that it's a bad thing.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Bad&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span class="keyword"&gt;template&lt;/span&gt;&amp;lt; &lt;span class="keyword"&gt;typename&lt;/span&gt; &lt;span class="type"&gt;src_functor_type&lt;/span&gt;, &lt;span class="keyword"&gt;typename&lt;/span&gt; &lt;span class="type"&gt;kernel_accessor_type&lt;/span&gt; &amp;gt;&lt;br /&gt;&lt;span class="keyword"&gt;inline&lt;/span&gt; &lt;span class="type"&gt;pixel_functor&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;horizontal_convolution_pixel&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;pixel_functor&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;src_functor_type&lt;/span&gt; &amp;gt;, &lt;span class="type"&gt;kernel_accessor_type&lt;/span&gt; &amp;gt; &amp;gt;&lt;br /&gt;&lt;span class="function-name"&gt;convolveh&lt;/span&gt;( &lt;span class="keyword"&gt;const&lt;/span&gt; &lt;span class="type"&gt;pixel_functor&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;src_functor_type&lt;/span&gt; &amp;gt;&amp;amp; &lt;span class="variable-name"&gt;src&lt;/span&gt;,&lt;br /&gt;           &lt;span class="keyword"&gt;const&lt;/span&gt; &lt;span class="type"&gt;kernel_accessor_type&lt;/span&gt;&amp;amp; &lt;span class="variable-name"&gt;kernel&lt;/span&gt;,&lt;br /&gt;           &lt;span class="keyword"&gt;typename&lt;/span&gt; &lt;span class="constant"&gt;kernel_accessor_type&lt;/span&gt;::&lt;span class="type"&gt;value_type&lt;/span&gt; &lt;span class="variable-name"&gt;norm&lt;/span&gt; )&lt;br /&gt;{&lt;br /&gt;    &lt;span class="keyword"&gt;typedef&lt;/span&gt; &lt;span class="keyword"&gt;typename&lt;/span&gt; &lt;span class="type"&gt;horizontal_convolution_pixel&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;pixel_functor&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;src_functor_type&lt;/span&gt; &amp;gt;, &lt;span class="type"&gt;kernel_accessor_type&lt;/span&gt; &amp;gt; &lt;span class="type"&gt;fun_type&lt;/span&gt;;&lt;br /&gt;    &lt;span class="keyword"&gt;return&lt;/span&gt; &lt;span class="type"&gt;pixel_functor&lt;/span&gt;&amp;lt; &lt;span class="type"&gt;fun_type&lt;/span&gt; &amp;gt;( fun_type( src, kernel, norm ) );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;That's what happens when it's used in real life. Since that's some of my own code (from &lt;a href="http://sourceforge.net/projects/scalex/"&gt;scalex&lt;/a&gt;), I hope there are worst examples out there.&lt;br /&gt;&lt;br /&gt;Can you see what's happening in that function? It's a simple call to a constructor. That's it. This function exists only so that users don't have to name explicitly all the types that they use. They should not have to because, obviously, those types can be deducted from the context. So there you have it : C++ template metaprogramming means you have functions where the declaration of the return type is longer that the function itself.&lt;br /&gt;&lt;br /&gt;There was a time when I wished one day this could be possible :&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  template&amp;lt; typename T &amp;gt;&lt;br /&gt;  auto my_function( const T&amp;amp; parameter )&lt;br /&gt;  {&lt;br /&gt;      return some_valid_cpp_expression;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;But not anymore. I have lost faith that it will ever happen and if it ever does it will be too little, too late. Because the C++ standard moves too slowly, C++ needs to be programmable.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;The Ugly&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;(spp&lt;br /&gt; (&lt;span class="keyword"&gt;let-syntax&lt;/span&gt; ((for-range&lt;br /&gt;               (&lt;span class="keyword"&gt;syntax-rules&lt;/span&gt; ()&lt;br /&gt;                 ((_ type var begin end body ...)&lt;br /&gt;                  (for (type var begin) (&amp;lt; var end) (++ var) body ...)))))&lt;br /&gt;&lt;br /&gt;   (function int main ()&lt;br /&gt;             (decl float[256] array)&lt;br /&gt;             (for-range int i 0 256&lt;br /&gt;                        (= (array-ref array i) 0.0))&lt;br /&gt;             (return 0))))&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Lisp! Maybe you did not expect "the visual appeal of oatmeal mixed with nail clippings" but I warned you! Hey, at least it works - the previous "spp" code generates this : &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="function-name"&gt;main&lt;/span&gt; () &lt;br /&gt;{&lt;br /&gt;    &lt;span class="type"&gt;float&lt;/span&gt; &lt;span class="variable-name"&gt;array&lt;/span&gt;[256];&lt;br /&gt;    &lt;span class="keyword"&gt;for&lt;/span&gt;( &lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="variable-name"&gt;i&lt;/span&gt; = 0; (i &amp;lt; 256); (++ i) )&lt;br /&gt;    {&lt;br /&gt;        (array[i] = 0.0);&lt;br /&gt;    };&lt;br /&gt;    &lt;span class="keyword"&gt;return&lt;/span&gt; 0;&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In this little example code density is not better, but I hope you can get the idea. C++ template metaprogramming is in itself the wrong solution to the code verbosity problem; lisp macros are a better idea. &lt;a href="http://www.vlam.ca/spp"&gt;SPP&lt;/a&gt; is my take on this. What I'm shooting for with SPP is &lt;a href="http://www.paulgraham.com/progbot.html"&gt;Bottom-Up&lt;/a&gt; programming in C++.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-2206943630013818667?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/2206943630013818667/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=2206943630013818667' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2206943630013818667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/2206943630013818667'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/my-take-on-c-template-metaprogramming.html' title='My take on C++ template metaprogramming'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-1240370521515838101</id><published>2008-12-04T14:51:00.007-05:00</published><updated>2008-12-04T15:34:56.277-05:00</updated><title type='text'>Syntax Schmintax</title><content type='html'>Syntax Schmintax. It's only syntax. Everybody can learn syntax, *everybody*.&lt;br /&gt;&lt;br /&gt;When faced with a programming problem there are always multiple choices. We are supposed to sort them out according to multiple criteria. Here are a few&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Robustness&lt;/li&gt;&lt;li&gt;Maintainability&lt;/li&gt;&lt;li&gt;Beauty/Ugliness&lt;/li&gt;&lt;li&gt;Originality, as in &lt;a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself"&gt;dry&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Performance&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;Syntax Schmintax means that the beauty of a solution should be considered only when you know robustness, maintainability, originality and performance are maximal.&lt;br /&gt;&lt;br /&gt;One example from C++ : static_cast, const_cast, reinterpret_cast and friends vs C-style casts. C++ style casts provide more information to the reader and to the compiler, are easier to find and have no cost in performance or otherwise. But they are ugly. They are syntax that's possible to avoid, that's possible not to learn. Learn it! Use it! Syntax Schmintax says : learning new syntax is easy.&lt;br /&gt;&lt;br /&gt;It's easy to learn a new syntax that does pretty much the same thing as some other syntax you know. There is no semantics to learn. What you think about and how you think about it does not change. It's not like learning &lt;a href="http://en.wikipedia.org/wiki/Scheme_%28programming_language%29"&gt;Scheme&lt;/a&gt; or &lt;a href="http://www.haskell.org/"&gt;Haskell&lt;/a&gt; (you should, by the way). Learning Scheme means you should understand what a continuation is, what a lisp macro is. Haskel is quite simply alien.&lt;br /&gt;&lt;br /&gt;Syntax is vocabulary. Syntax is good for you. Learn what's out there. Invent beautiful syntax if you can, but ugly syntax is better than nothing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-1240370521515838101?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/1240370521515838101/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=1240370521515838101' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1240370521515838101'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/1240370521515838101'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/syntax-schmintax.html' title='Syntax Schmintax'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6519463035788700342</id><published>2008-12-02T21:37:00.004-05:00</published><updated>2009-03-13T11:20:14.072-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='compyle'/><title type='text'>How I optimize Python code</title><content type='html'>I Compyle it :-)&lt;br /&gt;&lt;br /&gt;I wrote a library that takes a python string and returns a proxy object that can be used like a python module. Inside the proxy module, there are proxy functions. When a proxy function is called, it looks at the type of its arguments and generates a dll specific to those types.&lt;br /&gt;&lt;br /&gt;So you have something like this : python -&gt; C++ -&gt; dll -&gt; really fast code.&lt;br /&gt;&lt;br /&gt;How fast? &lt;a href="http://www.vlam.ca/compyle"&gt;Really fast&lt;/a&gt;. Thousands of times faster. Even faster than the C++ code I would normally write. The generated code runs really fast because it's threaded, because the generated code is pretty conservative (C++ compilers like conservative code) and because some image processing functions are recognized as intrinsics. The just-in-time compiler does not support the whole Python language, but it supports enough of it to optimize pretty complex algorithms. I use it mainly to optimize scientific applications, but if you'd like to try it out on other kind of applications (string processing? AI? rendering?) tell me, it may not be a big effort for me to add what's missing.&lt;br /&gt;&lt;br /&gt;If you'd like to try out Compyle, send me a message or vist &lt;a href="http://www.vlam.ca/"&gt;VLAM's website&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6519463035788700342?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6519463035788700342/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6519463035788700342' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6519463035788700342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6519463035788700342'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2008/12/how-i-optimize-python-code.html' title='How I optimize Python code'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-7544285983412393479</id><published>2007-07-04T20:32:00.001-05:00</published><updated>2008-12-11T16:12:06.621-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scheme'/><title type='text'>lambda-image</title><content type='html'>Vous pourrez trouver mon dernier projet ici : &lt;a href="https://sourceforge.net/projects/lambda-image"&gt;https://sourceforge.net/projects/lambda-image&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;C'est un logiciel de traitement d'images programmable. Il est écrit en scheme en utilisant MrEd (http://www.plt-scheme.org/). Le but est d'en faire un éditeur sérieux pour les professionnels en analyse d'images et en vision artificielle. Je compte y intégrer un language de transformation d'images qui pourra être compilé en C++ pour un maximum de performances.&lt;br /&gt;&lt;br /&gt;Comme le projet est à un stade peu avancé je lance un appel aux contributions et aux idées à tous les programmeurs intéressés. Je crain qu'il ne soit pas très utile en lui-même dans son état actuel pour des utilisateurs ne sachant pas programmer. Soyez avertis!&lt;br /&gt;&lt;br /&gt;Si l'évolution du projet vous intéresse, laissez-le moi savoir.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-7544285983412393479?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/7544285983412393479/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=7544285983412393479' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/7544285983412393479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/7544285983412393479'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2007/07/lambda-image.html' title='lambda-image'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6061852344316147831</id><published>2007-01-17T21:29:00.001-05:00</published><updated>2008-12-11T16:12:37.877-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='scheme'/><title type='text'>Voilà</title><content type='html'>Le prototype est publié.&lt;br /&gt;&lt;a href="https://sourceforge.net/projects/py-scm"&gt;https://sourceforge.net/projects/py-scm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Si vous y trouvez une utilité, donnez-m'en des nouvelles.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6061852344316147831?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6061852344316147831/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6061852344316147831' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6061852344316147831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6061852344316147831'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2007/01/voil.html' title='Voilà'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-4440129533990101595</id><published>2007-01-05T12:56:00.001-05:00</published><updated>2008-12-11T16:12:22.830-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='scheme'/><title type='text'>Python in Scheme on sourceforge</title><content type='html'>&lt;a href="https://sourceforge.net/projects/py-scm"&gt;https://sourceforge.net/projects/py-scm&lt;/a&gt; is where the code will soon be.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-4440129533990101595?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/4440129533990101595/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=4440129533990101595' title='2 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4440129533990101595'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/4440129533990101595'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2007/01/python-in-scheme-on-sourceforge.html' title='Python in Scheme on sourceforge'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6860766684752178101.post-6964160078341082027</id><published>2006-12-11T20:40:00.001-05:00</published><updated>2008-12-11T16:10:56.696-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='scheme'/><title type='text'>Python in Scheme</title><content type='html'>Anybody wants access to their python code in scheme?&lt;br /&gt;&lt;br /&gt;I do.&lt;br /&gt;&lt;br /&gt;Since I did not find any really easy way to do it (a library already done) I started writing my own. Here is what I came up with after a few tries: &lt;a href="http://www.foobrac.com/static/pes.scm"&gt;http://www.foobrac.com/static/pes.scm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;If you don't feel like reading code, here is the gist of it&lt;br /&gt;&gt; (py-eval "2+2")&lt;br /&gt;"4"&lt;br /&gt;&lt;br /&gt;It's pretty far from a state I would call usefull... but in a few days (weeks if I'm lazy and watch the fifth season of 24 I just bought... don't tell me the end!) it could be able to load user modules and allow pretty decent interoperability between Scheme and Python.&lt;br /&gt;&lt;br /&gt;So, anybody wants access to their python code in scheme? If I know of potential users I'll do it faster and better :-)&lt;br /&gt;&lt;br /&gt;If you know a way to do what I want without writing the library I'm starting, please tell me. Who knows, maybe I could find something better to do with my time! Yeah, I'd probably just watch TV or add features to my little search engine (&lt;a href="http://www.foobrac.com/"&gt;http://www.foobrac.com&lt;/a&gt;)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Bonne nuit tout le monde,&lt;br /&gt;&lt;br /&gt;MAD&lt;br /&gt;&lt;br /&gt;ps: I'm not trying to build a python interpreter in scheme. I simply want to call  my python code within a scheme application.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6860766684752178101-6964160078341082027?l=foobrac.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://foobrac.blogspot.com/feeds/6964160078341082027/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6860766684752178101&amp;postID=6964160078341082027' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6964160078341082027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6860766684752178101/posts/default/6964160078341082027'/><link rel='alternate' type='text/html' href='http://foobrac.blogspot.com/2006/12/python-in-scheme.html' title='Python in Scheme'/><author><name>MAD</name><uri>http://www.blogger.com/profile/04830234645710297580</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
