![]() |
Retardating scripts, one at a time
Is retardating a word? Let's assume it is.
Just thought I'd share this script I made to convert decimal to hexadecimal, as an example of how retarded I can be. I don't even know what I was doing, or why I was doing it. Then I looked at it and went '... Oh my god.' and created the latter. PHP Code:
PHP Code:
|
You mean you want to show how to optimize / simplify scripts?
Although in this example it would be simpliest to do format("%X",decv) I guess ;) |
Cool, although (I'll probably seem stupid saying this lol) but what use could you use it for? Unless you're just curious to know what a decimal is in hexadecimal value...or for hex editing...
|
Quote:
format() has no practical use. Not to mention it's a waste of time. |
Down with format!
Yes, I made it mainly for hex editting. It's too much trouble to handle conversions with Window's calculator. |
Quote:
|
format(_("%"), ee)
kicks ass |
Quote:
|
Probably was a joke :D
|
I'd use format() but my powers of pure laziness prevent me from learning how to use it... or achieve any actual development.....meh
Development hell sucks ^^ |
Quote:
|
Quote:
How is it anymore useful than using @'s, SPCs, etc? It's not very practical besides for using to shorten the length of some lines of code. It all depends on personal style, since you can argue that either is easier to read. Personally, I find it faster to not use format. If you misplace things while using format, then the outcome won't be that of which you intended, thus making you pay extra attention to where you place things in order for it to work correctly. It's more of a hassle for something that has no real practical use. You get the same outcome in the end. It's not a matter of efficiency, it's a matter of personal choice, thus, making it less practical than you make it to be. Format() was created to simplify code, yet, it's much more of a hassle than simple writing the whole thing out. And, as I stated before, it's not really easier to read considering the fact that if you don't know how to use format, you wouldn't understand anything that that specific line of code was supposed to do. It can be argued either way. |
Quote:
PHP Code:
PHP Code:
|
Quote:
Exactly my point, it's all based on personal preference. In the end, it's the same thing, just one contains a shorter length than the other, but it could be easier for one to edit a line that wasn't using format, rather, @'s and so forth. Format() is fine, it's just not very practical when it wouldn't effect your script efficiency wise if you use it or not. |
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.
|
Quote:
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. |
Quote:
Quote:
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? |
Quote:
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:
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. |
Quote:
Quote:
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? |
Sheesh, Gambet. What is this the 4352356245626th argument you've started in your life?
|
Quote:
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. |
Quote:
|
Quote:
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. |
Quote:
Quote:
|
Quote:
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. |
Quote:
Arguing whether efficiency is the most important criterium is for another thread so I will leave now :mad: |
Quote:
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 08:16 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.