Thread: Java or C#: which has higher compatibility?

  1. #1
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80

    Java or C#: which has higher compatibility?

    Hello,

    I'm working on an application that does some SQL work by interacting with an Access database (i.e. will need ODBC/JDBC) with some GUI. I'm wondering whether I'm better off writing it in C# or Java. I want a non-techy user to be able to run the application on a typical Windows machine with as few requirements as possible (e.g. would Java require JVM? would C# require .NET framework? which one do most people have already?). To be honest I'm not very familiar with all the low level details of these languages.

    Thanks.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    It doesn't work that way. It will depend on you, the programmer, the ability to develop your application so a "non-techy" user can work with it without any aggravations.

    That said, the .net framework is an almost guarantee on every windows computer these days. Vista and above ship with it and most XP users almost certainly have it installed already. But what about you? Do you want to learn C# or VB.Net? Do you prefer Java? Well, if its just to connect to a Access Database you can even do it in good old Visual Basic 6.0 or even in your Office suite, using VBA.

    It all depends on how much effort are you willing to put into it and what are your goals concerning this project. You may just want to get it done and over with as fast as possible (Visual Basic, VBA), or you may want to grab the chance and learn a new programming language gaining a future for yourself (Java, C#, VB.Net and of course C or C++)
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80
    First, thank you. To be honest with you I didn't learn programming the usual way (I learned it the wrong way in fact). I know how to write code in both languages but there are many things that I don't know about yet -even some very primitive ones. My goal for this project is for a non-techy user to be able to run my application on a Windows machine.

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    I had to write a database java app once, hated it*. Not sure how C# is in this regard.



    *: Just to be clear: I hated writing the database stuff, not the java stuff. Lack of multiline string literal is horrible for writing database queries.

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    I use both ADO.NET & JDBC (and dont dislike either) and if I were targeting an Access database I'd go for C#. Reason being? To use Access on the Java platform I'd probably have to end up using ODBC (and I hate doing that) as most of the JDBC drivers for Access are third party and most of them cost money to use. With C# and ADO.NET you'll easily get access to Access (excuse pun) with loads of examples on the web.


    >>*: Just to be clear: I hated writing the database stuff, not the java stuff. Lack of multiline string literal is horrible for writing database queries.

    Agreed. That's why I end up trying to use IBatis when doing java database stuff.

    I'm actually messing with some simple code at the moment to read from an Access database and I'm doing it in Python - wow, how simple! You have multiline literals and with the win32com stuff you can use ADO to get the data and stuff it into an xml doc in a few lines of code.

    Sometimes I like Python too much

  6. #6
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Thantos View Post
    Lack of multiline string literal is horrible for writing database queries.
    Why? This is just as clear as a multiline string literal:
    Code:
    String query = "SELECT * FROM foo " +
                   "WHERE foo.bar = 5";
    Last edited by cpjust; 07-20-2009 at 10:36 AM.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    It's annoying because of the excessive use of quotes and concatenation. Some queries can run several lines and be subject to a large number of changes during the development process. Not to mention those cases where the DDL is meant to go inside the code. There's just too much of a need for copy-pasting and proper formatting which translates in a higher number of editing screw ups and too much time spent working not on the query, but on the language syntax.

    Wasn't aware of the JDBC issues however. Did a very fast casual search on google and can see the problem alright. But certainly there ought to be free stuff around.
    Last edited by Mario F.; 07-20-2009 at 06:59 AM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Nothing's stopping you from using a pre-processor

  9. #9
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by cpjust View Post
    Why? This is just as clear as a multiline string literal:
    Code:
    String query = "SELECT * FROM foo" +
                   "WHERE foo.bar = 5";
    And you just caused a SQL syntax error.

  10. #10
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by Thantos View Post
    And you just caused a SQL syntax error.
    You mean the missing space? OK, I fixed it.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  11. #11
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Yep, and that is why I hate doing it without multiline literals. Way too easy to make those mistakes. Not too concerned with the concat operations as it is possible that the compiler can see you are concating two literals and change it into one (not sure if that is done or not though).

    I just hate the ease of causing those kind of SQL syntax errors.

  12. #12
    Registered User
    Join Date
    Nov 2005
    Location
    Canada
    Posts
    80
    Very helpful thread indeed. Thanks for sharing your experiences.

  13. #13
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Yep, and that is why I hate doing it without multiline literals. Way too easy to make those mistakes.
    The error he made would happen just as easy with a multiline literal. If you are doing it either way, you are doing it the wrong way.

    This is much easier:
    Code:
    String sql = String.format("SELECT * FROM foo WHERE foo.bar = %d", 5);
    Of course most people would argue that if you are building a SQL string in code, you have already lost the battle.

  14. #14
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by bithub
    The error he made would happen just as easy with a multiline literal.
    I think that depends on what exactly is meant by a multiline string literal. For example, this would surely result in the necessary whitespace:
    Code:
    String query = "SELECT * FROM foo
                    WHERE foo.bar = 5";
    Quote Originally Posted by bithub
    This is much easier:
    In what way? The problem remains when you want to format the SQL statement over multiple lines.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #15
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    In what way? The problem remains when you want to format the SQL statement over multiple lines.
    Usually when SQL is formatted this way, the format string will fit on one line, and then you place the variables on the following lines. This removes the need to split up the SQL string at all. Of course if you have a monstrosity of a SQL statement, it still may take multiple lines. In that case though, why in the world are you not using stored procedures instead?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  2. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  3. The Java language is being expanded
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 06-11-2004, 09:07 PM
  4. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 12:37 AM
  5. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 04:12 PM