PDA

View Full Version : breaking the java habit...



MikeyIckey
01-15-2008, 11:07 PM
so i was reading one of the threads that started quite a debate.
link's right here. (http://cboard.cprogramming.com/showthread.php?t=97676)
I found it pretty interesting, both the forum and the authors of the discussed article made some really excellent points, but it brought up some questions for me.
Mainly how does some one whose first programming language was Java break the Java habits?
They don't work for C and C++ (obviously :rolleyes: ) but I can't seem to get passed going back to Java to try to figure out how to write C code.

At any rate, I was hoping to get some feed back from you guys and gals.
Thanks again!

~M.I.

Dino
01-15-2008, 11:29 PM
I'm coming from a non-C / non-C++ background as well. I too find myself "all the time" working out the code I'm trying to write in the language I primarily code in. So, it's not just Java!! I've been coding in Assembler for 18 years!

I feel your pain.

Todd

CornedBee
01-16-2008, 03:30 AM
Breaking a paradigm habit is the same as breaking any other habit. Prevent yourself from indulging in it. Arrange things so that you get negative feedback every time you indulge. (E.g. to get rid of finger biting, paint your nails with this foul-tasting stuff.)

Learn Haskell or ML. The functional approach is so fundamentally different that with an imperative, object-oriented mindset you will get absolutely nowhere. That ought to work.

indigo0086
01-16-2008, 07:32 AM
I hopped from regular Java study and use to heavy C++ use. One step is not to read material the compares how the two languages do things, because it seems as though they get you thinking, "In java you do this, but like this"

I don't think it's so difficult, because other than the whole library and that stuff you just have to know the basics.

I'm taking a class where we're doing ml this semester, wish me luck.

abachler
01-16-2008, 09:45 AM
Quit java like you quit cigarettes, by going cold turkey.

Don't buy cigarettes, dont use java. Eventually the effects will wear off.

indigo0086
01-16-2008, 10:26 AM
And don't think C# is a nicorette patch.

abachler
01-16-2008, 10:56 AM
Ultimately you need to realize that the assertion that Java is 'just like C/++' is a load of malarky. See C/C++ as a new language and you will overcome one of the largest mental barriers to learning C/C++. Whether its true or not is irrelevant. Seeing them as 'similar' makes you end up using your java knowledge to try to figure out C/C++, which ultimately holds you back. Its unfortunate that you where mentally abused by being taught java as a first language, so radical steps are necessary to fix the damage.

