Thread: C or Java ? Pleas help meee ...

  1. #31
    Registered User
    Join Date
    Dec 2007
    Posts
    25
    I don't know that, that is why I ask in this topic.
    C/C++ which one efficient, fast and with more possibilities...

  2. #32
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Java can never beat C/C++ in raw speed. I can tell you that. If you want to do speed critical things like emulators - then C/C++ is the only way.
    For Web, Java is obviously faster (faster to develop WITH).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #33
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Actually, since Java passes all objects by reference and therefore doesn't make a lot of copies, I believe there are some cases in which Java could be faster than C/C++ (unless the C/C++ code is written very carefully).
    I just hate Java's lack of type safety though (i.e. no const keyword...)

  4. #34
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Quote Originally Posted by bchaib View Post
    T

    What does that mean, "I don't have to worry about memory management" and why not in Java ?

    Can you pleans give me an example and tell me which libraries you are talking about ?
    In Java you have for example imports java.sql.*; don't you have this in C ?
    In C you have to explicitly "ask" (or allocate) memory, and "free" (or deallocate) memory. If you mess this up your program can have a memory leak, which causes it to keep using more and more ram.

    In Java, there is a built in component called the Garbage collector. All allocation and deallocation is handled for you.

    As for the libraries, there are no standard libraries like java.sql.*. There are many third party libraries, but its your job to dig through them and figure out which one is best for your needs (in the case of DBMS access, ODB will be your friend with C). Once you've done that, there are no standard conventions about how the library is used or even the coding conventions. So you can end up with function_calls_like_this() for one lib, andOthersLikeThis() for anther, xyzSAN_andSomeLikeThis().... etc... It makes your code awkard to read and write.

  5. #35
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by cpjust View Post
    Actually, since Java passes all objects by reference and therefore doesn't make a lot of copies, I believe there are some cases in which Java could be faster than C/C++ (unless the C/C++ code is written very carefully).
    I just hate Java's lack of type safety though (i.e. no const keyword...)
    Oh come on, speed isn't only from references. Speed is from fast libraries and not some crap garbage collector that sites in the background eating up CPU cycling through all memory you have and see if it's not being used anymore.
    C/C++ along with assembly, which it walks hand-in-hand with almost, will always be at the top of the speed chain.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #36
    Registered User
    Join Date
    Dec 2007
    Posts
    25
    since Java passes all objects by reference and therefore doesn't make a lot of copies
    Can you pleas give me an example? but in C we don't have objects !! or not ?

    Elysia,
    No, I don't want emulators => that's too technical ... I just want in the future to make programs processing data and save it to databases ..

  7. #37
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by bchaib View Post
    Can you pleas give me an example? but in C we don't have objects !! or not ?
    We have structs!

    Code:
    typedef struct
    {
    	int a, b, c;
    } mystruct;
    
    void foo(mystruct* p)
    {
    }
    
    void foo2(mystruct p)
    {
    }
    
    int main()
    {
    	mystruct astruct;
    	foo(&astruct); /* Pass as pointer or reference as some call it */
    	foo2(astruct); /* Copy the entire struct and pass it */
    	return 0;
    }
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #38
    Registered User
    Join Date
    Dec 2007
    Posts
    25
    @Perspective


    Thank you, .. do you do that ? you are programming on a very low layer if you operate the memory .. you can program virus with C

    I think it's a lot work to do this memory management!

  9. #39
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Well, it may be a slight problem, but then again, if you define strict rules for it, then it usually isn't that bad of a problem. It also gives you speed since you can explicitly control when to free the memory.
    In C++, you can build classes around memory handling (like Boost's smart pointers) to take away memory handling from your hands.

    C and C++ is a very low level language. You can directly manipulate memory and mess around with it if you want (I bet you can't do that in Java).
    But this also makes C/C++ very unsafe.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #40
    Registered User
    Join Date
    Dec 2007
    Posts
    25
    @Elysia

    Yes, I was reading today in a book about differences between C and Java and I read about pointers in C using stars but there is no pointer in Java.

    The Question is: no pointers in Java : does that mean Java is beter ?

    ps: I'm learling now the basics of C ...

  11. #41
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by bchaib View Post
    @Perspective


    Thank you, .. do you do that ? you are programming on a very low layer if you operate the memory .. you can program virus with C

    I think it's a lot work to do this memory management!
    Depending on how you "define" Virus, it may be possible to do so, but I think most actual code that distributes itself within the executable file of other files are written in assembler - mostly because they don't do anything really complex, so there's no point in using a higher level language. There are only a few people who ACTUALLY write this type of code - others take the code and tweak it.

    Memory management is something that needs to be done by someone somewhere. The original reason for C++ even being invented was that the Simula-67 language that Bjarne Stroustrup used before coming up with C++ has a "garbage collection" method of memory management, which was OK when the system was running small loads - but [in the implementation Bjarne was working with] when the amount of memory usage was high, the time spent in garbage collection was much higher than in the code actually running in the simulation. C and C++ lets the user decide when memory is freed - this increases freedom, but with freedom comes responsibility. As with most things, there's a positive and a negative side to almost everything.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  12. #42
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    The Question is: no pointers in Java : does that mean Java is beter ?

    ps: I'm learling now the basics of C ...
    Learn how to program, then talk about the pros and cons of language features (or "misfeatures", as the case may be). If you are new to programming and are currently learning the basics of C, a discussion on pointers with respect to C versus Java is beyond you since you do not know Java and barely know C.
    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

  13. #43
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by bchaib View Post
    @Elysia

    Yes, I was reading today in a book about differences between C and Java and I read about pointers in C using stars but there is no pointer in Java.

    The Question is: no pointers in Java : does that mean Java is beter ?

    ps: I'm learling now the basics of C ...
    That's bulls**t! Java has pointers -- they just like to call them "references". Although technically they aren't really pointers or references; they're a crappy combination of the two.

  14. #44
    Registered User
    Join Date
    Dec 2007
    Posts
    25
    @matsp

    Virus according to me is a program which destroys your files and data or make your computer working slowly ..
    Yes now I understand memory management and garbage collection .. in Java we don't have to do that because it is the job of JVM (Java Virtual Machine).

    But you can never make virus destorying the system time memory (BIOS)

    Source: Mr. Google.

  15. #45
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Note that even though a language may call it references there are no such things. In machine language, there are only pointers. So the code that's generated are pointers. Basically variables that holds a memory address to an object.
    So yes, both C and Java can do pointers.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C#, Java, C++
    By incognito in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 10-05-2004, 02:06 PM
  2. 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
  3. Java woes
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 07-06-2003, 12:37 AM
  4. How to use Java with C++
    By Arrow Mk 84 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2003, 04:12 PM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM