Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Because I'm too lazy to ask my coworkers.

54 views
Skip to first unread message

cda...@gmail.com

unread,
Mar 6, 2019, 2:47:42 PM3/6/19
to
Are than any decent books meant for inexperienced C++ programs who need to rewrite Java code in C++? More to the point, I need to rewrite a few thousand lines of Java code for the Android Platform to the C++ equivalent on a Microsoft tablet. I don't know where to look because parts of the code Java code to be directly translated to the C++ equivalent.

Jorgen Grahn

unread,
Mar 6, 2019, 4:57:47 PM3/6/19
to
On Wed, 2019-03-06, cda...@gmail.com wrote:
> Are than any decent books meant for inexperienced C++ programs who
> need to rewrite Java code in C++? More to the point, I need to
> rewrite a few thousand lines of Java code for the Android Platform
> to the C++ equivalent on a Microsoft tablet.

Do you mean C++ books for Java programmers?

I'm asking because you may get better answers if that's clarified.
For people completely new to programming, Stroustrup's "Programming:
Principles and Practice Using C++" is said to be good.

> I don't know where to look because parts of the code Java code to be
> directly translated to the C++ equivalent.

That sentence's beginning is intriguing, but I cannot parse the end.
What did you mean to say?

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Öö Tiib

unread,
Mar 7, 2019, 3:56:55 AM3/7/19
to
On Wednesday, 6 March 2019 21:47:42 UTC+2, cda...@gmail.com wrote:
> Are than any decent books meant for inexperienced C++ programs who need to rewrite Java code in C++?

it takes about half a year within experienced C++ team for Java
programmer to reach level of working alone.

> More to the point, I need to rewrite a few thousand lines of Java code for the Android Platform to the C++ equivalent on a Microsoft tablet.

The main issue there is that the Android and Windows
Phone tools and API-s are quite different and apps mostly
consist of configuring and calling those APIs. Just write
down every detail that thet the app must do and how. Then
write totally new program that just looks same.

> I don't know where to look because parts of the code Java code to be directly translated to the C++ equivalent.

Perhaps read "A tour of C++". http://www.stroustrup.com/Tour.html.
It is less than 200 pages and gives pretty decent overview how
to use C++ in general. However the main trouble of yours will be
how to make apps in C++ for Windows Phone ... and I don't know
any decent materials for that.

cda...@gmail.com

unread,
Mar 7, 2019, 7:15:20 AM3/7/19
to
On Wednesday, March 6, 2019 at 1:57:47 PM UTC-8, Jorgen Grahn wrote:
> On Wed, 2019-03-06, cda...@gmail.com wrote:
> > Are than any decent books meant for inexperienced C++ programs who
> > need to rewrite Java code in C++? More to the point, I need to
> > rewrite a few thousand lines of Java code for the Android Platform
> > to the C++ equivalent on a Microsoft tablet.
>
> Do you mean C++ books for Java programmers?
>

I think C++ for Java programmers might be what I'm look for since I like to believe that I'm somewhat versed in imperative programming languages..


> I'm asking because you may get better answers if that's clarified.
> For people completely new to programming, Stroustrup's "Programming:
> Principles and Practice Using C++" is said to be good.
>
> > I don't know where to look because parts of the code Java code to be
> > directly translated to the C++ equivalent.
>
> That sentence's beginning is intriguing, but I cannot parse the end.
> What did you mean to say?
>

Ideally I'd just like to just change the syntax. Ie, I really don't want to have to rewrite the core algorithms.

Sam

unread,
Mar 7, 2019, 8:24:44 AM3/7/19
to
cda...@gmail.com writes:

> On Wednesday, March 6, 2019 at 1:57:47 PM UTC-8, Jorgen Grahn wrote:
> > On Wed, 2019-03-06, cda...@gmail.com wrote:
> > > Are than any decent books meant for inexperienced C++ programs who
> > > need to rewrite Java code in C++? More to the point, I need to
> > > rewrite a few thousand lines of Java code for the Android Platform
> > > to the C++ equivalent on a Microsoft tablet.
> >
> > Do you mean C++ books for Java programmers?
> >
>
> I think C++ for Java programmers might be what I'm look for since I like to
> believe that I'm somewhat versed in imperative programming languages..

You will actually find it easier to learn C++ if you put everything you know
about Java out of your mind.

Despite C++'s deceptively similar syntax, in many ways C++ is fundamentally
different from Java. It is quite common for someone with a Java background
to look at some C++ code that looks almost Java and think it does the same
thing. It does not, and this only causes constant confusion, and common
programming errors that the Java developer will not understand.

> Ideally I'd just like to just change the syntax. Ie, I really don't want to
> have to rewrite the core algorithms.

It is almost a certainty that you will have to. C++ is not Java. Java is
managed code. C++ is not. Java will take care of creating, baby-sitting, and
destroying all of your objects, after the last reference to each object goes
out of scope, and the object becomes subject to garbage collection.

There's nothing of that sort in C++. In C++ you have complete responsibility
for figuring out when objects are no longer needed, and must be destroyed.
Guess wrong one way, and your running program eats all available RAM in a
few seconds. Guess wrong the other way, and you get random crashes in some
completely different part of the code which has nothing wrong with it,
leaving you to wonder WTF is happening.

C++ is not Java. To correctly use C++ for anything beyond "Hello world!" you
need to fully understand C++'s fundamental scoping rules, and actually
understand how objects get created, when they should be created, and when
they should be destroyed. As a Java coder, this is something that you have
never learned, and you simply don't know because Java always did this for
you, by itself. But now you must learn all of this in order to write C++
code that doesn't nuke itself from high orbit, all the time. And you must
learn this 100% correctly. No margin for error, whatsoever. Otherwise your
code will simply not work.

So, no, it is unlikely that you will be able to simply take Java code that
does anything more complicated than printing "Hello world!", and just
replace it with equivalent C++ syntax.

Jorgen Grahn

unread,
Mar 7, 2019, 4:47:20 PM3/7/19
to
On Thu, 2019-03-07, Öö Tiib wrote:
> On Wednesday, 6 March 2019 21:47:42 UTC+2, cda...@gmail.com wrote:
>> Are than any decent books meant for inexperienced C++ programs who need to rewrite Java code in C++?
>
> it takes about half a year within experienced C++ team for Java
> programmer to reach level of working alone.
>
>> More to the point, I need to rewrite a few thousand lines of Java
>> code for the Android Platform to the C++ equivalent on a Microsoft
>> tablet.
>
> The main issue there is that the Android and Windows
> Phone tools and API-s are quite different
[etc]

I was going to flame certain other unhelpful replies, but there's
enough negativity in the group.

So I'll praise this one instead. Practical, insightful and helpful.

(Disclaimer: I don't know anything about these APIs myself.)
0 new messages