Author Topic: HUD/Python discussion  (Read 13708 times)

0 Members and 1 Guest are viewing this topic.

Offline mikhael

  • Back to skool
  • 211
  • Fnord!
    • http://www.google.com/search?q=404error.com
Oh, give it up, Kaz. Neither of you seems to have anything substantive to say about it. Its just kneejerk stupidity.

Mik, please reconsider this post in the light of my post immediately following. :) -- Goober5000
[I am not really here. This post is entirely a figment of your imagination.]

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
Quote
Originally posted by mikhael
Yes, it is. Python enforces a consistent indentation patter at the block level. It doesn't matter how you do your indents, so long as they're consistent. This annoys sloppy coders.

This makes people like me, who have to read other people's code a lot, very very happy.
I very much agree with the basic sentiment behind that.  I'm a stickler for clean code formatting - spaces on either side of every operator, newlines between logical segments of code, etc.  Clean code is readable code is easily-debuggable code.

But I vehemently disagree with the way Python enforces it.  It violates one of the fundamental tenets of engineering design: separating form and function.  In order to make code do a particular thing (its function), you have to enter certain coding symbols.  But you should also have the right to arrange your code (its form) in whatever way you see fit.

This is the rationale behind TeX and similar typesetting schemes: you write your content (function) and you design your typeface (form), but you do them separately.  If you need to completely reformat your academic paper in order to submit it to a different conference, you can do it simply by swapping out the current design and swapping in the new one.

It's the same way with formatting.  Different formatting styles are matters of opinion.  Although I very much dislike the Kernigan and Ritchie brace style (and in fact tend to rewrite it in BSD/Allman style if I'm working on it to any significant extent) I can understand the rationale behind using it and support the coder's right to arrange it in the way he wants.  If he wants to enter the Obfuscated C Contest that's fine by me and I will stand by his right to do it.  But I will run his code through a BSD/Allman pretty printer before I even attempt to mess with it. :D

There is a very significant distinction what a coder should do (i.e. make his code readable to others) and what he has the right to do (i.e. design his code however he wants).  In conflating form and function, Python completely steamrollers over that right.

Now that's just the philosophical argument.  The practical argument (whitespace getting corrupted via spaces converting to tabs or tabs converting to spaces) is a whole new argument altogether. :D

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
I 100% agree with Goober5000's assessment - plus using scripting languages in performance-intensive applications targeted at non-scalable archetectures is simply asking to have you system bogged down to next to nill performance.
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Quote
Originally posted by mikhael
Oh, give it up, Kaz. Neither of you seems to have anything substantive to say about it. Its just kneejerk stupidity.

Mik, please reconsider this post in the light of my post immediately following. :) -- Goober5000


Hey, I wish I could edit other people's posts for no other purpose than to give them orders. Such a great use for mod powers...[/sarcasm] :doubt:

That being said, I don't totally disagree with you. I'm plenty annoyed with 'proper' coding styles in languages with {s is to put them so that the conditional is right above the code; IMHO it makes it look cluttered. So I like the freedon to do whatever the hell I want with it.

In fact these days, I tend to use K&R for short conditionals, and BSD/Allman for either branching or long ones.

So when I get to Python, I feel somewhat naked without my lovely braces. :p

However Python does have going for it a simple syntax, that will work for short expressions or longer blocks. Its API documentation is a piece of crap IMHO, but I can compile the code and then run it repeatedly.

It's cross-platform and thankfully the only difference seems to be the libs. It's fairly well-known and popular, so there are a lot of tutorials on how to use it.


To answer Kazan's complaint, I'd like to point out that we already have one scripting language, the SEXP system. But that doesn't seem like it was ever really meant to be edited directly by your everyday modder, nor does it work well for short expressions.

I could hack in hardcoded things like lists and such, but that seems a bit stupid when I can provide the tools to people to do that themselves, and give them a lot more per-mod flexbility in the process.

So, rather than have the SEXP system, an expression system, and a scripting system, you have the SEXP system and one scripting system whose functions can be used for both expressions or logic loops and whatnot.
-C

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
SEXPs are an expression system, not a scripting language - orders of magnitude of complexity difference
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline CaptJosh

  • 210
I have to say that I disagree that it is a basic engineering principle to seperate form from function. And I'm pretty sure both my grandfathers would agree with me, having worked for Hughes Aircraft. The basic form of a missile is integral to its function, and has been since the very first V2 rocket, which was actually the first ever medium range ballistic missile.

There is no reason at all why programming shouldn't follow suit, code parsing correctly being dependent on formatting of that code. As has been observed, it does annoy sloppy coders that Python is this way. You know what? GOOD! Neat code IS easier to debug. Furthermore, IMO, it seems to me that sloppy coding often causes more bugs to be introduced into code simply because it is sloppy. And sometimes is the cause of bugs on its own. I applaud the designers of Python for forcing would-be programmers to make clean clear code.
CaptJosh

There are only 10 kinds of people in the world;
those who understand binary and those who don't.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
i guess il need to study up on my python, any of you coders know a good tutorial off the tops of your heads thats relevant to the way this system will be implemented?
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
CaptJosh: do yourself a favor and STFU

1) Missiles are not programs - aerodynamics is one of the small list of things there form and function are integral to each other - PROGRAM CODE IS NOT
2) nobody gives a rats ass what your grandfathers did, it doesn't make you special, stop talking about it ever seven seconds
3) you're being an attention whore - STOP IT
4) Have you even written code?
« Last Edit: October 18, 2005, 12:00:36 am by 30 »
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
i find the best engineering feats occure when designers reject the established rules and design something totally out of the box. it usually comes out really cool, or becomes a disasterous failure. either way its amusing :D

