C or Java?
Author |
Message |
[Gandalf]
|
Posted: Sun Jan 16, 2005 7:24 pm Post subject: C or Java? |
|
|
Which should I learn, C or Java? I already know Turing quite a bit.
I want to learn C, and I think I could learn it quicker - but I will probably have to learn Java in school in a few years... Many people say that both are pretty similar, so that if I know C then I can learn Java easily. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
bugzpodder
|
Posted: Sun Jan 16, 2005 7:49 pm Post subject: (No subject) |
|
|
depends on your motives. if you are learning for your own satisfaction, then learning what doesnt matter (you may perfer C++ over C). |
|
|
|
|
|
Martin
|
Posted: Sun Jan 16, 2005 8:19 pm Post subject: (No subject) |
|
|
Yes. The first langauge is always the hardest, unless you later choose to learn BF.
In any case, I'd go with C++ instead of C if you want to learn something along those lines. All three are good languages that you can have some fun with. |
|
|
|
|
|
wtd
|
Posted: Sun Jan 16, 2005 8:26 pm Post subject: (No subject) |
|
|
martin wrote: Yes. The first langauge is always the hardest, unless you later choose to learn BF.
In any case, I'd go with C++ instead of C if you want to learn something along those lines. All three are good languages that you can have some fun with.
If you choose to go in this direction, do go with C++, and use a decent compiler (GCC 3.x, preferably).
The original question: Java is a far better language to go with than C. It does more for you.
All of this said, don't learn any of these. In any of them there's too much overhead. You spend too much time worrying about babysitting the language and compiler rather than solving problems. |
|
|
|
|
|
rizzix
|
Posted: Sun Jan 16, 2005 9:08 pm Post subject: (No subject) |
|
|
Java is the most productive lanuage.. it has the largest standard library.. and a vast collection of third party libraries (most of which are opensource).
now c has a tiny standard library.. although it does sport quite a competing set of third party libraries.. but those libraries are not always all so easy to use.. not all of them are documented properly if ever documented... and most of the libararies do not follow a standard c programming convention.
the same goes with c++.. actually there's not much 3d party libraries available for c++.. but since c++ is the superset of c... all C libraries work under c++.
now depending on what u want to do: being productive or doing something specific such as 3d games etc.. you would have to decide what language u are going to use. eventually you will learn them all (well at least those 3), cuz they are so popular. |
|
|
|
|
|
wtd
|
Posted: Sun Jan 16, 2005 9:25 pm Post subject: (No subject) |
|
|
rizzix wrote: Java is the most productive lanuage.. it has the largest standard library.. and a vast collection of third party libraries (most of which are opensource).
Of the three, perhaps, but Java is filled with warts. The standard library is immense, but still makes basic operations, such as operations on collections of objects, more cumbersome than they need be.
C++ beats out Java in this regard, due to the Standard Template Library.
I really think that beginners need to use a language which encourages them to do things in a high-level manner. C++is the best in this regard, but still makes experimentation far too cumbersome.
Higher level languages include:
- Ruby
- Python
- Perl
- Haskell
- O'Caml
- Scheme
|
|
|
|
|
|
rizzix
|
Posted: Sun Jan 16, 2005 9:30 pm Post subject: (No subject) |
|
|
wtd wrote: rizzix wrote: Java is the most productive lanuage.. it has the largest standard library.. and a vast collection of third party libraries (most of which are opensource).
Of the three, perhaps, but Java is filled with warts.
hmm warts? elaborate?
Quote: The standard library is immense, but still makes basic operations, such as operations on collections of objects, more cumbersome than they need be.
C++ beats out Java in this regard, due to the Standard Template Library.
I really think that beginners need to use a language which encourages them to do things in a high-level manner. C++is the best in this regard, but still makes experimentation far too cumbersome.
I agree. it's easier to write a hello world app in c/cpp than in java. cuz of the number of questions you might have to answer. and it gets the student all confused. although i was introduced to the oop world directly through java. |
|
|
|
|
|
[Gandalf]
|
Posted: Sun Jan 16, 2005 9:52 pm Post subject: (No subject) |
|
|
C++ is probably too hard... I like a language in which the commands have something to do with what the outputs. Like in Turing "put" puts something and "PRINT" in BASIC basically prints something to the screen.
I would like to learn C over Java since I have heard that there are many different versions of Java, like the holt one, pure Java, and possibly some others. I am not sure, it might just come down to what I think I can learn best. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
wtd
|
Posted: Sun Jan 16, 2005 11:15 pm Post subject: (No subject) |
|
|
rizzix wrote: wtd wrote: rizzix wrote: Java is the most productive lanuage.. it has the largest standard library.. and a vast collection of third party libraries (most of which are opensource).
Of the three, perhaps, but Java is filled with warts.
hmm warts? elaborate?
The differentiation between primitive types and object types is a big problem, especially when it comes to how collections are implemented. Since collections can only contain descendants of object types, you end up with all kinds of boxing and unboxing garbage.
Also, the lack of multiple implementation inheritance leaves programmers with a lot of Frankensteinian abstraction and duplication of code.
Consider something like your basic output. In Java, where we only have single implementation inheritance, we can't inherit from some class which provides things like a standard output handle, because we might need to inherit from another class instead, so we have to get it as a static member of the System class.
Now, that's in contrast to how we could do this in a language with proper multiple implementation inheritance, like Eiffel. Here, we can inherit from multiple classes, and one provides "std_output".
But we're talking about C++, so let's look at an example of that.
code: | #include <iostream>
#include <vector>
#include <string>
class student_name
{
private:
std::string first_name, last_name;
public:
student_name(std::string f, std::string l)
: first_name(f), last_name(l) { }
std::string get_first_name() const
{
return first_name;
}
std::string get_last_name() const
{
return last_name;
}
};
class grade_collection : private std::vector<int>
{
public:
grade_collection() : std::vector<int>() { }
void add_grade(int grade)
{
push_back(grade);
}
int number_of_grades() const
{
return size();
}
int get_grade(int index) const
{
return at(index);
}
int sum_of_grades() const
{
int sum = 0;
for (int i = 0; i < number_of_grades(); i++)
{
sum += get_grade(i);
}
return sum;
}
int average_grade() const
{
return sum_of_grades() / number_of_grades();
}
};
class student : public student_name, public grade_collection
{
public:
student(std::string f, std::string l)
: student_name(f, l), grade_collection() { }
};
int main()
{
student bob("Bob", "Smith");
bob.add_grade(96);
bob.add_grade(98);
std::cout << bob.average_grade() << std::endl;
return 0;
} |
How would you implement something so simply in Java?
rizzix wrote: Quote: The standard library is immense, but still makes basic operations, such as operations on collections of objects, more cumbersome than they need be.
C++ beats out Java in this regard, due to the Standard Template Library.
I really think that beginners need to use a language which encourages them to do things in a high-level manner. C++is the best in this regard, but still makes experimentation far too cumbersome.
I agree. it's easier to write a hello world app in c/cpp than in java. cuz of the number of questions you might have to answer. and it gets the student all confused. although i was introduced to the oop world directly through java.
I learned OOP in Python. Ruby made me appreciate having learned it. |
|
|
|
|
|
[Gandalf]
|
Posted: Mon Jan 17, 2005 12:18 am Post subject: (No subject) |
|
|
Woah! I just read - in this big book of java which I have , that C is not an object-oriented language... Is this true? that surprised me... |
|
|
|
|
|
wtd
|
Posted: Mon Jan 17, 2005 12:57 am Post subject: (No subject) |
|
|
[Gandalf] wrote: Woah! I just read - in this big book of java which I have , that C is not an object-oriented language... Is this true? that surprised me...
C is not. C is a very limited language. It's possible to do... well... anything in C, but the language doesn't give you any help.
C++, on the other hand, is a completely different language, and does support object-oriented programming, as well as generic programming. |
|
|
|
|
|
|
|