5 ms·
C is great and SQLite seems doing amazing leveraging its power. Yet I bloody wish there were alternative (yet 100% compatible on the file format and SQL dialect
by qwerty456127 9y ago
C is great and SQLite seems doing amazing leveraging its power. Yet I bloody wish there were alternative (yet 100% compatible on the file format and SQL dialect levels) SQLite implementations native to specific languages/platforms (e.g. .Net). In just so many cases the DB speed is the least priority while simplicity and portability are valued much higher (in these particular cases). Every time I build a humble desktop .Net app featuring an SQLite database it turns into in a ridiculous "try this, google a lot, try that, repeat, .... oh wow, it works!... oh, it doesn't" nightmare and even if it actually starts working nobody really knows how to deploy such an app on another computer (especially if it runs a different kind of OS) correctly.
SQLite is arguably the best of what has happened to the world of desktop/embedded databases ever yet lack of alternative (not necessarily this fast) implementations in high-level languages is its main problem IMHO.
- laumars 9y agoIve used sqlite a lot in recent years and found the issue you describe to be largely one that only affects Windows deployments. On Linux, FreeBSD, Solaris and OS X builds it's all just worked for me. But the same build scripts will fail for a multitude of subtle ways on Windows. IIRC (I've not targeted Windows much recently) I've found the easiest way to get it working was just to have mingw (or similar POSIX layer) and build sqlite from within that.
- WorldMaker 9y agoAs with most things, your mileage varies a lot based on what you are used to. The previous poster mentioned "cross-platform" and I think that is where the most headaches lie because you might know one permutation, but not all of them. For instance, Windows binary deployments are quite predictable (and often dead simple; so easy a lot of Windows installers get it wrong and yet still work), but on *nix you may have to fight distro differences in libc or get a dozen different answers on what you should statically link in your compile versus what you "must" dynamically link and a half-dozen different installers/bundlers/distro tools to deal with making sure the shared libraries are both installed and correctly linked to. What "just works" is often relative and the magic is very easily dispelled in that terrible state of "why isn't this working?", especially if it "just works" like magic for other people. For what it is worth, the Windows UWP platform even bundles a shared SQLite install (as like Android and iOS) and using it is quite easy in a bunch of languages (just not easily portable cross-platform).
- laumars 9y ago> For instance, Windows binary deployments are quite predictable (and often dead simple; so easy a lot of Windows installers get it wrong and yet still work), but on nix you may have to fight distro differences in libc or get a dozen different answers on what you should statically link in your compile versus what you "must" dynamically link and a half-dozen different installers/bundlers/distro tools to deal with making sure the shared libraries are both installed and correctly linked to. What "just works" is often relative and the magic is very easily dispelled in that terrible state of "why isn't this working?", especially if it "just works" like magic for other people. That's only if you're working with C / C++ though. Switch to Go, Java or basically nearly any other language, and most of your cross platform headaches go away. Though for what it's worth, half those problems aren't really problems you'd generally have to get your hands dirty with as your tooling and distro should manage that for you (just so long as you write POSIX code that is). I'll grant you I've not done anything too complex in C++ but what I have done was portable between Linux, Solaris and FreeBSD (the 3 systems I needed those POSIX C++ programs to target). That was compiling on those respective platforms rather than compiling for those platforms then packaging them up for deployment. I've written a lot of code over the last 30 years and shipped it in a plethora of different ways and creating installers has historically definitely been easier on Windows. No question. Go lang is helping somewhat in that it's now really easy to ship a dependency free binary. But Windows is only one platform and one that creates more problems for cross-platform portability than all of the rest of the big platforms put together.
- qwerty456127 9y ago> For instance, Windows binary deployments are quite predictable (and often dead simple... It's neither predictable, nor simple nor easily portable when it's about a mixture of managed (C#, Java etc.) and native (C, C++, asm etc) code. I'm happy to know the Windows UWP platform finally has it built-in but I code WinForms and console apps targeting Windows 7 + Mac and Linux with Mono and using SQLite always means a problem (yet I always want to use SQLite to store anything (except just some things that obviously fit other ways of storage better) because it's great and it's a standard supported everywhere).
- edwinyzh 9y agoI'm not sure if it's related to the .Net framework, but definitely it's NOT related to the Windows platform. I've been using SQLite on Windows (with Delphi) for nearly a decade, while there were issues (solvable), but one is related to deployment, seriously.
- masklinn 9y ago… Are you saying that there's no actually working .net sqlite bindings? Because when using python, featuring an sqlite database is roughly: import sqlite3 with sqlite3.connect(db_file) as cnx: # query the db
- gandreani 9y agoI think the parent means native implementations so that these bindings are not necessary. The bindings are an interface to a C library that should be shipped with the device. I can see how that can be problematic if you're targeting OS X, Windows, and Unix systems
- masklinn 9y agoThe OP is saying problems exist before even deployment concerns: > even if it actually starts working nobody really knows how to deploy such an app on another computer (especially if it runs a different kind of OS) correctly. emphasis mine. (and portability could obviously be solved the same way it was in Python: ship sqlite as part of the core system)
- marcosdumay 9y ago> The bindings are an interface to a C library that should be shipped with the device. There is nothing stopping you from statically linking it with the rest of your code.
- weberc2 9y agoNot all languages are compiled.
- paulddraper 9y agoIf your language has no possibility of ffi, that's kinda an issue on that language. Good luck using portable libraries.
- jug 9y agoI think it has been ported to .NET but unsure about maintenance: https://www.infoq.com/news/2009/08/SQLite-Has-Been-Ported-to-.NET https://www.infoq.com/news/2009/08/SQLite-Has-Been-Ported-to...
- deleted 9y ago[deleted]
- JoachimSchipper 9y agoYou really don't want to re-implement SQLite for every high-level language! Also, isn't SQLite just supported out-of-the-box by new .Net versions? E.g. https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite https://docs.microsoft.com/en-us/ef/core/get-started/netcore....
- rootw0rm 9y agoI've worked fairly extensively with SQLite in C and .Net bindings. I prefer C, but you can do nearly everything at basically full speed with the various interfaces. The only thing off the top of my head that didn't work properly recently was saving in-memory DBs to disk using bindings. I had to use C for that.
- sametmax 9y agoI don't understand how you get in that situation. Python has shipped SQLite for years and it works the same on every single plateforms.
- grandinj 9y agoIf you're using Java, use H2 (h2database.com) Edit: full disclosure, I am a maintainer :-)