laserlight
01-16-2008, 11:15 AM
See C/C++ as a new language and you will overcome one of the largest mental barriers to learning C/C++.
I agree. I would extend this to C and C++ as well, in that recognising that they are different and not some language named C/C++ (http://www.research.att.com/~bs/bs_faq.html#C-slash) is a step across the barrier to learning one after learning the other.


Its unfortunate that you where mentally abused by being taught java as a first language, so radical steps are necessary to fix the damage.
I think that is an exaggeration. It not mental abuse to be taught programming with Java as the first programming language. The "radical" steps we're talking about here is necessary when learning any new programming language radically different from the ones you already know.

indigo0086
01-16-2008, 11:18 AM
I'm noticing a trend with abachler

abachler
01-16-2008, 11:52 AM
I'm noticing a trend with abachler

Heh, what trend would that be?

Prelude
01-16-2008, 02:31 PM
>Mainly how does some one whose first programming
>language was Java break the Java habits?
Why would you want to? At the risk of alienating all of the language zealots here, you learned Java, and those lessons are valuable. There's no reason to throw them away, even if you move to a different language. Just remember that Java is Java, and other languages are not Java. Adjust your habits accordingly, but don't discard them.

abachler
01-16-2008, 03:38 PM
Java is a language for babies :duck:...

j/k. Although I dont see it as being useful outside web applications.

Dino
01-16-2008, 04:21 PM
I like Java. It looks good on my resume.

CornedBee
01-16-2008, 05:47 PM
you learned Java, and those lessons are valuable. There's no reason to throw them away, even if you move to a different language. Just remember that Java is Java, and other languages are not Java. Adjust your habits accordingly, but don't discard them.

True, but I think the adjusting is what the OP has problems with. And the best way of stopping to try to apply the Java way of thinking to everything is to completely avoid the Java way of thinking for a time. It's not like you forget it.

Thantos
01-16-2008, 05:54 PM
One thing that helps is to program in several different languages at the same time (but not necessarily for the same project). Since I've had to do that I found I think more about the problem, possible algorithms, restrictions, etc long before an implementation comes to mind. I then start thinking about the implementation (in generics) which then leads me to a language and then to a specific method.

mike_g
01-16-2008, 05:58 PM
Well for me I got stuck with Basic for quite a while because I knew it well and could do most things I wanted in it. Learning new languages takes time, and in that time you cant make as much fun stuff. It took me a couple of years before I got off my ass started learning C; console apps aren't the most inspiring things to start off with. That said Its nice to be able to make progs that run fast and don't come with a ton of bloat.

VirtualAce
01-16-2008, 07:04 PM
Fundamentally you should probably think more about the task you are trying to accomplish than the actual code behind the task. There will be a point where you will have to begin thinking about code but that should be simple(r) since you already have a design. So if you find yourself thinking in Java then I'm afraid if you use C++ you will also find yourself thinking in C++ instead of thinking in concepts. Fact is you don't think in any language when you are approaching a specific problem. This will keep you concentrated on how to approach and solve the problem more than how you will code A with B.

Once you have your design and approach then you could pretty much code it in any language. At this point you will have to wrap your brain around C++ a bit but it should not be too hard - especially when the compiler starts yelling at you for this or that. Once that happens you will get a good feel for what is allowed in Java and what is allowed in C++. I don't think the adjustment should be that difficult. And your Java knowledge will not be 100% useless in C++ so I agree that you shouldn't throw out the baby with the bathwater here. Think of it as both and instead of one or the other.

Your problem as I see it may be you are thinking in relation to a specific language or a specific implementation rather than a general overall view of the underlying concepts.

MikeyIckey
01-19-2008, 12:26 PM
Thanks everyone for the input.
So it looks like the general consensus is not forget to java, but remember that C is not Java and focus on the on design.

doubleanti
01-23-2008, 12:37 PM
Although I dont see it as being useful outside web applications.


Alright... well... basically my entire Ph.D. project is written in Java. I wrote an english syntax parser, and vector analysis package, and a bunch of other stuff to do natural language processing in it. It has a lot of libraries by which you don't have to re-impliment a lot of very useful data structures (I actually wrote a tree-map, but then scratched it after I realized that java already had it! such wasted time but at least I learned something). It was good because I wanted to focus more on dealing with the grammar, and the algorithms, and not nitpick around making data structures for everything.

Also, it's cross-platform compatible so you can run your code on your windows box, but also on a unix box.

So, yeah...!

Oh, and before anyone mentions anything about performance, my simulations take six days already, so it doesn't really matter. I swear, the other Ph.D.'s always .......... about their sims taking half an hour, or like two hours, go get some lunch and come back, try a week... pfft!

So... yeah!

CornedBee
01-23-2008, 02:46 PM
Oh, and before anyone mentions anything about performance, my simulations take six days already, so it doesn't really matter.
Err ... now if your simulation took a minute, then I'd say don't worry. But if it takes 6 days, then even making it run just 1% faster would shave a full hour and more off.
The longer something takes, the more you should worry about performance.

doubleanti
01-23-2008, 06:08 PM
Well, that's true that the longer it takes the more the percentage-wise improvement would help. However, there are multiple modules to the project, so usually when I'm running simulation on a particular part, I'm coding or improving other parts, or writing new code for something else. If I were to re-write this in C++, it would probably take more work, though I have re-written this entire project from the ground up several times.

abachler
01-23-2008, 08:53 PM
I have to learn new flavors of basic all the time. I program a lot of controllers (servo's, PLC's, etc). The latest flavor is PBASIC. Once you know how to program, the specific language only depends on what is most applicable to the task at hand. Sure, I'd love to be able to program the BASIC stamp in C/C++, but then it would be the C/C++ Stamp. The project requirement is to write the code for the stamp, so I just have to deal with it.