Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I read the stuff below on a tutorial someone in a previous post pointed me to. C is that crazy eh!? I had no idea! What about C++ and Java?
It seems Java can do ANYTHING and EVERYTHING when it comes to computers...any computer concept seems to have a parallel in Java. Where does it come into play?
The stuff below makes it seem I should really learn C...what about Java and C++ and other programming languages? Can somebody please comment on Java and C++ specifically? Can I program anything in C that I could in C++ and Java? Is there anything one of these 3 languages can do that another cannot?
Is there any functional reason I should learn more than one of the 3? (i.e. not a reason like "it's obviously better for completeness", but a reason that indicates that one cannot create an application that the others can?)
Thanks!
Quote:
C was invented for the purpose of writing an operating system that could be recompiled (ported) to different hardware platforms (different CPUs). Because the operating system is written in C, this language is the first choice for writing any kind of application that has to communicate efficiently with the operating system.
Many people who don't program in C very well think of C as an arbitrary language out of many. This point should be made at once: C is the fundamental basis of all computing in the world today. UNIX, Microsoft Windows, office suites, web browsers and device drivers are all written in C. Ninety-nine percent of your time spent at a computer is probably spent using an application written in C. About 70% of all ``open source'' software is written in C and the remaining 30% are written in languages whose compilers or interpreters are written in C. [C++ is also quite popular. It is, however, not as fundamental to computing, although it is more suitable in many situations.]
Further, there is no replacement for C. Since it fulfills its purpose almost flawlessly, there will never be a need to replace it. Other languages may fulfill other purposes, but C fulfills its purpose most adequately. For instance, all future operating systems will probably be written in C for a long time to come.
It is for these reasons that your knowledge of UNIX will never be complete until you can program in C. On the other hand, just because you can program in C does not mean that you should. Good C programming is a fine art which many veteran C programmers never manage to master, even after many years. It is essential to join a Free software project to properly master an effective style of C development.
i'm too tired to read all that stuff but higher level object oriented structures like are present in c++
are inapropriate for low level say kernel level programming.
and java ?? well java needs an interpreter and so is slow and unusable generally
java works good as a server back end or something i guess like where you would ordinarily use a scripting language.
programming languages are tools in a tool box
Quote:
Is there any functional reason I should learn more than one of the 3
it's hard to nail the boards in place if you first don't learn how to use the saw.
i mean really you never really "learn" a language anyway
they change so often and a new one comes along or get's new features
it's more like learning the underlying theories
my first functional (i thought) program was written in fortran on punch cards for an old ibm mainframe
don't get stuck in one spot -- just let it evolve
the greatest danger of any journey is thinking you are "there"
Learn a language as the fancy or need takes you. Java isn't necessarily slow in the usability sense, but it would be unsuitable for device drivers and the like because it has the overhead of needing the virtual machine running to interpret the compiled bytecode. But on the other hand, java apps can run on any system that has a VM without recompiling. It also has libraries for building GUI's as standard, whereas with C or C++ you'd need to choose a GUI toolkit to use. Interestingly, while most apps are written in C, KDE is written in C++ because the Qt toolkit is C++ based.
Re: WOW, "C" is that crazy!? What about Java and C++?
Quote:
Originally posted by veeruk101
The stuff below makes it seem I should really learn C...what about Java and C++ and other programming languages? Can somebody please comment on Java and C++ specifically? Can I program anything in C that I could in C++ and Java? Is there anything one of these 3 languages can do that another cannot?
Anything you can do in C you can do in Java or C++ and vice versa. All of those languages are Turing Complete, meaning that you can do anything you could think of with them.
Like the people above said, it's probably better to set out to learn to program than to learn to program C, after playing about for a while you will find the language that you prefer. I like Java myself, but am not adverse to a bit of C, or C++
Anything you can do in C you can do in Java or C++ and vice versa. All of those languages are Turing Complete, meaning that you can do anything you could think of with them.
There is one exception to this I know of. In C you know exactly when all your code is going to run (as you clearly write it all out). In C++ it is similar, the destructors for objects are never called by you but they have a clearly defined location and time at which they will be run when an instance of an object is no longer referenced. So, both of these languages are functionally the same. Java, on the other hand, makes no guarantees about when it will run your destructor. It could run it right after the last instance, at the end of a code block, at the end of a function, or even later if it "feels" like it.
Okay, for all "practical" purposes this should never be an issue for the average programmer. Real languages shouldn't have to do their own memory management (but that is another story anyway). The problem comes only when you have committed yourself to a project only to find a point in time where you absolutely need to know when that destructor will run and be sure it does only at that time, exactly at that time, and every single time for every single run. It is a sour and vicious bite when it is dealt to you... be forewarned.
Aside from that, they are all basically the same when it comes to functionality (C and C++ allow you to get closer to the hardware, as well, but good code should never rely on a defined understanding of the hardware unless it is not meant to be portable).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.