4

I am going to develop a software that works with different databases and I'm considering whether to use .NET languages or C++. I've known that .NET features LINQ and ADO.NET but are there features like that in the native C++? Which one works better, faster with databases?

6
  • 1
    What about SQL and various DB bindings to any language?
    – Basilevs
    May 19, 2014 at 1:49
  • So I can typically send SQL commands as string in any language?
    – brillydev
    May 19, 2014 at 1:59
  • Yes, you have special libraries for most combinations of language and SQL-based database engine.
    – Basilevs
    May 19, 2014 at 2:01
  • As for performance, the lower level a language is, the faster it will be. So C++ wins because it is lower level. As for which is "better" in general, the answer is neither--it depends on your specific requirements.
    – jordan
    May 19, 2014 at 2:01
  • 6
    @jordan -- as most database intensive programs will spend there time executing SQL etc. any speedup gained using C++ will be barely noticeable. So a higher level language which speeds up development would be a better option. May 19, 2014 at 2:11

1 Answer 1

7

There's no clear-cut answer to your question - it depends on what sort of work you plan to do and the requirements of any particular project - you need "the right tool for the right job". Also, your question as stated isn't entirely valid, because C++ is clearly designated as a systems language - not really designed for developing forward facing applications - but the .NET languages are part of a framework that spans pretty much every aspect of modern software development and focuses on the development of applications for "consumers". (LINQ is a language feature of C# and isn't part of C++, although using the STL you can do some similar things, with work...) Having said that, here's an overview of how things break down:

When you use .NET languages with VStudio, the database stuff is pretty much there "right out of the box" - it's all set up for you - you can do it all with very little code using wizards and template projects, etc, if that's what you want. Or you can code by hand using the framework's classes for database handling, or combine the approaches, depending on your ability, taste and requirements. And of course it's integrated with ADO, ADO.Net (part of the framework itself), etc - so you can connect quite easily to just about any DBMS out there. (Sometimes you'll have to pay some good money for top quality ADO/ADO.net provider packages from third parties.)

But there is a price to pay with .NET, in terms of performance (your mileage may vary, depending on what you're doing with it), in terms of your wallet, and in terms of being locked into a proprietary framework, which MS has a nasty habit of breaking and complicating from time to time... etc - essentially part of their business model... You're also pretty much locked into the Windows platform with .NET. Although Mono and MonoDevelop (as well as some other IDE's) are open source and are available for Linux, IMO they are not really on a par with the MS tool-chain, and it can get a bit nasty keeping track of .NET versions and compatibility, and staying in sync, etc.

In native C++ it's a very different story. "Out of the box" C++ has no database support - since it's a systems language, it's not part of the standard. Doing it all by hand is generally not an option - you could spend the rest of your career just developing a solid framework for accessing various databases. Even if you only need one database, it is still challenging.

So, when working with databases in C++, you generally need to work with frameworks that have been designed for/with database support. QtSql for example, is quite popular as is libdbi (google will lead you to others) or at least download or buy drivers for various databases and learn how to wire them up. Again, not always so easy, but quite doable if you're comfortable with C++.

The upside of using C++ is that's free, there are great tools for developing with it that are also free, performance will, as a rule, be superior to .NET, your code will be more or less cross platform, and you'll be working with what is arguably the most important language in modern computing. (Not trying to start any language wars here - I know there are other candidates...)

Another important consideration is your frontEnd: Again, with .NET, it can all be done "out of the box" - you've got all sorts of controls that are easy to wire up to your database input and output. In C++, frontEnds are also not part of the standard, since it's a systems language, as explained. So you'll have to use another framework for your frontEnd and "hand wire" things. The QT platform does provide an "end to end" solution in native C++, but it's still a lot more work than using the MS tools, and it does have its down-sides, although it is very popular and is widely used on Linux. For example, KDE a very important and popular GUI toolkit for Linux, is QT based.

So - it's your call: If you need quick and easy solutions for Windows only, IMO go for .NET. If you need open source/cross platform, super high performance solutions and are ready to roll up your sleeves, C++ is what you want. But in that case, other languages, such as Java and Python, might also be candidates for you to investigate, depending on your needs and taste. They are easier to work with than C++ if you're new to this sort of thing.

Not the answer you're looking for? Browse other questions tagged or ask your own question.