Porting to C++

For code related discussions and questions
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Porting to C++

Post by Cyp »

Chojun wrote:C++ for the sake of it isn't a good enough reason. I currently do contract software development for the US Air Force and although most of the new/evolving stuff is written in the latest .NET 4.0, you'd be surprised to learn how old the code is that some F-16s and older aircraft are running on (30-40 years old in some cases).

The old axiom "if it ain't broke, then don't fix it" is what fits there. The crux is that the code works exceptionally well and changing it just to simply modernize it creates maintenence hazards that in some cases can be untenable.

The fact is that Warzone's core code works reasonably well, so there has to be a good reason to migrate. Some advocate C++ because at some level they understand that it is superior (++) to C, but they don't quite understand why. C and C++ both compile to the same machine code, so what's the big difference?

Design. :hmm:


Edit: Wow, that's an old topic. Sorry about that. :stare:
Old topic, yes — Warzone 2100 in C++ now (renamed the files from .c → .cpp, that is). It should hopefully still compile down to the same machine code.

As for "if it ain't broke, then don't fix it", the .c → .cpp isn't a fix, it's just something that makes future fixing easier (sometimes much easier).

In my opinion, refactoring stuff is a lot faster to do in C++, and results in a lot less code to maintain, and the result is also a lot more readable. (Results may vary depending on C++ usage/abuse ratio.)
littlepig
Code contributor
Code contributor
Posts: 2
Joined: 13 Jan 2011, 12:33

Re: Porting to C++

Post by littlepig »

I'm no expert in c/c++ code but here it goes.

When one is playing this game, one clearly see that much of its identities are objects. I mean, they are physical objects: they have properties, actions, interactions with other objects, receive orders, Join a group, are built and destroyed, etc. All this "things", one must admit, are today better implemented in a objected oriented paradigm, where methods, friends, virtual methods, private and public domains, polymorphism, overloading etc. do each job.

By better implemented, I mean that the code is:

- better portable;
- better readable;
- better debugged;
- better expandable;
- same or no relevant computational cost;

The question, I think, is not whether this code should or should not be ported. In my point of view, the 1º question (and the 2º most difficult to answer right now) is: how can we port this old, yet so great and so tested code to C++. How can we find a intelligent way of porting it.
I've been studied the code, and without doubt, it is a difficult task!, I think that anyone (so as the devs) who know some (or most) of the code, understand this problem. And this is, in my perspective, the reason why there is the inertia to change a so good coded wz code to C++.
There is a great risk that a bad port can cause some good months of debugging (that was already made on the current code) with the increased possibility of abandoning the project (of porting), which can causes months (and a lot of code wasted) of delay in the current tasks of maintaining the current code. In my perspective, people like Seismo haven't yet understood (or don't want to understand) this pertinent point.

To test a port, I personally wasted 1 day of my life trying to only port the group.h/cpp to a class, and I must assume is difficult: either the design options, my ignorance, or simply the fact that the rest of the code is not ported yet and so a lot of things just don't fit well. (And I'm so noob that I deleted the local repository where it was stored ahahahahahahaha).

In my opinion, the conclusion of the test was this: it is possible to port, but this will cause some very nasty stuff in the current project. I perceive that a port means a whole new bug system would have to be built from scratch, basically because the current one is based on the current code paradigm, that would change with the port. Probably some of the things had to be built too, but I don't know enough of this code to tell you about.

So, this leads to my 2º question (and the 1º most difficult to answer right now): is it worth?

I personally don't know the answer, but I have some opinion:
In a long term objective, it is fundamental to port it:

- The better implemented the code, the more devs came to join, which is good for the community;
- The faster is to debug which means faster response to bugs, which means more people playing the game, which is good for the community;
- Portability for obvious reasons;
- Better expandable which means more features/year, which means more people joining the community, which is good for the community.

However:
- This is a open source community, and so, one of it the objectives, by definition, is to be a community, which means that, by definition, have different points of view;
- One don't know how to quantify the concept of "long term objective", because different people have different definitions of long;
- Some people(developers) spent much time working on this code, and an abrupt change on it is, by its definitions, a shake to them. If the change goes wrong, the developers are (again by definition) the best targets to blame, which can in turn leads to some bad environment on the community, which is bad for the community.
- Most people (who play games) don't care about all of this; they only want a good, stable, low bug game to play. A complete stop to code maintenance makes people leave the game (and the community).

Have all said for now,
littlepig
Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Porting to C++

Post by Chojun »

I'm about to release the so-called 'wz2200' source. I made a bit of an effort to port Warzone's framework code over to C++, as you will see.

