• Forum
  • Lounge
  • Is Java a good language to learn Besides

 
Is Java a good language to learn Besides C++ ??

Pages: 123... 5
Hello all , I've been learning C++ for 3 months till now and I was thinking about learning another language besides C++ !! I am thinking about Java because its technology allows its programs to run on almost all platforms :):)
So tell me Ur Opinions , thoughts :)

CMinus ,
A Boy who loves computers .
Well, you can learn Java, but it's really so similar to C++ that it will hardly be a revelation. I find it somewhat easier to "think" object-oriented in Java, and it has some runtime features that C++ doesn't have, but lacks other things I like in C++ (templates for instance are just syntactic sugar in Java, and not nearly as powerful as in C++, and the lack of operator overloading can be quite annoying sometimes because something like matrix1.mult(matrix2.mult(matrix3))) just looks silly).

If you want to learn something for fun, try a functional language.
Last edited on
If you like C++, you'll hate Java. All variables are passed by value to methods and there are many immutable types in Java that would be much more convenient in Mutable form. There are loads more things I hate about it but I won't go into details.

I recommend learning it. Its disgusting essence is being used more and more frequently.
Last edited on
If you like C++, you'll hate Java. All variables are passed by value to methods and there are many immutable types in Java that would be much more convenient in Mutable form.


Actually, all non-primitive types are passed by reference in Java, and the only type whose immutability can be annoying sometimesis String, but that's because a String is not a char array in Java.
Java would be good to learn, seeing as Android apps are primarily built on java, and the programming market is moving to the mobile domain.
hanst99 wrote:
Actually, all non-primitive types are passed by reference in Java
False:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
public class ReferenceTest
{
    public static void main(String[] args)
    {
        ReferenceTest t = new ReferenceTest(1);
        DoStuff(t);
        t.print();
    }
    public static void DoStuff(ReferenceTest rt)
    {
        rt = new ReferenceTest(2);
    }

    int value;
    public ReferenceTest(int v){ value = v; }
    public void print(){ System.out.println(value); }
}
1
References are passed by value :p
Last edited on
> Well, you can learn Java, but it's really so similar to C++ that it will hardly be a revelation.

> If you want to learn something for fun, try a functional language.

+1

Learning a functional language is more than just fun. It is also a way of discovering many new programming techniques; techniques that programmers who have programmed only in the C based languages tend to miss out on.
That's still pass by reference, you are just having wrong expectations regarding the assignment.
The ReferenceTest object is not passed, the reference to it is passed, and that reference is passed by value.

In C++:
1
2
void DoStuff(ReferenceTest *rt) //passed by value
void DoStuff(ReferenceTest *&rt) //passed by reference 
Last edited on
That's only if you're thinking C++ when dealing with Java.
@CMinus, Java is a fine languages, but I suggest sticking with C++ a bit more. I don't think there is any good in switching languages every few months, especially if you are new to programming in general.
@hanst99 nope. Consider this seemingly-intuitive code:
1
2
3
4
5
6
7
public static void DoStuff(Integer i)
{
    i++;
    i *= 3;
    --i;
    i /= 2;
}
1
2
3
Integer i = 1;
DoStuff(i);
System.out.println(i);
What does it print? Did you say 2? It prints 1.

I see this stuff far too often from my classmates, and it's even on the exam.
Last edited on
and the programming market is moving seeing some expansion in the mobile domain.


Which means its only a matter of time until someone gets around to a decent C and C++ compiler for these platforms. :)


If you want another language, learn something that will complement what you already have. Something different, in which you won't still be thinking in C++ and writing it in different notation, but something that actually makes you think about problem solving in a whole new way. How about a functional programming language?
Last edited on
What does it print? Did you say 2? It prints 1.


No surprises there. The Integer type is immutable.
What if you print i at the end of DoStuff? I guarantee it will print 2.

Yes it is immutable, and thus a new one has to be made for each autounbox and autobox operation, so the fact that i is passed by value makes it impossible to have the intended result of changing the value of i outside the function.

Now I have a question: Why in the world are the wrapper classes immutable? It's very annoying...
If they were mutable, they'd exhibit different behavior from primitive types. Primitive types are mutable, but only by assignment, so if you'd get the output 2 then Integer would behave differently from the type it's supposed to wrap, which would be a bug.
Last edited on
Ah, that makes sense. Well I've hijacked this thread long enough.

learn haskell
Last edited on
closed account (3hM2Nwbp)
@OP - Java's a good language, but the crowd that uses it will likely lynch you if you go against any of the standard conventions.

Code like:
1
2
3
4
5
6
7
class X // Notice the scope start is not on the same line
{
    public static void main(String[] notNamedArgs)
    {

    }
}


will probably get you either A) ridiculed by or B) assassinated by Java zealots. At least from my experiences with working with Javanoids.
Last edited on
I can't stand having multiline code unless the braces are on their own lines o_o Java zealots are crazies...
Well Guys I think I will stick to C++ until I understand The OOP Programming concepts well & master the syntax :)
Maybe after 3 or 4 Months I will try to learn Functional Language like Lisp Or Haskell Or maybe I will play a little with Web Development :)

Now I have to look after my annoying study (I hate the subjects I take WTF!!).

CMinus

A Boy who loves computers .
Last edited on
Pages: 123... 5