Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old June 11, 2011, 23:33   #1
Bahman Rabii
Scout
 
Join Date: Jun 2011
Posts: 31
Bahman Rabii is on a distinguished road
Current thinking around the development language

Hi folks,

What is the current thinking around the future of the development language for Angband? I argued more than five years that straight C is not a suitable choice for the large amount of high-level code in Angband. Even without a major rewrite, it is would be possible to allow limited use of selected C++ features.

I am not planning to get involved in development in the foreseeable future, so please take this question as friendly curiosity. I am not volunteering/asking permission to do a pilot program.

FYI:

What put this back in my mind was the observation that Google's protocol buffer format would make an excellent replacement for the edit-file ascii format used in Angband, but that protobuf only works in C++, Java, and Python.

I use protobuf at work and it is a much stronger solution writing a custom parser. It is also nicer than XML for a few reasons: it has a nice compact ascii format, it handles typed data much better, and the programmatic APIs are good enough to use the parsed data structures directly without moving them into a different in memory representation.

This would also be nice for savefiles.

If you are curious there are more docs: http://code.google.com/apis/protocol.../overview.html
Bahman Rabii is offline   Reply With Quote
Old June 12, 2011, 00:45   #2
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 39
Posts: 1,516
d_m is on a distinguished road
Quote:
Originally Posted by Bahman Rabii View Post
What is the current thinking around the future of the development language for Angband? I argued more than five years that straight C is not a suitable choice for the large amount of high-level code in Angband. Even without a major rewrite, it is would be possible to allow limited use of selected C++ features.
I think we have stuck with C mostly because no one really wants to write C++

To be less glib--I personally like the idea of using something like Python, but I'm not sure that I have the energy/willpower to port the exact Vanilla Angband gameplay (and front-ends) over to Python. I'd probably just build an independent game inspired by Angband.

I think only real way that the Vanilla codebase escapes C is if it can be modularized and then controlled (at a high level) from something like Python or Lua (I like Python a lot, I think many of the devs like Python and/or Lua). This was attempted earlier with Lua but didn't take. I think someone (Sirridan?) on oook started writing porting Angband to Python from scratch, but AFAIK it stalled out.

DarkGod has written Tome4 entirely in Lua so it's clearly possible (although I think it required abandoning much of Tome2-3 to get there).
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 12, 2011, 01:08   #3
Bahman Rabii
Scout
 
Join Date: Jun 2011
Posts: 31
Bahman Rabii is on a distinguished road
Quote:
Originally Posted by d_m View Post
I think we have stuck with C mostly because no one really wants to write C++
I got a similar reaction 5 years ago, and I still don't understand the level of antipathy for C++ in this community. I do not recall hearing any specific reasons.

Just allowing classes and STL would probably reduce the size of the angband codebase by 15-20%, while improving readability.
Bahman Rabii is offline   Reply With Quote
Old June 12, 2011, 02:18   #4
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,936
Donated: $40
takkaria is on a distinguished road
I'd say there are a bunch of reasons. The easiest one is that not all the devteam code in C++ and switching to a new toolchain and language would be a big disruption. I understand that we could refactor stuff in C++ to be more efficient and have fewer lines of code but we're largely doing that already without needing to switch language, and we have collectively a better grasp of C idioms than we do of C++. It would also break variant portability.

I think another factor is that the bigger issues with the code are structural ones; stuff like bare array accesses using numeric indexes, or rewriting the UI code to handle tiles as first-class citizens of the display rather than as a pretend terminal character. These things aren't fixed or become any more fixable in C++, they can just be fixed differently and switching language would IMO be a distraction from actually sorting them out, especially given that the devs don't know C++.

In short, I don't think the disruption would be outweighed by the gains, though personal preference obviously comes into it too.

As to parsers for edit files: we have a consistent and clear API for parsing in modern V (see parser.c and most of init2.c); the format may not be perfect but the opportunity cost of changing format is high compared to its marginal gain (which may well be a loss, since cross-variant portability would go out the window even if we had a better format).

