<?xml version="1.0" encoding="utf-8"?>
        <?xml-stylesheet type="text/css" href="http://blog.ngas.ch/styles/feed.css"?>
<rss version="2.0"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:admin="http://webns.net/mvcb/"
 xmlns:atom="http://www.w3.org/2005/Atom"
>
<channel>
<title>Filed under: programming | Pas un Geek en tant que tel</title>
<atom:link href="http://blog.ngas.ch/archives/programming/index-rss.xml" rel="self" type="application/rss+xml" />
<link>http://blog.ngas.ch</link>
<description>No Geek As Such</description>
<dc:language>en-us</dc:language>
<dc:creator><a href=&quot;https://plus.google.com/114292582268779510325&quot;>Tonnerre Lombard</a></dc:creator>
<dc:date>2011-12-12T21:20:42+01:00</dc:date>
<admin:generatorAgent rdf:resource="http://nanoblogger.sourceforge.net" />

<item>
<link>http://blog.ngas.ch/archives/2010/07/18/quotes_from_the_people_who_brought_you_php/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2010/07/18/quotes_from_the_people_who_brought_you_php/index.html</guid>
<title>Quotes from the people who brought you PHP</title>
<dc:date>2010-07-18T16:27:43+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> programming, broken</dc:subject>
<description><![CDATA[<p>
 <a href="https://www.mirbsd.org/wlog-10.htm">Thorsten Glaser</a> from
 <a href="http://www.tarent.de/">Tarent</a> added a number of nice quotes
 from PHP developer
 <a href="http://en.wikipedia.org/wiki/Rasmus_Lerdorf">Rasmus Lerdorf</a>
 to the PHP source code of Evolvisforge, the gforge clone of his company:
</p>
<p><i>
 I have absolutely no idea how to write a programming language, I just
 kept adding the next logical step on the way.
</i></p>
<p>
 <a href="https://evolvis.org/scm/viewvc.php/trunk/gforge_base/evolvisforge/gforge/common/include/utils.php?root=evolvis&amp;r1=6547&amp;r2=6546&amp;pathrev=6547&amp;diff_format=u">gforge_base/evolvisforge/gforge/common/include/utils.php:1009</a>
</p>
<p><i>
 I was really, really bad at writing parsers. I still am really bad at
 writing parsers.
</i></p>
<p>
 <a href="https://evolvis.org/scm/viewvc.php/trunk/gforge_base/evolvisforge/gforge/common/include/minijson.php?revision=6547&amp;root=evolvis&amp;view=markup&amp;pathrev=6547">gforge_base/evolvisforge/gforge/common/include/minijson.php</a>
</p>
<p><i>
 I'm not a real programmer. I throw together things until it works
 then I move on. The real programmers will say &quot;yeah it works but
 you're leaking memory everywhere. Perhaps we should fix that.&quot; I'll
 just restart apache every 10 requests.
</i></p>
<p>
 <a href="https://evolvis.org/scm/viewvc.php/trunk/gforge_base/evolvisforge/gforge/www/pm/t_follow.php?revision=6547&amp;root=evolvis&amp;view=markup&amp;pathrev=6547">gforge_base/evolvisforge/gforge/www/pm/t_follow.php</a>
</p>
<p><i>
 We have things like protected properties. We have abstract methods.
 We have all this stuff that your computer science teacher told you
 you should be using. I don't care about this crap at all.
</i></p>
<p>
 <a href="https://evolvis.org/scm/viewvc.php/trunk/gforge_base/evolvisforge/gforge/www/pm/t_lookup.php?revision=6547&amp;root=evolvis&amp;view=markup&amp;pathrev=6547">gforge_base/evolvisforge/gforge/www/pm/t_lookup.php</a>
</p>
<p>
 I think people like Rasmus explain a lot about the poor design and the
 many implementation flaws of the PHP programming language.
</p>
<p>
 Thanks as well to <a href="http://www.slideshare.net/bsiegert">Benny
  Siegert</a> who provided the quotes.
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2010/06/12/cassandra_in_pkgsrc/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2010/06/12/cassandra_in_pkgsrc/index.html</guid>
<title>Cassandra in pkgsrc</title>
<dc:date>2010-06-12T07:44:11+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> programming, free_software</dc:subject>
<description><![CDATA[<p>
 During this second quarter of 2010, I added a number of Cassandra related
 packages to the pkgsrc package collection. They will appear in the next
 quarterly branches. The following packages have been added:
</p>
<ul>
 <li>databases/apache-cassandra: Highly scalable, distributed structured key-value store</li>
 <li>databases/libcassandra: C++ interface to Cassandra</li>
 <li>databases/p5-Net-Cassandra: Perl5 module for accessing the Cassandra database</li>
 <li>databases/py-cassa: Python client library for Cassandra</li>
 <li>databases/ruby-activerecord-cassandra: ActiveRecord Cassandra adapter</li>
 <li>databases/ruby-cassandra: Ruby extension for Cassandra</li>
</ul>
<p>
 Apache Cassandra is a next generation, No-SQL, non-relational distributed
 database. Unlike SQL databases, it behaves more like a key-value store
 and can store nested data structures. Cassandra is already in use by a
 number of large web sites, and has clients for a number of programming
 languages, like the ones mentioned above.
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2010/03/10/rpm_package_for_nanoblogger_and_preparing_a_new_package_repository/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2010/03/10/rpm_package_for_nanoblogger_and_preparing_a_new_package_repository/index.html</guid>
<title>RPM package for Nanoblogger and preparing a new package repository</title>
<dc:date>2010-03-10T14:28:40+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> free_software, programming</dc:subject>
<description><![CDATA[<p>
 Since I was searching for my <i>nanoblogger</i> RPM or .spec file for the
 third time now, I decided that now that I'm leaving
 <a href="http://www.sygroup.ch/">SyGroup</a> it's time to move my software
 development and packages to a well-defined place. As I recently saw the
 domain <i>young-solutions.ch</i> and as I'm the owner of
 <a href="http://www.ancient-one.ch/">ancient-one.ch</a>, I figured it would
 be a nice fit to put it all on
 <a href="http://www.ancient-solutions.ch/">ancient-solutions.ch</a>.
</p>
<p>
 If you're expecting content there yet, you're a tad too early. The idea is
 merely a sketch at this point. So far my plans comprise an installation of
 <a href="http://www.gitorious.org/">Gitorious</a> so I can migrate my
 projects away from <a href="http://github.com/tonnerre/">Github</a> to my
 own hosted place. Of course, <a href="http://bsdprojects.net/">bsdprojects.net</a>
 was meant for this initially, but it's less private.
</p>
<p>
 The current idea of the domain looks as follows:
</p>
<table border="0">
 <thead>
  <tr>
   <th>Host</th>
   <th>Content</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td><a href="http://www.ancient-solutions.ch/">www.ancient-solutions.ch</a></td>
   <td>A small web site describing the whole thing, with links to the other subsites; or maybe the gitorious site?</td>
  </tr>
  <tr>
   <td><a href="http://blog.ancient-solutions.ch/">blog.ancient-solutions.ch</a></td>
   <td>A blog with progress information</td>
  </tr>
  <tr>
   <td><a href="http://git.ancient-solutions.ch/">git.ancient-solutions.ch</a></td>
   <td>The git repositories with a gitweb for everyone to see</td>
  </tr>
  <tr>
   <td><a href="http://bcollect.ancient-solutions.ch/">bcollect.ancient-solutions.ch</a></td>
   <td>A short web site (wiki?) about bcollect</td>
  </tr>
  <tr>
   <td><a href="http://clib.ancient-solutions.ch/">clib.ancient-solutions.ch</a></td>
   <td>A short web site (wiki?) about clib</td>
  </tr>
  <tr>
   <td><a href="http://rpm.ancient-solutions.ch/">rpm.ancient-solutions.ch</a></td>
   <td>RPM package repositories</td>
  </tr>
  <tr>
   <td><a href="http://deb.ancient-solutions.ch/">deb.ancient-solutions.ch</a></td>
   <td>Debian package repositories</td>
  </tr>
 </tbody>
</table>
<p>
 The spec files etc. would eventually end up on <i>git.ancient-solutions.ch</i>.
</p>
<p>
 Anybody got a cthulhu logo?
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/11/30/mysql_5_1_few_new_features_but_many_new_bugs/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/11/30/mysql_5_1_few_new_features_but_many_new_bugs/index.html</guid>
<title>MySQL 5.1: few new features, but many new bugs</title>
<dc:date>2008-11-30T00:34:45+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> broken, programming</dc:subject>
<description><![CDATA[<p>
 As <a href="http://monty-says.blogspot.com/">Monty</a>, who is apparently
 working at MySQL, wrote yesterday in his blog, there appears to be a
 rahter large number of quite devastating bugs left in MySQL 5.1 at the
 time of its release, many of which would have been declared release
 critical by open source projects.
</p>
<p>
 In <a href="http://monty-says.blogspot.com/2008/11/oops-we-did-it-again-mysql-51-released.html"><i>Oops, we did it again</i></a>,
 <i>Monty</i> names a number of these bugs and outlines variety of bad
 management decisions which have lead to the current situation, and which
 apparently have lead to similar situations in the past.
</p>
<p>
 To me, it does not really come as a surprise. As you may or may not know,
 I have been following the MySQL company, community and products for years,
 and haven't seen too many different types of releases so far. In any case,
 I strongly support the suggestion of <i>Monty</i> and also strictly
 recommend staying with MySQL 5.0 for now &mash; or to migrate to
 <a href="http://www.postgresql.org/">PostgreSQL</i>, if possible.
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/11/26/mysql_build_system_command_line_wildness/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/11/26/mysql_build_system_command_line_wildness/index.html</guid>
<title>MySQL build system command line wildness</title>
<dc:date>2008-11-26T12:31:18+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> broken, programming</dc:subject>
<description><![CDATA[<p>
 Only seconds ago, the MySQL build system produced a ton of compiler command
 lines like this one:
</p>
<p><code>
 gcc -shared  -Wl,--whole-archive ndbapi/.libs/libndbapi.a common/transporter/.libs/libtransporter.a common/debugger/.libs/libtrace.a common/debugger/signaldata/.libs/libsignaldataprint.a mgmapi/.libs/libmgmapi.a common/mgmcommon/.libs/libmgmsrvcommon.a common/logger/.libs/liblogger.a common/portlib/.libs/libportlib.a common/util/.libs/libgeneral.a -Wl,--no-whole-archive  -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lpthread -lcrypt -lnsl -lm -lpthread  -Wl,-soname -Wl,libndbclient.so.0 -o .libs/libndbclient.so.0.0.0
</code></p>
<p>
 It seems that it really desperately wants to link against libpthread.
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/11/25/your_daily_pot_of_mysql_insanity_threading/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/11/25/your_daily_pot_of_mysql_insanity_threading/index.html</guid>
<title>Your daily pot of MySQL insanity: Threading</title>
<dc:date>2008-11-25T18:34:20+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> broken, programming</dc:subject>
<description><![CDATA[<p>
 I really know I shouldn't look into MySQL source code, but since there are
 customers who really entrust their data to this piece of software, I
 sometimes have to.
</p>
<p>
 The task today: Updating PHP on Etch to version 5.2.6. Sounds easy, right?
 Wrong. Because after you put up with disabling all the new security
 extension which prevent the worst PHP scripts you've ever seen from
 running, and after fiddling half a day with weird compile time detection
 scripts which don't work in a uniform way, i.e. discover different
 environments under different circumstances, thus leaving you with a
 PHP which is in a constant debate with itself where its extension
 directory really is, &hellip;
</p>
<p>
 &hellip;you finally come to the point where you have a working PHP package
 which waits infinitely on a futex on exit. A command as simple as
 <i>php -v</i> hangs indefinitely.
</p>
<p>
 Following the code path further up, there is <i>main()</i>,
 <i>php_module_shutdown()</i>, <i>zend_shutdown()</i> (Why this stack order?!),
 <i>zend_hash_graceful_reverse_destroy()</i>, <i>zend_hash_apply_deleter()</i>,
 <i>module_destructor()</i>, <i>zm_shutdown_mysql()</i> (Argh, there's our
 other worst offender), <i>mysql_server_end()</i>, <i>my_end()</i>,
 <i>my_thread_global_end()</i>, <i>pthread_cond_destroy()</i>, &hellip;
</p>
<p>
 Digging through the code a bit, and digging through the glibc code some
 more, it becomes clear that this is indeed one of the good old
 <i>pthread_exit()</i> NPTL bugs from older glibc days. For once, it seems
 that Debian has also shipped beta software to the world. At least it
 wasn't some important system component, only the libc.
</p>
<p>
 Looking around some more, I stumbled over the
 <a href="http://bugs.php.net/bug.php?id=42625">PHP bug #42625</a>. It is
 not very helpful, though, it only proclaims:
</p>
<p><pre>
 Problem will solve itself when you rename /lib/tls to
 /lib/tls.go.fuck.yourself
</pre></p>
<p>
 Thanks for the suggestion, dear PHP people, but I have to get some work
 done first. Of course the above workaround does its job, but it is
 simply not what you would like to see in your server environment. And
 I don't mean the name.
</p>
<p>
 So I dug out a different patch for <i>mysql</i> which adds code to detect
 whether or not the glibc NPTL is in use. In fact, it gets the check
 entirely wrong by checking if the OS is Linux, while the bug is certain
 to appear on other operating systems running glibc as well. In that
 precise moment, though, I couldn't have cared less.
</p>
<p>
 Digging through the related header files, some more horrid things turned
 up which made it perfectly clear that I should not have gone there. One
 comment was rather odd:
</p>
<p><code>
 /*Irena: compiler does not like this: */<br/>
 /*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */
</code></p>
<p>
 Yeah, Irena, I can imagine perfeclty well why the compiler didn't like
 that. After all, typed arguments aren't really supported in preprocessor
 macros. It can be hacked in using tricks, but they will always be
 tricks. However, now that you found out that the compiler doesn't like
 it, why commit it?
</p>
<p>
 Only a number of lines further, there is some code to handle a nonexistent
 errno:
</p>
<p><code>
 #ifndef ESRCH<br/>
 /* Define it to something */<br/>
 #define ESRCH 1<br/>
 #endif
</code></p>
<p>
 Maybe it is not the best idea after all to define <i>ESRCH</i> to <i>EPERM</i>.
</p>
<p>
 Then finally I am at the code I want to modify, but there is some oddity
 as well (there's always one more oddity). The added thread types for the
 header file are not flags or anything, they just enumerate types of
 libraries. However, no enum is used. That's ok, but the numbering is
 slightly odd:
</p>
<p><code>
 #define THD_LIB_OTHER   1<br/>
 #define THD_LIB_NPTL    2<br/>
 #define THD_LIB_LT      4<br/>
</code></p>
<p>
 Why bitwise numbering if it is not a flag? Or can a threading library be
 LT and OTHER at a time?
</p>
<p>
 Of course, that's all not dangerous, but it gives a very odd impression
 &hellip;
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/11/25/driving_mysql_ad_absurdum/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/11/25/driving_mysql_ad_absurdum/index.html</guid>
<title>Driving MySQL ad absurdum</title>
<dc:date>2008-11-25T11:56:56+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> programming</dc:subject>
<description><![CDATA[<p>
 I recently discovered that apparently there are database people with an
 insanely brilliant sense of humour:
 <a href="https://launchpad.net/drizzle">Drizzle</a>.
</p>
<p>
 <i>Drizzle</i> is a clone of MySQL 6.0 where any type of useful features
 has been removed. Its focus lies on <i>Simply design for ease of
  installation and management</i> (sic). There is a large list of features
 which have been removed:
</p>
<ul>
 <li><i>Stored procedures</i>, ok, they are not usually very useful in
  well-designed software, or maybe they are?</li>
 <li><i>Query caches</i>, so that queries will have to be reparsed and
  reexecuted every time, slowing down normal operation significantly</li>
 <li><i>Prepared statements</i>, slowing down repeated operations
  significantly and re-opening the doors to SQL injections</li>
 <li><i>Views</i>, ok, I admit I have started to dislike them myself</li>
 <li><i>Triggers</i>, because who cares about data integrity and the likes</li>
 <li><i>Grants</i>, who needs permission management anyway? Any attacker should
  be able to enjoy full damage capability</li>
 <li><i>Some storage engines</i> &mdash; I think this one slipped through,
  as it is not a hilarious idea</li>
</ul>
<p>
 At the first glance I thought that someone was about to commit a devastating
 stupidity, but then, reading through the web sites and source code I am now
 convinced that this is an artistic act, aimed at making fun of the puritan
 MySQL community. Someone has proved a really great class of humour,
 especially in the way he imitates fresh students who fork software projects
 despite having no idea of what they're talking about. Also, the spelling
 mistakes look really authentic. I had a very good laugh.
</p>
<p>
 Thank you a lot, Mr. <i>Brian Aker</i>, you're really a great commedian of
 the Open Source community!
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/11/04/for_all_django_fans/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/11/04/for_all_django_fans/index.html</guid>
<title>For all Django fans</title>
<dc:date>2008-11-04T11:06:44+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> programming</dc:subject>
<description><![CDATA[<p style="background-color: #ffa4d6; color: #FFFFFF;">
 There is now <a style="color: #dc04fd;" href="http://djangopony.com/">an ultimate must-have for all
  Django fans</a>. <b>OMG Ponies!</b>
</p>
<p>
 Unfortunately, it appears that this pony is not even free.
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/11/04/sqlalchemy_with_ancient_methods_against_modern_it/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/11/04/sqlalchemy_with_ancient_methods_against_modern_it/index.html</guid>
<title>SQLAlchemy: With ancient methods against modern IT</title>
<dc:date>2008-11-04T09:32:18+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> broken, programming</dc:subject>
<description><![CDATA[<p>
 There is a small number of projects the Python developers are especially
 proud of: <a href="http://www.zope.org/">Zope</a> and
 <a href="http://www.sqlalchemy.org/">SQLAlchemy</a>.
</p>
<p>
 The fact that the Python core team deliberately keeps breaking compatibility
 for Zope is probably bad enough, but at least SQLAlchemy appears to work
 well enough with the various versions. Well, but how does it work?
</p>
<p>
 The answer is: bizarre.
</p>
<h2>Never trust the database to get sequences right!</h2>
<p>
 The first thing I discovered was with PostgreSQL and sequences. Some tables
 use sequences for creating their primary key, which is then going to be a
 64-bit integer. This is done automatically by either not naming the primary
 key column on insert, or by using the keyword <i>DEFAULT</i>.
</p>
<p>
 Looking through the debug output, however, items like these can be spotted:
</p>
<p><code>
 2008-11-04 09:26:24,258 INFO sqlalchemy.engine.base.Engine.0x..d0 select nextval('data_from_box_id_seq')
</code></p>
<p>
 This is wrong on a number of levels. At this point, SQLalchemy manually
 queries the next value returned by the sequence for the <i>id</i> column.
 This value is consequently used in the <i>insert</i> statement for the
 <i>id</i> column. This breaks the atomicity of the <i>insert</i>
 statement &mdash; rather than letting PostgreSQL handle things internally
 as it's supposed to, the insert statement is artificially split into two
 statements. Of course, this also means that two SQL operations are
 performed, which almost doubles the network overhead (especially over
 encrypted connections).
</p>
<p>
 The most likely reason why this is done is to have the row ID of the
 newly inserted row for use in the client side object representation.
 However, PostgreSQL has two much better mechanisms achieving the same:
 Firstly, the ID can be queried using the <i>last_insert_id</i> operation,
 or, even better, everything can be handled in one statement by using
 the <i>RETURNING</i> keyword:
</p>
<p><code>
 INSERT INTO data_from_box VALUES (DEFAULT, something, else) RETURNING id;
</code></p>
<h2>Prepared statements are for the weak and timid</h2>
<p>
 An even more bizarre affection manifests itself in the support for MySQL.
 Rather than to make use of the prepared statements, which are mandated
 by the API specification, SQLAlchemy attempts to reproduce prepared
 statements in the SQLAlchemy code, and to naturalize SQL statements
 manually. Then, the resulting statement is <i>PREPARE</i>d and
 <i>EXECUTE</i>d.
</p>
<p>
 This of course constitutes a duplication of functionality, and more than
 this, the SQLAlchemy users are now prone to SQLAlchemy prepared statement
 naturalization bugs which cannot really occurr in SQL prepared statements
 (because they are never synchronized into a string but used as-is).
</p>
<p>
 Overall, it is very hard to say what the SQLAlchemy developers had in mind,
 but it seems clear that it was nothing useful.
</p>]]></description>

</item>
<item>
<link>http://blog.ngas.ch/archives/2008/10/29/iterating_hot_air/index.html</link>
<guid isPermaLink="true">http://blog.ngas.ch/archives/2008/10/29/iterating_hot_air/index.html</guid>
<title>Iterating hot air</title>
<dc:date>2008-10-29T13:45:42+01:00</dc:date>
<dc:creator>Tonnerre Lombard</dc:creator>
<dc:subject> broken, programming</dc:subject>
<description><![CDATA[<p>
 Python allows to create iterators through the builtin function
 <i>iter</i>. This function has two ways of being called:
</p>
<ul>
 <li><b>iter</b>(<i>collection</i>) -> <i>iterator</i></li>
 <li><b>iter</b>(<i>callable</i>, <i>sentinel</i>) -> <i>iterator</i></li>
</ul>
<p>
 The first call is rather unproblematic for sure. It calls a class method,
 it gets its object and that's it.
</p>
<p>
 The second variant is however utterly useless. The callable is not called
 with any object &mdash; in fact, the call to <i>iter</i> does not even
 know what object is being iterated. This requires the programmer to
 store the state externally in some kind of global variable, or not to
 have any state at all. The latter would render the iterator rather pointless,
 since a crucial part of the purpose of an iterator is to externalize
 the state.
</p>]]></description>

</item>
</channel>
</rss>

