Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Retardating scripts, one at a time (https://forums.graalonline.com/forums/showthread.php?t=70600)

Gambet 12-06-2006 12:34 AM

Quote:

Originally Posted by Stefan (Post 1250601)
Format-strings can be quite hard to read when you have many %s and %d and %+3d and stuff in it, although I often prefer it since it makes it easier for the translation system.



Yeah, and it would confuse the heck out of someone that didn't know what %s, %d, and/or %+3d meant. At least when you write it out the 'longer' way, one can pretty much assume what that line of code is supposed to do based on the fact that it's fully written out and people would be able to use context clues to put two and two together.

Loriel 12-06-2006 01:45 AM

Quote:

Originally Posted by Gambet (Post 1250605)
Yeah, and it would confuse the heck out of someone that didn't know what %s, %d, and/or %+3d meant.

Well, if they understand the rest of my script, chances are they are smart enough to look up what format() does. Also, anyone who has ever read the first chapter of a tutorial on C and probably half of those who read tutorials about C++ know how printf works. Other than that while obviously it is a good thing to not intentionally obfuscate scripts, dumbing scripts down other than for learning purposes is not really something I can get behind.

Quote:

At least when you write it out the 'longer' way, one can pretty much assume what that line of code is supposed to do based on the fact that it's fully written out and people would be able to use context clues to put two and two together.
"Hey, look, a bunch of text with apparently magical symbols that do seem to occur in grammatically interesting places, and a bunch of variables afterwards, and the function is called format, I wonder whether these could be placeholders used to format these variables into the text, and if I am not sure I can still check the documentation!" is close enough for me.

Also if I was not totally ignorant of people who do not bother to learn English yet play on an English server, I would agree with Stefan about the localisation issue because translating lots of string fragments with no obvious logical connection and without the ability to reorder the inserted variables to conform to the target language's grammar gets old really fast.


Apart from that, the whole integer formatting part of format is probably way more powerful than equivalent string concatenation magic. And did anyone ever benchmark format applications against equivalent string concatenations?

Gambet 12-06-2006 02:10 AM

Quote:

Originally Posted by Loriel (Post 1250629)
Well, if they understand the rest of my script, chances are they are smart enough to look up what format() does. Also, anyone who has ever read the first chapter of a tutorial on C and probably half of those who read tutorials about C++ know how printf works. Other than that while obviously it is a good thing to not intentionally obfuscate scripts, dumbing scripts down other than for learning purposes is not really something I can get behind.


How is it dumbing the script down? There is no difference efficiency-wise. No extra lag is caused, or anything that would be a problem. It's simply a different way of writing it.


Quote:

Originally Posted by Loriel (Post 1250629)
Apart from that, the whole integer formatting part of format is probably way more powerful than equivalent string concatenation magic.


How is it more powerful in GScript? It's the same thing. It's not "magic," Stefan made it work like that, thus showing that both ways are acceptable. It's all based on personal preference.

Loriel 12-06-2006 02:32 AM

Quote:

Originally Posted by Gambet (Post 1250637)
How is it dumbing the script down? There is no difference efficiency-wise. No extra lag is caused, or anything that would be a problem. It's simply a different way of writing it.

My point is that format() is often a superior way of writing it:

Quote:

How is it more powerful in GScript? It's the same thing. It's not "magic," Stefan made it work like that, thus showing that both ways are acceptable. It's all based on personal preference.
So how do you print, using string concatenation, an integer in base 8 padded with zeros to a lenght of 8 characters with a sign character in front? How about a float in decimal notation with 4 digits after the decimal point and grouped by thousands with , between them assuming the locale defines that as thousands grouping character?

Further, how about printing the current date either in yy/mm/dd or dd.mm.yy notation based on some internationalisation setting? Are you going to give your translators a bunch of code to edit and then reinsert into your NPCs with if-statements separating the supported languages?

coreys 12-06-2006 02:34 AM

Sheesh, Gambet. What is this the 4352356245626th argument you've started in your life?

Gambet 12-06-2006 02:42 AM

Quote:

Originally Posted by Loriel (Post 1250648)
Stuff


What does this have to do with GScript? My arguments support its function on GScript, considering that's the language that we code in on Graal.

Loriel 12-06-2006 03:10 AM

Quote:

Originally Posted by Gambet (Post 1250655)
What does this have to do with GScript? My arguments support its function on GScript, considering that's the language that we code in on Graal.

I am talking about gscript...?

Gambet 12-06-2006 03:16 AM

Quote:

Originally Posted by Loriel (Post 1250663)
I am talking about gscript...?


How does printing apply to Graal? I probably just misunderstood you.

I don't see how there would ever be an instance where you would need to use format.

Don't get me wrong, format looks a lot more clean, but it just doesn't seem very practical to me, and I'm not the only scripter that thinks this. If there's no point on using it, why use it? Just to make the script seem less cluttered? I guess it depends on what you would consider to be cluttered.


Enlighten me.

Loriel 12-06-2006 03:27 AM

Quote:

Originally Posted by Gambet (Post 1250668)
How does printing apply to Graal? I probably just misunderstood you.

Oh, I mean printing as in outputting text. To chat or RC or strings or whatever.

Quote:

If there's no point on using it, why use it?
I just keep listing reasons to use it, where it is way more elegant, compact and readable than string concatenation. Someone would need to benchmark it, but chances are it is more efficient too.

Gambet 12-06-2006 03:33 AM

Quote:

Originally Posted by Loriel (Post 1250670)
I just keep listing reasons to use it, where it is way more elegant, compact and readable than string concatenation. Someone would need to benchmark it, but chances are it is more efficient too.


But that's exactly what I've said.

It just looks more clean, or 'elegant' as you say. But it makes no difference efficiency wise, which is really what counts. You could argue that format makes script more presentable, but one who prefers to read the elongated version would argue with you.

If there were a clear distinction between the two methods, besides not wanting to format via symbol concatenation, then I would agree that it would be best to use format.

Loriel 12-06-2006 03:45 AM

Quote:

Originally Posted by Gambet (Post 1250672)
But that's exactly what I've said.

It just looks more clean, or 'elegant' as you say. But it makes no difference efficiency wise, which is really what counts.

Not at all. See assembly language versus highlevel languages. Programmer time is more expensive than processor time.

Arguing whether efficiency is the most important criterium is for another thread so I will leave now :mad:

Gambet 12-06-2006 03:53 AM

Quote:

Originally Posted by Loriel (Post 1250676)
Not at all. See assembly language versus highlevel languages. Programmer time is more expensive than processor time.



Considering I hardly ever use format(), I can say that concatenation symbols work a lot faster for me ;)


All times are GMT +2. The time now is 03:26 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.