The task is not impossible, it must be approached from a design perspective.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Porting to C++

Post by Per »

The current c++ port is based on a very simple rule of thumb: If a change to c++ way of doing things makes the code better (shorter, less hacky, faster, etc) then it is good. If there are only ideological reasons (OO rules, c++ rocks, classes are pretty, whatever), then it does more harm than good. This means it will be a slow port, with focus on features instead of language religion, and that is intentional.
User avatar
Rman Virgil
Professional
Professional
Posts: 3812
Joined: 25 Sep 2006, 01:06
Location: USA

Re: Porting to C++

Post by Rman Virgil »

.

:shock: :o :stare: :hmm: :ninja: :3


- :wink:
.
.

Impact = C x (R + E + A + T + E)

Contrast
Reach
Exposure
Articulation
Trust
Echo
.
jumico
Greenhorn
Posts: 7
Joined: 29 May 2010, 16:44

Re: Porting to C++

Post by jumico »

Why would c++ be more portable than c?
Chojun
Regular
Regular
Posts: 518
Joined: 25 Nov 2006, 17:49
Contact:

Re: Porting to C++

Post by Chojun »

It's more portable in the sense that you can design to portable interfaces.
Seismo
Trained
Trained
Posts: 70
Joined: 06 Feb 2010, 17:32

Re: Porting to C++

Post by Seismo »

Good C++ object oriented code is much easier to maintain. Support is not a harmfull matter anymore. This will also make it extrem easy to untersand the code if you are new to this project. And last but not least it will be more portable due less harmfull search, try and error thru code changes.
User avatar
Buginator
Professional
Professional
Posts: 3285
Joined: 04 Nov 2007, 02:20

Re: Porting to C++

Post by Buginator »

Chojun wrote:I'm about to release the so-called 'wz2200' source. I made a bit of an effort to port Warzone's framework code over to C++, as you will see.

The task is not impossible, it must be approached from a design perspective.
Was this ever released ? :hmm:
and it ends here.
Seismo
Trained
Trained
Posts: 70
Joined: 06 Feb 2010, 17:32

Re: Porting to C++

Post by Seismo »

Buginator wrote:
Chojun wrote:I'm about to release the so-called 'wz2200' source. I made a bit of an effort to port Warzone's framework code over to C++, as you will see.

The task is not impossible, it must be approached from a design perspective.
Was this ever released ? :hmm:
Yes, i got it for conversion to c# i am currently working on.
medusa
Trained
Trained
Posts: 175
Joined: 25 Jul 2011, 01:56

Re: Porting to C++

Post by medusa »

Seismo wrote:
Buginator wrote: Was this ever released ? :hmm:
Yes, i got it for conversion to c# i am currently working on.
another version of warzone?
where can we get it from?
User avatar
vexed
Inactive
Inactive
Posts: 2538
Joined: 27 Jul 2010, 02:07

Re: Porting to C++

Post by vexed »

FWIW, last I heard, Chojun's code was given to Seismo who is working on a C# version.
While they both have project pages on SF, neither of them have anything in the repo.
/facepalm ...Grinch stole Warzone🙈🙉🙊 contra principia negantem non est disputandum
Super busy, don't expect a timely reply back.
Seismo
Trained
Trained
Posts: 70
Joined: 06 Feb 2010, 17:32

Re: Porting to C++

Post by Seismo »

vexed wrote:FWIW, last I heard, Chojun's code was given to Seismo who is working on a C# version.
While they both have project pages on SF, neither of them have anything in the repo.
I am still working on the c# version. I was under heavy load to finalize my engine all belongs to, now i implement the logic. It is sad, i can not use any line of orginal WZ sourcecode due to its old style. I have to code all new. I use the WZ code only to understand some specific parts like the game internal rules. For a first draft i would like to use the models and textures from orginal, but than i would have a dilemma, i do not want to share my engines source code... So SF seems to be not the best platform for this project and i need new graphic objects too. Oh man, still so many things to do... :augh:
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Porting to C++

Post by Per »

Pumpkin created this game with several people working on it for years, full time. You are going to make it from scratch, alone, in your spare time? Perhaps it is time for a reality check?
Safety0ff
Trained
Trained
Posts: 397
Joined: 18 Jul 2009, 23:23

Re: Porting to C++

Post by Safety0ff »

Per wrote:You are going to make it from scratch, alone, in your spare time? Perhaps it is time for a reality check?
I think he has a better chance from scratch than reusing either old or current code. :lol2:
Seismo wrote:and i need new graphic objects too. Oh man, still so many things to do... :augh:
That will likely be the most time consuming or expensive part, good luck.
Post Reply