{"id":1674,"date":"2009-08-03T08:53:54","date_gmt":"2009-08-03T07:53:54","guid":{"rendered":"http:\/\/www.itwriting.com\/blog\/1674-sqlite-c-port-raises-hopes-for-a-silverlight-local-database-manager.html"},"modified":"2009-08-03T08:53:54","modified_gmt":"2009-08-03T07:53:54","slug":"sqlite-c-port-raises-hopes-for-a-silverlight-local-database-manager","status":"publish","type":"post","link":"https:\/\/www.itwriting.com\/blog\/1674-sqlite-c-port-raises-hopes-for-a-silverlight-local-database-manager.html","title":{"rendered":"SQLite C# port raises hopes for a Silverlight local database manager"},"content":{"rendered":"<p>Yesterday programmer Noah Hart <a href=\"http:\/\/www.mail-archive.com\/sqlite-users@sqlite.org\/msg44921.html\">announced<\/a> a port of <a href=\"http:\/\/sqlite.org\/\">SQLite<\/a> to C#:<\/p>\n<blockquote>\n<p>I am pleased to announce that the C# port is done to the point where others can look at it.<\/p>\n<\/blockquote>\n<p>Unfortunately the code was taken offline almost immediately afterwards, thanks to the intervention of the author of SQLite, D Richard Hipp:<\/p>\n<blockquote>\n<p>Noah, you are welcomed, even encouraged, to take the source code to SQLite and translate it in any way you want and do whatever you want with it. But you need to make it abundantly clear to everyone on your site and in the comments of your source code that your code is <strong>not<\/strong> the original SQLite &#8230; SQLite is a registered trade mark. If I don&#8217;t defend the trademark, then I could lose it. So, I really do need to insist that you not use the name &quot;SQLite&quot; for your product. <\/p>\n<\/blockquote>\n<p>The reason given is that Dr Hipp does not want to receive support requests for the port, though the intervention is a little surprising since there are other 3rd party adaptions out there that do use the SQLite name, though these generally modify or wrap the original code rather than porting it completely. <\/p>\n<p>Still, Hart has taken it in his stride and it looks as if the code may be back soon under the name sqlsharp \u2013 a <a href=\"http:\/\/code.google.com\/p\/sqlsharp\/\">Google code project<\/a> with that name has been created. I hope this is the name since I <a href=\"http:\/\/www.mail-archive.com\/sqlite-users@sqlite.org\/msg44944.html\">suggested it<\/a>, though it is rather an obvious one and I might not have been the first.<\/p>\n<p>Why the interest? First, it\u2019s always interesting to compare languages. Currently, Hart says his executable compiles to 528kb vs 506kb for the native version, and performs <a href=\"http:\/\/www.nabble.com\/Re%3A-ANN%3A--SQLite-3.6.16.C--p24769455.html\">3-5 times more slowly<\/a> (results in rows per second):<\/p>\n<table>\n<tbody>\n<tr>\n<td>Test<\/td>\n<td>SQLite3 C#<\/td>\n<td>SQLite3<\/td>\n<\/tr>\n<tr>\n<td>Inserts<\/td>\n<td>300K<\/td>\n<td>1300K<\/td>\n<\/tr>\n<tr>\n<td>Selects<\/td>\n<td>1500K<\/td>\n<td>8450K<\/td>\n<\/tr>\n<tr>\n<td>Updates<\/td>\n<td>60K<\/td>\n<td>300K<\/td>\n<\/tr>\n<tr>\n<td>Deletes<\/td>\n<td>250K<\/td>\n<td>700K<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Although that may seem disappointing, SQLite is remarkably fast so even 5 times slower is still acceptable in many contexts; and there are no doubt many possibilities for optimisation.<\/p>\n<p>What\u2019s the point? Hart says it was a C# learning exercise, which is fair enough. Others are hopeful for a local database manager for Microsoft Silverlight, writing to isolated storage. Competitor <a href=\"http:\/\/www.adobe.com\/products\/air\/\">Adobe AIR<\/a> includes SQLite in the runtime, as does <a href=\"http:\/\/gears.google.com\/\">Google Gears<\/a>.<\/p>\n<p>Silverlight may a stretch for Hart\u2019s port. Silverlight does not allow platform invoke or code marked as unsafe; and while there are apparently only a few p\/invoke calls I\u2019m guessing there may be many unsafe sections since the original SQLite makes heavy use of pointers.*<\/p>\n<p>Although Silverlight is an implementation of the .NET Framework, it does not include the System.Data namespace. It does include System.Linq.<\/p>\n<p>There are a few other efforts at creating a local database manager for Silverlight, including <a href=\"http:\/\/www.mcobject.com\/perst\">McObject\u2019s Perst<\/a>, db4o (<a href=\"http:\/\/developer.db4o.com\/blogs\/product_news\/archive\/2009\/06\/10\/in-the-search-of-silver.aspx\">work in progress<\/a>), and <a href=\"http:\/\/silverdb.codeplex.com\/\">Silverlight Database<\/a> which works by persisting XML.<\/p>\n<p>*<strong>Update<\/strong>: the project has now been <a href=\"http:\/\/code.google.com\/p\/csharp-sqlite\/\">published as csharp-sqlite<\/a>, which is an excellent name; it looks as if Hipp relented to some extent. Now that I\u2019ve seen the code I find I\u2019m wrong about unsafe sections. In fact, I added C#-Sqlite to a Silverlight project and it failed to compile with a mere 53 errors, many of them related to file locking \u2013 possibly less necessary in isolated storage? A Silverlight port looks feasible. <\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:3abe022e-b390-4c56-ba7d-6ae37eab11f0\" class=\"wlWriterEditableSmartContent\">Technorati Tags: <a href=\"http:\/\/technorati.com\/tags\/silverlight\" rel=\"tag\">silverlight<\/a>,<a href=\"http:\/\/technorati.com\/tags\/sqlite\" rel=\"tag\">sqlite<\/a>,<a href=\"http:\/\/technorati.com\/tags\/sqlsharp\" rel=\"tag\">sqlsharp<\/a>,<a href=\"http:\/\/technorati.com\/tags\/database\" rel=\"tag\">database<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Yesterday programmer Noah Hart announced a port of SQLite to C#: I am pleased to announce that the C# port is done to the point where others can look at it. Unfortunately the code was taken offline almost immediately afterwards, thanks to the intervention of the author of SQLite, D Richard Hipp: Noah, you are &hellip; <a href=\"https:\/\/www.itwriting.com\/blog\/1674-sqlite-c-port-raises-hopes-for-a-silverlight-local-database-manager.html\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">SQLite C# port raises hopes for a Silverlight local database manager<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,55,77,80,94],"tags":[],"class_list":["post-1674","post","type-post","status-publish","format-standard","hentry","category-database","category-microsoft","category-silverlight","category-software-development","category-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/1674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/comments?post=1674"}],"version-history":[{"count":0,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/posts\/1674\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/media?parent=1674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/categories?post=1674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itwriting.com\/blog\/wp-json\/wp\/v2\/tags?post=1674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}