As to savefiles, modern V has a nice versioned and chunked savefile format which allows a lot more flexibility than the old code did along with better indicators of where savefile loading and saving is failing. Having rewritten the savefile code a couple of times for unreleased variants and seen the effort put into an abortive rewrite by one of the V developers, I have learnt that it too has a high opportunity cost and incremental change worked out to be the best strategy given the small gains made from wholesale replacement.
__________________
takkaria whispers something about options. -more-
takkaria is offline   Reply With Quote
Old June 12, 2011, 02:53   #5
Bahman Rabii
Scout
 
Join Date: Jun 2011
Posts: 31
Bahman Rabii is on a distinguished road
Fair points. I think I have fairly strong counter arguments to all of them, but since I am not in a position to contribute the work, it is a moot point.
Bahman Rabii is offline   Reply With Quote
Old June 12, 2011, 08:13   #6
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Bahman Rabii View Post
but since I am not in a position to contribute the work, it is a moot point.
I think this is the reason behind a lot of suboptimal outcomes in a lot of FOSS projects. If there was a driving personality on the devteam who loved C++ and was willing to mentor me in it, I would happily assist with conversion, and I suspect others would too. (Ditto to switch to Python, or anything else that would ultimately be better than C.) But no such person has stepped up, and those with the time to contribute don't have the knowledge or inclination to switch language. It's just so much easier to improve what's there than to start over - as Sirridan found out with the Python attempt, ditto the author(s) of Java Angband all those years before.

How DarkGod found the time/dedication to rewrite ToME4 almost from scratch I have no idea.
Magnate is offline   Reply With Quote
Old June 12, 2011, 12:01   #7
Antoine
Ironband/Quickband Maintainer
 
Join Date: Nov 2007
Posts: 1,008
Antoine is on a distinguished road
Quote:
Originally Posted by Magnate View Post
It's just so much easier to improve what's there than to start over - as Sirridan found out with the Python attempt
Is that project officially dead, or just gone quiet?

A.
__________________
Ironband - http://angband.oook.cz/ironband/
Antoine is offline   Reply With Quote
Old June 15, 2011, 00:36   #8
Chud
Swordsman
 
Join Date: Jun 2010
Posts: 286
Chud is on a distinguished road
I have toyed on and off with the idea of a Java version... but each time a voice in the back of my head mutters "you think you have *how many* free hours these days??"

Mostly with an eye toward the graphics and window management stuff, which I am always bad at (though I imagine it's easier in java than in C...)

Chud is offline   Reply With Quote
Old June 15, 2011, 00:42   #9
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,920
Derakon is on a distinguished road
And I'd love to see it rewritten in Python, my favorite language these days, but similarly lack the time. Oh, well...
Derakon is offline   Reply With Quote
Old June 15, 2011, 05:49   #10
Therem Harth
Knight
 
Therem Harth's Avatar
 
Join Date: Jan 2008
Location: New England winter
Posts: 921
Therem Harth is on a distinguished road
I think part of the problem is that Angband is not structured like a program written in a higher-level language would be (or rather, should be). Python Angband *might* be doable without a complete from-scratch rewrite, but it would be very ugly and probably hard to maintain. Java Angband would require a rewrite, as the entire procedural coding style is just not usable in Java.

(Well, I suppose you could rewrite most of the Angband source files as abstract classes full of static methods... I probably ought to be smacked for thinking of that, though.)
Therem Harth is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Translate Angband 3.1.0 to other language hernaldo Development 35 July 25, 2010 13:52
Re-thinking detection... buzzkill Vanilla 7 June 10, 2009 09:20
Morgothian programming language zaimoni Idle chatter 2 April 22, 2009 10:26
Angband and language tigpup Idle chatter 1 February 1, 2009 13:53
C Language momo125 Vanilla 11 February 27, 2008 09:30


All times are GMT +1. The time now is 03:04.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.