Google Groups Home
Help | Sign in
Message from discussion Porting C++ Template to Java Generic
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Chronic Philharmonic  
View profile
 More options May 17, 3:19 pm
Newsgroups: comp.lang.java.programmer
From: "Chronic Philharmonic" <karl.uppi...@verizon.net>
Date: Sat, 17 May 2008 19:19:16 GMT
Local: Sat, May 17 2008 3:19 pm
Subject: Re: Porting C++ Template to Java Generic

"Stefan Ram" <r...@zedat.fu-berlin.de> wrote in message

news:multiply-20080517013612@ram.dialup.fu-berlin.de...

> Aadain <aad...@gmail.com> writes:
>>Has anyone ever encountered this type of problem,
>>or can anyone see a way around this issue?

>  In Java, »*« only applies to primitive types, which cannot be
>  type arguments.

>  On this low level you would need to define an implementation
>  of »multiply« for each relevant type and use »a.multiply(b)«
>  or »multiply(a,b)« or so depending on the type of dispatch
>  (static or non-static) wanted for each argument.

>  Often, it will be better to re-design and re-implement in Java.

I inherited a "Java project" that was ill-advisedly ported from both C and
C++. The Java code had in/out parameters, HVALUE type return types that you
had to check (without the benefit of the Win32 "cracker" macros --  instead
of throwing/catching exceptions), and monstrosities such as "MutableInt". It
was not Java, it was Win32 and/or C and/or C++ that you could compile down
to Java byte codes and run in a JVM.

The sad thing was, when the project was ported to Java, it severed its ties
to the original native code base, so the only argument for the port was
slightly faster time to market, or slightly less development cost than
starting over in Java. I do not believe those arguments were validated, and
even if they were, any gains were more than offset by the very high cost of
maintenance over the years of the product's useful life.

Port the design, not the code.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google