Main Menu

Which C('s) should I teach myself?

Started by Lotos, April 06, 2010, 07:44:17 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Lotos

C, C#, and/or C++?

I'm not liking Java too much, mainly because its GUI doesn't conform with the other languages, the little icon popping up for applets, and that I can't work with it at home as it keeps saying stuff like "error in main" or it can't find the runtime.  Still, remember that I have a little bit of Java knowledge and my two main OSes are Windows 7 and Ubuntu (might be XP soon if my father gives me the newer old computer) when suggesting.

Anyway, I heard that you should learn C if you're going into Computer Science.  I heard that you can get C and C++ confused with each other.  I know that C can be used with Lua, which I would like to learn.  I also heard that C# is similar to Java and can be used to make XBL and PC games.

Care to help me?

bluaki

#1
C is amazing. The core of modern programming languages. Learn it first.

C++ is also good. For the most part, C and C++ are directly forward-compatible, and C++ adds object-oriented concepts that C originally lacked (but unlike Java, not everything has to be in a class and you can altogether ignore OOP). Object-oriented programming is apparently somewhat useful for GUI applications and games and there are more C++ libraries than C libraries out there for such tasks.

I don't know anything about C#, but it doesn't look too interesting to me. C++ seems to have all necessary features of OOP and most C# code is for Microsoft .NET or similar stuff.

What do you mean the GUI of Java doesn't conform with the other languages? Are you referring to Swing? I haven't tried messing with any GUI libraries yet with C, but I hear GTK+ is good for it and Qt is good for C++. As for compilers, stick with either GCC in Linux (it's included in all installations) or MinGW (a port of GCC) for Windows. I personally don't use an IDE and just compile via command-line.

I'm, personally, still learning basic C. Haven't tried using very much of the standard libraries nor any type of import library and I haven't done anything in terms of advanced data structures and advanced pointer sequences. Though, out of what I've learned about Java from AP Computer Science, things I can make in C currently include anything I'm able to make in Java and more. I haven't even attempted to start messing with C++

Lotos

#2
Quote from: bluaki on April 06, 2010, 07:49:26 PM
What do you mean the GUI of Java doesn't conform with the other languages? Are you referring to Swing?

It doesn't look like it is a standalone program in my opinion.  Take a look at Tile Molester's GUI.  That's what I mean.  Never mind.  It looks more normal.  The outer window had the metallic look too which I disliked.

Edit:  Damn ADD.  I forgot to mention that swing makes me want to KILL people.  It's too confusing and I can't figure out how to combine stuff.  We had to learn by examples we found on the web.  I hope he didn't teach the normal class this, because I must have missed it.  The AP class read something on it I think though.

Quote
Though, out of what I've learned about Java from AP Computer Science, things I can make in C currently include anything I'm able to make in Java and more.

But you're a genius as far as I know.  How long should it take me to learn (weeks, months?)?

Silverhawk79

C++ is the easiest to learn, or so I've heard. It's also the most widely used out of them all.

bluaki

#4
Quote from: Lotos on April 06, 2010, 08:20:04 PM
But you're a genius as far as I know.  How long should it take me to learn (weeks, months?)?
I don't have any "normal programmer" familiarity outside of my AP Computer Science classmates. Who can't figure out on their own how to properly use conditionals and loops, let alone separate methods/functions, to make a program that does simple tasks like generating a list of prime numbers within a range.
And those people are taking this long to learn those simple concepts which apply to any programming.

If you can figure out stuff like that well, it shouldn't take more than a couple weeks. From what I know so far in C, you can compare it to previous knowledge of Java and say that, in comparison to Java, C has, most basically:

  • Removed OOP features; no "public class X" needed around the entire program. The main function is "int main()" without modifier words like "public static" needed.
  • Very strong focus on pointers and arrays. Beyond Java's capability of only handling Object pointers, C programming often involves (slight exaggeration) creating something like a pointer to an array of pointers that are each pointing to an array of ints. Even strings are treated as an array of characters.
  • Strings are treated differently, with no feature of the language itself providing support of directly concatenating two strings (which can be achieved using loops with array manipulation) or other data types to a string. Generally, for converting numbers to a string, formatting functions are used which define things like zero-padding. Strings are, again, character arrays
  • With the lack of OOP features, there's nothing like Array.length that tells you an array length. If you let the program do so, it'll access memory completely out of your program when referencing an array index beyond the actual array. Arrays in which length is important either rely on separate variables or add an extra "blank" element to the end of the array which defines the end. Strings, for example, end with a 0 (which is well below any ASCII index) that can also be represented as '\0'
  • Different (and smaller) standard library of functions, which are included with "#include <header.h>" instead of "import java.category.header;"
  • That includes different simple input/output functions. printf() is heavily used to either print a simple string (ending in \n for newline instead of using a different function) or to print formatted output with syntax that converts ints and other data to a string. In my opinion, the best console input function to use is getchar(), which pauses the program until somebody types something in the console and then returns the first character of the input and then can be repeatedly called until reading the end of the input all the way up to the '\n' from pressing enter. I think that makes more sense than dealing with Scanners and input streams in Java.


Side note: this is my first post on my new IP address. I miss 72.77.233.6 ;___;

PsychoYoshi

#5
Quote from: Silverhawk79 on April 06, 2010, 08:52:13 PM
C++ is the easiest to learn, or so I've heard. It's also the most widely used out of them all.

Uh, no. C++ and C# are both object-oriented languages, so you need to dick around with classes and other poop (even though it's not nearly as bad as Java), therefore they're harder to learn than C. As my father explains it, when you program in C, you're creating verbs for the computer to use. When you program in C# or C++, you're creating nouns.

C# is more limited than C++ is, but it has a few safeguards built-in that prevent you from intercourse ing up and causing as many errors as you might potentially cause with ++. It's used in embedded a lot, but it's not nearly as prevalent as C++ is, as Blu said.