and josh, stop being an attention whore, theres only enough room for one and the position is already filled :D
« Last Edit: October 18, 2005, 12:14:56 am by 766 »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Kamikaze

  • A Complacent Wind
  • 29
    • http://www.nodewar.com
Thanks for showing your lovely tact yet again Kazan.

I like the idea of python for scripting (though to be honest I like ruby better). Python's a well thought-out language that's easy to read and has a rich feature set.

BTW: There are many examples of successful games (some of them far more resource intensive than FS2) that have used scripting languages. Homeworld 2 uses lua all over the game. Heres's a blurb from the lua site about it:

Quote
Homeworld2 is a space PC RTS game that uses Lua4 extensively in almost every aspect of the game, including the UI, AI, game rules, game flow, stats, game attributes, game tuning and automation.
Science alone of all the subjects contains within itself the lesson of the danger of belief in the infallibility of the greatest teachers in the preceding generation . . .Learn from science that you must doubt the experts. As a matter of fact, I can also define science another way: Science is the belief in the ignorance of experts. - Richard Feynman

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Lua is supposedly faster than Python, it's also used in Far Cry, and the examples on wikipedia didn't look too bad.

It's pretty similar to python actually.

I think Ruby is somewhat more complex, though; Python is about as simple as I can see a programming language getting while still being efficient.

I don't have experiene with either Lua or Ruby tho.

Edit: But at this point, I'm strongly biased towards Python because I know it's usable & I have the majority of the needed stuff implemented.
« Last Edit: October 18, 2005, 12:34:12 am by 374 »
-C

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
Kamikazi: i have a low tolerance for repeated expressions of Narcassitic Personality Disorder

if you hadn't notice he's been doing that in thread after thread after thread.
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 
Kazan: You post for attention as well. Get the personal issues worked out in PM please, this is a rather important discussion IMHO. If the wrong langauge ends up implemented, WMC will have done a lot of work for naught, and you'll be stuck with a lot of old code in CVS you don't need/use.


As for languages: I can see the argument on whitespace having a meaning to the compiler, and I agree with Goober on that. On the other hand, aside from the whitespace issue, is there another argument against Python?

EDIT: I just thought of something; If people are absolutely demanding braces, I can write a program that goes from braces to tabs for a large block of code in about 8 lines in PHP. C would be a bit longer, but still doable. So there would be the option of using braces, but still Python for the rest of the code. It might be liable to some bugs due to translation, but  I doubt that there'd be many.
just another newbie without any modding, FREDding or real programming experience

you haven't learned masochism until you've tried to read a Microsoft help file.  -- Goober5000
I've got 2 drug-addict syblings and one alcoholic whore. And I'm a ****ing sociopath --an0n
You cannot defeat Windows through strength alone. Only patience, a lot of good luck, and a sledgehammer will do the job. --StratComm

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
You just have to take into account the various ways to put the brackets: http://en.wikipedia.org/wiki/Indent_style

but it sounds like a plan.

Keep in mind that Python syntax is like:

Code: [Select]
#Check if (name) is in the current channel/context
def inChannel(name):
userlist = xchat.get_list("users")
if userlist:
for i in userlist:
#Add any reclaimers we missed
if isReclaimerName(i.nick) and not isReclaimer(i.nick):
xchat.command("whois %s" % i.nick)
if xchat.nickcmp(i.nick, name)==0:
return True
else:
dMsg("Unable to load userlist")
return False


(That is from my IRC bot, if anyone is wondering)

