Click to See Complete Forum and Search --> : java convert
kmj
11-09-2000, 02:10 PM
I love java. In fact; if I had to choose between my first born son and java, I'd chose my first born son. But that doesn't mean that I don't love java; because I do. Even if you have to type 18 characters to do a simple cout. Also, it'd be cool if java supported prepocessor macros. does it? I think I'll write a java preprocessor. someday. http://www.linuxnewbie.org/ubb/smile.gif Hashtables rock. I mean they rock hard, like igneous even. Not that crumbly conglomerate crap. I'm talking bubbling out of the earth in superheated form, covering everything, and then becoming solid. that's how much they rock. java rocks like frozen lava. did I mention I was bored?
Dru Lee Parsec
11-09-2000, 04:09 PM
Welcome to the dark side my son.
No, wait! Wrong movie.
Since I use Jext I wrote a Hyperkey macro so I just type:
sys[escape] and Jext types
System.out.println("");
and then puts my cursor between the quotes.
Yes hashtables rock. How about a Properties class? It's a hashtable that can be loaded from a text file and saved back to a text file. And don't forget ArrayList and HashMap. Those guys rock and are really fast!
As far as Macros in the preprocessor I must quote Scott Meyers from the book "Essential C++"
"You may be tempted to go back to your days in the gutter and rely on the pre-processor"
'nuff said.
kslaguardia
11-09-2000, 04:15 PM
Did you guys learn Java from a book? If so, what book helped you?
kmj
11-09-2000, 07:51 PM
I used Sun's java docs; I already knew C++, so I mostly knew it already. The only thing I had to learn was which classes to use for what purposes. I own O'reilly's Java in a nutshell and Java examples in a nutshell, but I haven't used them. The docs on Sun's site were far more helpful, since those books deal with an older version of java.
I use the ArrayList, love it, and the HashSet, which is great so far, too. The only thing that annoys me is that Hashtable doesn't have a capital t, while HashSet and HashMap do capitalize.
Yeah; I can do macros w/ vim, too, so when I set up a nice .vimjava file I should be fine.
I really do like it; I did my AI research project/program in java after only writing a couple of tiny little scripts.
jemfinch
11-10-2000, 12:54 AM
You can just use the C pre-processor and run cpp on it before you compile it http://www.linuxnewbie.org/ubb/wink.gif
Jeremy
Dru Lee Parsec
11-10-2000, 02:04 PM
I learned java because the company I was with 3 years ago switched to Java and we all had to get good fast. Evey developer there had Bruce Eckel's fine book "Thinking In Java".
This book is available in stores but it's also available on-line for free as PDF files at www.bruceeckel.com (http://www.bruceeckel.com)
It's a fantastic book. I think it's the best book for learning java because it starts at a very basic level, but it doesn't leave you there. By teh end of the book you're learning client server programming, Swing, Java Native Interface, and more. He even covers some basic design patterns.
If you buy "Thinking In Java" and do all the excercises you will not be sorry.
http://www.linuxnewbie.org/ubb/smile.gif
LloydM
11-10-2000, 04:50 PM
I learned Java about 2 1/2 years ago, because I saw Sun's Java Programmer Certification programming.
I thought it was quite cheap, around NZ$250, and since I already knew C/C++, I thought I'd give it a shot. I bought Java in a Nutshell (excellent book IMHO) and Just Java and Beyond, and sat the exam a month later. I passed, but I still haven't used Java commercially though http://www.linuxnewbie.org/ubb/frown.gif
Java's got some really nice features that I wish were in C++, e.g. the way you can mark methods as throws Something, (C++ has a similar but very restrictive/limited feature). Stack Trace in your exceptions, well designed class libraries, anonymous classes, ...
kmj
11-10-2000, 06:08 PM
Originally posted by jemfinch:
You can just use the C pre-processor and run cpp on it before you compile it http://www.linuxnewbie.org/ubb/wink.gif
Jeremy
Hmm. I think I'm going to try that!
Dru Lee Parsec
11-10-2000, 08:12 PM
Java in a nutshell
Really!? I thought that book was really bad. I didn't like it at all because the back half to two-thirds of the book is available on-line as the Java API specification for free. (and the on-line version is better documented).
But, I hear there's been another version of JIANS since I bought mine so maybe it's better now.
But yes, Java Rocks!
bakerb
11-14-2000, 05:18 PM
I don't know what kind of crack you guys are smoking, but it must be *really* good. Java sucks. It is the most horrible language ever created. Here are a few good reasons why.
1) Everything is a reference
All I want is a copy, and now I have to define some damned cone method in *every* class I ever want to copy. Also, riddle me this batman, they tell me there are no pointers in java, but how come i keep getting NullPointerExceptions. And while we are on the topic of references; the other day, I tried to compare two Strings with the == operator. Even though they were the same, it came back false. Do you know why? BECAUSE IT WAS COMPARING THE DAMNED REFERENCES!!! Seems to me like these "references" act a little too much like pointers . . . which brings me to my next topic.
2) No operator overloading
How are you going to stand here and tell me that overloading an operator should not be allowed. Because of this I cant compare two f*#@%!^g strings. And I can't add Integers. WTF!! I CAN'T ADD INTEGERS!?! So what if they are wrappers. It only makes sense to allow me to add two integers together. Now instead of:
i = j + k;
I have
Integer I = new Integer(J.valueOf() + K.valueOf());
That is just terrible. Which leads into my next complaint.
3) Java is, well, verbose.
I am sick and tired of having to cast 7 times in one line of code. It is unreadable.
4) No more multiple inheritance
<sarcastic tone> yeah, that was never useful, I *never* used that. <\sarcastic tone>.
5)System.out.println
How long did it take me to type that just now?
6) Reading from stdin
Gee, let's make include everything anyone could ever need in a programming language (hashtables, vectors, etc) but make it *almost* impossible for them to get anything but characters off of stdin.
7)java, javac, and wasted keystrokes
Hmmm, i want to compile after making some changes, so let me just do:
> !j
java foo
Damn, it ran the old version instead. Well lets do this:
> !javac
javac foo.java
Ok now lets run it:
> !java
javac foo.java
DAMN! I simply cannot '!' this command. oh well i guess I have to:
> java foo
8) Did you know that the same guy that spawned java also spawned emacs? Could he be any more evil?
9)public static void main (String[] args)
Just to do a hello world?
10) Integer i;
I can't just say:
Integer i;
and not get busted by the compiler. I have to say:
Integer i = new Integer(0);
retarded. And unsafe.
Well I hope you all see why java is a terible language. I will admit that there are some cool things included in java (like hashtables and general portability). But I just don't think that they are worth the price you pay in flexability, readability, and overall ease of programming. Sorry about the flame, but this is something I am believe in *very* strongly.
------------------
Save the whales. That way, you can collect and trade them with your friends!
[This message has been edited by bakerb (edited 14 November 2000).]
[This message has been edited by bakerb (edited 14 November 2000).]
kmj
11-14-2000, 05:46 PM
1) Everything is a reference
All I want is a copy, and now I have to define some damned cone method in *every* class I ever want to copy. Also, riddle me this batman, they tell me there are no pointers in java, but how come i keep getting NullPointerExceptions. And while we are on the topic of references; the other day, I tried to compare two Strings with the == operator. Even though they were the same, it came back false. Do you know why? BECAUSE IT WAS COMPARING THE DAMNED REFERENCES!!! Seems to me like these "references" act a little too much like pointers . . . which brings me to my next topic.
We all know references are actually prettier pointers, so in java everything is actually a pointer. They just say their are no pointers because pointers scare the uninitiated. You have the beauty of pointers w/o having to worry about the problems associated with them.
2) No operator overloading
How are you going to stand here and tell me that overloading an operator should not be allowed. Because of this I cant compare two f*#@%!^g strings. And I can't add Integers. WTF!! I CAN'T ADD INTEGERS!?! So what if they are wrappers. It only makes sense to allow me to add two integers together. Now instead of:
i = j + k;
I have
Integer I = new Integer(J.valueOf() + K.valueOf());
That is just terrible. Which leads into my next complaint.
You can't add Integers, but you can add ints all you want. I think operator overloading is cool, awesome, and groovy; but it doesn't make or break a language. Most languages don't have it.
3) Java is, well, verbose.
I am sick and tired of having to cast 7 times in one line of code. It is unreadable.
I agree that it is verbose. It isn't unreadable, though. See above discussions on using macros and possibly even preprocessors.
4) No more multiple inheritance
<sarcastic tone> yeah, that was never useful, I *never* used that. <\sarcastic tone>.
Multiple inheritance, a hairy and error prone scheme, was replaced with interfaces. Much cleaner.
5)System.out.println
How long did it take me to type that just now?
This was covered in (3)
6) Reading from stdin
Gee, let's make include everything anyone could ever need in a programming language (hashtables, vectors, etc) but make it *almost* impossible for them to get anything but characters off of stdin.
It's easy enough to convert from a char to anything else.
7)java, javac, and wasted keystrokes
Hmmm, i want to compile after making some changes, so let me just do:
> !j
java foo
Damn, it ran the old version instead. Well lets do this:
> !javac
javac foo.java
Ok now lets run it:
> !java
javac foo.java
DAMN! I simply cannot '!' this command. oh well i guess I have to:
> java foo
What, '!' is the only cool shell thing you know? Use an alias.
8) Did you know that the same guy that spawned java also spawned emacs? Could he be any more evil?
Uh, RMS created emacs, didn't he? java was created by Sun. Sun, which is run (at least partly) by Bill Joy, creator of vi.
9)public static void main (String[] args)
Just to do a hello world?
Yeah, what of it? Not really too much worse than C, especially once we actually start doing useful programs.
10) Integer i;
I can't just say:
Integer i;
and not get busted by the compiler. I have to say:
Integer i = new Integer(0);
retarded. And unsafe.
No; that is safe. You should have to initialize your variables; it would be unsafe to allow you to run around with uninitialized data.
Well I hope you all see why java is a terible language. I will admit that there are some cool things included in java (like hashtables and general portability). But I just don't think that they are worth the price you pay in flexability, readability, and overall ease of programming. Sorry about the flame, but this is something I am believe in *very* strongly.
You're going to have to come up with better arguments. The "general portability" you mention is an astounding benefit, which in the business world carries a tremendous amount of weight. The hashtables are only a tiny part of java's awesome package library. Java may be annoyingly verbose, but I think it is more readable than some cryptic backwater C hack. The verbosity actually makes a programmer's intentions clearer, improving readability. I don't know how you're defining flexibility, but I don't see any inflexibility in what you've mentioned,
and the packages make programming a functional program vastly easier than having to do the same thing in C. (Granted C++'s STL takes steps in the right direction.)
BrianDrozd
11-14-2000, 06:03 PM
Originally posted by bakerb:
1) Everything is a reference
All I want is a copy, and now I have to efine some damned cone method in *every* class I ever want to copy.
Yes, but you have to do the same thing is C++, so what's your point? Besides which, the clone method is usually trivial to write.
Also, riddle me this batman, they tell me there are no pointers in java, but how come i keep getting NullPointerExceptions.
Well, quite frankly, who ever told you there aren't pointers in Java was smoking something. There are pointers in Java. You just can't get to them.
And while e are on the topic of refs; the other day, I tried to compare two Strings with the == operator. Even though they were the same, it came back false. Do you know why? BECAUSE IT WAS COMPARING THE DAMNED REFERENCES!!! Seems to me like these "references" act a little too much like pointers...
That would be because that's what references are: pointers that have been hidden from you.
2) No operator overloading
How are you going to stand here and tell me that overloading an operator should not be allowed. Because of this I cant compare two f*#@%!^g strings.
Sure you can. Any object can be compared to any other object by using the equals method.
As for why operators can't be overloaded, that's because the designers of Java wanted strong type checking at compile time, rather than a runtime like it is with C++. Overloaded opperators make it much harder to do accurate type checking.
And I can't add Integers. WTF!! I CAN'T ADD INTEGERS!! So what if they are wrappers. It only makes sense to allow me to add two integers together. Now instead of:
i = j + k;
I have
Integer I = new Integer(J.valueOf() + K.valueOf());
just terrible.
Well, that's your opinion. Personally, I'd use the int simple type rather than the Integer class, but, well, that's your decision.
3) Java is, well, verbose.
I am sick and tired of having to cast 7 times in one line of code. It is unreadable. If I have a char, I should be able to assign it to an int.
I would actually assert just the opposite. Two of the biggest sources of bugs in C++ code is code that has been shortened into unreadabile statements and haphazard or unitentional type casting. It is good programming style to be more verbose, in general, then less. Moreover the compiler will catch more errors before hand if it doesn't automatically convert everything to an int. Java was deisgned to encourage good programming styles.
4) No more multiple inheritance
<sarcastic tone> yeah, that was never useful, I *never* used that. <\sarcastic tone>.
Multiple inheritence is generally a bad idea. There are too many problems with it an no good solutions.
Besides, most of the functionality that multiple inheritence buys you, Java has in way of interfaces.
5)System.out.println
How long did it take me to type that just now?
And your point being?
6) Reading from stdin
Gee, lets make include everything anyone could ever need in a programming language (hashtables, vectors, etc) but make it *almost* impossible for them to get anything but characters off of stdin.
Again, and your point being? Most of the time when I'm reading in from C++ I do it through either getline or getch. That's because that's about the only way to catch when mister dumb-as-a-rock end user tries entering "two" when I'm expecting a numeric input.
7)java, javac, and wasted keystrokes
Hmmm, i want to compile after making some changes, so let me just do:
> !j
java foo
Damn, it ran the old version instead. Well lest do this:
> !javac
javac foo.java
Ok now lets run it:
> !java
javac foo.java
DAMN! I simply cannot ! this command. oh well i guess I have to:
> java foo
you know, there's this lovely thing called 'alias'. Maybe you should read the man page on it. If you don't like how the commands are named, change them already.
9)public static void main (String[] args)
Just to do a hello world?
Yes. That's the main down side to pure Object Oriented languages. For reallyt small stuff, it takes a good deal more code.
10) can't compile Intger i;
I can't just say:
Integer i;
and not get busted by the compiler. I have to say:
Integer i = new Integer(0);
retarded.
Again, my personal preference but the only time I'd use a wrapper class like Integer is when I needed to stuff it into an Vector.
Besides, I don't know what your problems is with Integer i. I can get it to compile just fine. The Java compiler should interpret it as Integer i = null;
Now, if I want to actually use Integer, yes, I have to do an i = new Integer (0); It makes sense; I still have to allocate the memory for an Integer after all.
Well I hope you all see why java is a terible language. I will admit that there are some cool things included in java (like hashtables and general portability). But I just don't think that they are worth the price you pay in flexibility, readability, and overall ease of programming. Sorry about the flame, but this is something I am believe in *very* strongly.
I'd don't think you loose any flexability, readability, or ease of programming. I think you're forced to stop using the shortcuts that are in C and C++ and actually write good solid code.
Dru Lee Parsec
11-14-2000, 06:12 PM
OK, Who wants to take this one on? I guess I'll go first.
First of all, back off of the coffee and jolt cola, you'll be a lot happier (and calmer).
>1) Everything is a reference All I want is a copy, and now I have to define some damned
>clone method in *every* class I ever want to copy.
Sounds like a style issue to me. Certainly not enough to slam an entire language. If you want a copy make one. What's the big deal.
>Also, riddle me this batman, they
tell me there are no pointers in java, but
>how come i keep getting NullPointerExceptions.
"I" never said there were no pointers in Java. You just don't have to code for them explicitly. As per your last point, all arguments are passed by reference so you DON'T have to woryy about pointers. Let's not forget the benefits of automatic garbage collection either. As far as your NullPointerExceptions: stop trying to run methods on objects that havn't been initialized. If you do that in C++ you get an error as well.
>And while we are on the topic of references; the other day, I tried to
>compare two Strings with the == operator. Even though they were the same, it came back
>false. Do you know why? BECAUSE IT WAS COMPARING THE DAMNED REFERENCES!!!
Of course, You're comparing two objects in memory. String1 == String2 is asking if these are the same objects and they're not. String1.equals(string2) is an object oriented way of doing what you want. If your argument is that Java is forcing you to write object oriented code instead of linear code then I'll agree with you.
>Seems to me like these "references" act a little too much like pointers . . . which
>brings me to my next topic.
Which is exactly what they are. You're just insulated from the problems of parameter passing and garbage collection.
>2) No operator overloading
How are you going to stand here and tell me
>that overloading an operator should not be allowed. Because of this I cant compare two
>f*#@%!^g strings. And I can't add Integers. WTF!! I CAN'T ADD INTEGERS!?! So what if
>they are wrappers. It only makes sense to allow me to add two integers together. Now
>instead of:
>i = j + k;
>I have Integer I = new Integer(J.valueOf() + K.valueOf());
>That is just terrible.
Once again, your real complaint is that you can't write linear code in an object oriented world. But I would agree that operator overloading would big a great help. However, before you continue your rant think about this: All the wrapper classes (Integer, Float, Boolean etc) are defrived from java.lang.Object. All the collection classes (Vector, ArrayList, etc) can hold anything that is derived from java.lang.object That means that the standard collections can hold ANY OBJECT. So if you want to use int, float, boolean then use them. If you want to manipulate objects then use objects. But don't be upset because Objects don't allow you to write non-OO code.
>3) Java is, well, verbose. I am sick and tired of having to cast 7 times in one line
>of code. It is unreadable.
And C has an obfuscation contest so what's your point? You can write clear or unclear code in any language.
>4) No more multiple inheritance
><sarcastic tone> yeah, that was never useful, I *never* used that. <\sarcastic tone>.
Ignoring the sarcasim for the moment, even Bjarne Stroustrup has said that if he had it to do over he would never have allowed multiple inheritence in C++. But I'm sure you're a much better language designer than Mr. Stroustrup so I'll let you take it up with him.
Oh BTW </sarcasm>
>5)System.out.println
How long did it take me to type that just now?
Yep, I type sys[escape] and my editor does it for me. It's a poor workman that blames his tools.
But more importantly is that you're missing the point of System.out.println(); System is a class which has a public output stream attribute which has a static method called println(String). If you're tired of typeing it then perhaps you're not appreciating the object oriented design of the System class.
>6) Reading from stdin
Gee, let's make include everything anyone
>could ever need in a programming language (hashtables, vectors, etc) but make it
>*almost* impossible for them to get anything but characters off of stdin.
Sorry, I'm going to draw the line here. Rather than teaching a class in how to accept byte streams via an IP address or via an RS 232 port or via the serialization of ANY object or any of the many many other ways to accept data in Java I'm just going to have to say "You're mistaken".
>7)java, javac, and wasted keystrokes
Hmmm, i want to compile after making some
>changes,
[silly bang example deleted]
Sorry but once again, it's a poor workman that blames his tools. In the past I used makefiles but now I use ant. To compile my projects I type:
ant
To run it I type
!j
and it runs the last java command I typed in.
>8) Did you know that the same guy that spawned java also spawned emacs?
>Could he be any more evil?
Not even worth commenting on.
>9)public static void main (String[] args)
Just to do a hello world?
Once again, you're missing the point of Object Oriented programming. Rather than spend the next several months showing you the error of your ways I suggest you look at "Thinking in Java" by Bruce Eckel.
>10) Integer i;
>I can't just say:
>Integer i;
>and not get busted by the compiler. I have to say:
>Integer i = new Integer(0);
>retarded. And unsafe.
No, You're creating memory on the heap just like you do in C++. If you did this in C++ you'd get exactly the same thing. In your first example you're creating a pointer to an object. When you use "new" you're creating an actual object. If you don't see how this is exactly the same as with C++ then you don't have sufficient knowledge to argue the merits of either language.
>Well I hope you all see why java is a terible language.
Sorry, I don't see your point at all.
>I will admit that there are some cool things included in java (like hashtables and general portability).
And Swing, and RMI, and JNI, and the ease of creating client server applications. Not to mention servlets, Java server pages; The ease with which Java can work with XML objects; The utter simplicity of code it takes to serialize an object or any of the other amazing things about java.
Oh and about that "general portability" thing? I use exactly the same text editor in Windows NT, Linux and IBM AIX running on a mainframe. Why? Because Java is platform independent. Can you write ANY C program that can do that without recompiling?
kmj
11-14-2000, 06:34 PM
OK, Who wants to take this one on? I guess I'll go first.
LOL; Should'a known that was coming. Never thought i'd cross the line so fast. I wonder if it took me or jemfinch longer to jump ship. 'Course, I might just forget about java when I finally get to try python. http://www.linuxnewbie.org/ubb/smile.gif
Dru Lee Parsec
11-14-2000, 07:06 PM
Yeah, by the time I wrote my response you guys already answered it for me. http://www.linuxnewbie.org/ubb/smile.gif
Look everyone, Java Rocks! C++ Rocks! Python Rocks! Perl Rocks!
You can write bad code in any language.
You can write good code in any language.
But if you're going to slam a language then you should have a better understanding of it than the people who make their living coding in that language 10+ hours every day for the last several years.
Now, have you heard any good programmer jokes?
justlinux.com
Copyright Internet.com Inc. All Rights Reserved.