D-SIPL Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
I've just been routing through old posts in this forum, one thing i have noticed is there are a lot of novice programmers.. who want to learn C/C++. Now, in my opininon if i were to start programming i would start with a version of BASIC (who many are there now!!), and then move onto something like Java. When you have mastered (i use that term lightly as no-one can truely master a language.. i think!!) it then move onto to C/C++. I went straight for C/C++, and picked up so many bad habits, but Java teaches you how to properly construct your code and stops you getting into bad habits. Am i alone here, or do other people agree. --D-SIPL |
Briant Member Posts: 742 From: Stony Plain, Alberta, Canada Registered: 01-20-2001 |
I'm biased, but I think if your end goal is to learn C/C++, then start with C/C++. But then again I've never done any Java (I don't see how I can live without pointers), and haven't touched BASIC since the early 80's. What kinds of bad habits are you referring to that Java helps you avoid that C/C++ doesn't? Brian |
D-SIPL Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
The main bad habit is that C++ allows you not to encapsulate types, where as Java will not let you declare something that is not encapsulated in an object. I still think that Java is more sructured and is a good starting point for any programmer. --D-SIPL |
D-SIPL Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
oh yeh, one other thing.. you stated that you couldn't live without pointers (i had the same feelings until i started programming in Java). no pointers is probably the strongest guarantor of security that lies embedded into the Java language. There being no pointers means that there isn't a peice of a Java program that is anonymous. Meaning every data structure and fragment of code has a handle that makes it fully traceable. Hope this helps (I'm not trying to convert anyone to java.. honest!!) --D-SIPL |
Briant Member Posts: 742 From: Stony Plain, Alberta, Canada Registered: 01-20-2001 |
Hey D-SIPL, You said "The main bad habit is that C++ allows you not to encapsulate types". Since I don't know Java, I cannot adequately debate the pros and cons of C++ vs. Java. However, I don't see how that is a bad habit. I think it is more a matter of style, and sometimes of necessity, to determine when to encapsulate or not. I often avoid encapsulation on purpose, not because of a bad habit, but because of convenience (eg. encapsulating a x,y coordinate is overkill in my opinion) or because of a speed improvement (calling constructors/destructors unnecessarily in critical loops, etc, are going to slow things down). But again, I don't know Java so maybe these are not even an issue there. You said "no pointers is probably the strongest guarantor of security that lies embedded into the Java language. There being no pointers means that there isn't a peice of a Java program that is anonymous. Meaning every data structure and fragment of code has a handle that makes it fully traceable." I have no idea what you are talking about. Brian [This message has been edited by Briant (edited August 10, 2001).] |
rowanseymour Member Posts: 284 From: Belfast, Northern Ireland Registered: 02-10-2001 |
Hi everybody. Here's my take on the whole Java vs C/C++ thing: Disadvantages of Java... 1. No unsigned data types. Makes something like modifiying an image buffer really inefficient. Advantages of Java... [This message has been edited by rowanseymour (edited August 13, 2001).] |
D-SIPL Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
I don't want to start an argument.. but it seems as though you have never used Java. Some of the points are incorrect. --D-SIPL |
CobraA1 Member Posts: 926 From: MN Registered: 02-19-2001 |
I've been experimenting with an older Java compiler, and I've found Java to be about as easy as C++, with a couple of exceptions: -Since I don't know anything about how the handles work, and Java doesn't use pointers, I've been having problems making custom data structures. I can get them to work, but I know that they are far from being efficient; they're really hackish. -I'm using an older piece of Symantec's Cafe - which means I don't have any of the stuff that I'd like. DirectX? I hate it. I can't get a simple 2D app going properly. Not to mention that it won't work with Linux. Tried it, gave up. I'm making much faster progress with Java. I even got threads working, even though I have never worked with them in C++. |
D-SIPL Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
Which was the whole point of this post.. Java is easier to learn then C++.. nice one mate!! |
CobraA1 Member Posts: 926 From: MN Registered: 02-19-2001 |
Umm, any advice on free Java implementations I can use? I don't like not having vectors and other things my outdated version doesn't have. Also, any advice on how to use data structures in Java? How do I work with the handles? One more thing: Anybody know how to pass or share information between threads? |
rowanseymour Member Posts: 284 From: Belfast, Northern Ireland Registered: 02-10-2001 |
Ok Mr D-SIPL. Which bits of my post are incorrect ? I know you said you didn't want to start an argument, but I am having a particularly dull day at work . I have been using Java for about 2 years, C/C++ for 3. If you want a child thread to share data with its creator / parent, just construct it with a reference to the creator. If you want to share data between child threads, just use static data. MyThread t = new MyThread(this); class MyThread extends Thread MyThread(Object parentObj) { ... } synchronized void setVariable() { ... } synchronized ... getVariable() { ... } Using the synchronized keyword ensures only one thread at a time can execute that function. It also can be applied to any code block. [This message has been edited by rowanseymour (edited August 16, 2001).] |
D-SIPL Moderator Posts: 1345 From: Maesteg, Wales Registered: 07-21-2001 |
6. No printf()- why do you need need printf(), it's Java not c/c++!! system.out.println or system.out.print (whis is the true cousin of C/C++). 8. No concept of hardware. Your program is limited to the realm of the virtual machine, so you can't do things like change the screen resolution. Wrong.. the company i work for, we program investment software, and we utilise the screen resolutions for people with dual monitors. 12. Javabyte code is easily decompiled.- only if it not encrypted. We have a lot of rivals in our market, and we wouldn't risk letting our source code get out!!
Hope this helps --D-SIPL [This message has been edited by D-SIPL (edited August 18, 2001).] |
CobraA1 Member Posts: 926 From: MN Registered: 02-19-2001 |
Thanks for the help. Hopefully, I can now actually finish a project for once . But I'm in college, so I'll see how much spare time I have. |