It'd be nice if it could preserve linenumbers just in case :nervous: (ie insert a blank line where a bracket was)
-C

 

Offline aldo_14

  • Gunnery Control
  • 213
Interesting.  Very HLL.

Although the # comments would surely get on my tits after a while.

I don't think CaptJosh is making a bad point in terms of code readability being a good thing; I think maybe you're thinking at cross purposes here, though.  

From what I read here, the primary objection to Python is not to do with forcing readable code (is such a thing even possible), but in forcing a restrictive code structure/formatting that may be counter-intuitive and ultimately irritating (I've never even looked at python myself, so I can't evaluate personally).  This is not to do with wishing to be a 'sloppy' coder, but simply to work within the most comfortable personal format (and hence the most efficient/effective one).

To me, readability is not synonymous with a particular format, but more simple conventions; meaningful variables, proper commentary.
EDIT; (etc)

In either case, drawing an analogy with missiles is IMO not valid.  Because with a missile, the physical form affects performance; this is not true for programming - any non-trivial code will be able to be written in a large amount of  (perfectly readable) different formats, without that difference affecting performance.

(that's entirely aside from the functional aspects of abstraction & decoupling, which I'd expect to be outside the scope of the scripting being discussed here, but are another significant difference from 'physical' engineering)

Oh, and enforced tabulation can sometimes, in my experience, hurt readability anyways, particularly if enforced in a non-intuitive way (try - catch blocks come to mind).

I'm firmly on the fence vis-a-vis python, though, given my never having used it.  If it's chosen, I'll adapt.  If not....well, I'll adapt to whatever else is used :D
« Last Edit: October 18, 2005, 09:48:31 am by 181 »

 

Offline Goober5000

  • HLP Loremaster
  • Administrator
  • 214
    • Goober5000 Productions
All right, calm down you guys.  Kazan, while I agree with you, you could have said that with much more tact.

CaptJosh, you're confusing two definitions of the word "form".  A missile's "form", i.e. its shape, is part of its function - it has to have certain aerodynamic properties.  Because it is integral to the design of the missile, it does not fall under the engineering definition of "form".  So your first paragraph is incorrect.  As for your second paragraph, that was addressed previously.

EDIT: Yeah, I see aldo also addressed the missile thing.  What he said too. :)

 

Offline FireCrack

  • 210
  • meh...
Yeah, "form" if applied to a v2 missile would likely be whatever is painted on it...


And i agree abnout pythion, consistency is good, but evrey now and then you have somthing that would look better or be more readble in a different format.
actualy, mabye not.
"When ink and pen in hands of men Inscribe your form, bipedal P They draw an altar on which God has slaughtered all stability, no eyes could ever soak in all the places you anoint, and yet to see you all at once we only need the point. Flirting with infinity, your geometric progeny that fit inside you oh so tight with triangles that feel so right."
3.141592653589793238462643383279502884197169399375105820974944 59230781640628620899862803482534211706...
"Your ever-constant homily says flaw is discipline, the patron saint of imperfection frees us from our sin. And if our transcendental lift shall find a final floor, then Man will know the death of God where wonder was before."

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Exactly. In the missile analogy its form is what colour you've painted it, not the shape of the missile.

I never knew that Python made whitespace demands on you. Just thinking about the amount of problems you can get from people cutting and pasting code is more than enough to scare me off it.

*Looks at all the posts detailing table problems. Imagines how much worse they'd be if whitespace mattered.*
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline aldo_14

  • Gunnery Control
  • 213
Good point. :shaking:

Although if the compiler detects it, why can it not auto-correct it?  Or is the nesting solely controlled by ws?

 

Offline CaptJosh

  • 210
Point taken on form vs. form. I guess I'm forever a hardware type. *smiles wryly* As far as coding, the most I can say I've done is HTML and mIRCscript.

I used to code all in one big blob of HTML. For all of about two attempts. It stopped when I realized that even I couldn't find any thing in my own HTML. I started formatting it with gloups of two spaces, initially, then moved on to using tabs, as it was faster, and made sections more distinct. I'm a big fan of W3C compliance in HTML, as well. When w3c standards are used, it's virtually impossible for a page to be readable in one browser but not in another.

That said, I'm going to be learning C++ as soon as I can. I have some things I'd like to do vis-a-vis porting some stuff from one game to another and I need to learn this so I can do that.


Finally, Kazan, I posted because I thought I had something to contribute. If you don't like my contribution, refute or rebut it in a civilized manner. If you can't do that. I suggest you sit on your hands until you can respond to me without the use of ad hominem attacks.
CaptJosh

There are only 10 kinds of people in the world;
those who understand binary and those who don't.