Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Emoji are great

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



ninjeff posted:

The word you posted for 'if' literally means 'case' (the noun). The one for 'while' isn't really considered a word; it's just a verb suffix, like '-ing' in English.

There's a whole list of alternatives, too, if you look under the 'preferred' translation:

なら if, in case
と and, if
もし if, supposing, in case
ならば if, in case
仮令 though, if, even if, although
よしんば if
暁 if

None of those work well enough to be a semi-formal stand-in?

The Gripper
Sep 14, 2004
i am winner

Munkeymon posted:

よしんば if
They should use ば, because it even looks like the word "if"! Problem solved.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


That way lies Programmiglyphics.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Remember back a few hundred years ago how if you wanted to be a serious member of the scientific community, no matter what your mother tongue was, you learned Latin? Let's just go back to that for programmers.

Somehow this thread always comes back to this: Lingua::Romana::Perligata.

welcome to hell
Jun 9, 2006
Damian Conway is a crazy person.

ninjeff
Jan 19, 2004

Munkeymon posted:

There's a whole list of alternatives, too, if you look under the 'preferred' translation:

なら if, in case
と and, if
もし if, supposing, in case
ならば if, in case
仮令 though, if, even if, although
よしんば if
暁 if

None of those work well enough to be a semi-formal stand-in?

That's up to a native Japanese-speaking language designer to decide! I'm just trying to dispel the notion that word-for-word replacements are possible for control structures in general. See Zhentar's post for how the grammar would have to change.

Amarkov
Jun 21, 2010
From the openGL docs:

code:
void glTexImage2D(	GLenum  	target,
 	GLint  	level,
 	GLint  	internalFormat,
 	GLsizei  	width,
 	GLsizei  	height,
 	GLint  	border,
 	GLenum  	format,
 	GLenum  	type,
 	const GLvoid *  	data);

...

border
This value must be 0.
I've seen so many worse things, but there's a neat simplicity to function arguments which have a mandatory and constant value.

Zombywuf
Mar 29, 2008

Flobbster posted:

Remember back a few hundred years ago how if you wanted to be a serious member of the scientific community, no matter what your mother tongue was, you learned Latin? Let's just go back to that for programmers.

Somehow this thread always comes back to this: Lingua::Romana::Perligata.

Suffix based languages with many gramatical moods and where word order is used for emphasis rather than meaning could be an excellent basis for programming languages for people who like to use chained object notation to construct libraries to make code that reads a little bit like English in. If you can rearrange the words to get the same compiled code you can go wild making your code look like poetry.

mjau
Aug 8, 2008

Amarkov posted:

I've seen so many worse things, but there's a neat simplicity to function arguments which have a mandatory and constant value.

It's for compatibility with older versions of OpenGL (pre 3.x). You could pass 1 there to have a border around your texture.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Zombywuf posted:

If you can rearrange the words to get the same compiled code you can go wild making your code look like poetry.

http://www.csse.monash.edu.au/~damian/papers/HTML/Perligata.html

Zombywuf
Mar 29, 2008


Er, yes? That is what I was talking about. (could also do a Finnish version though)

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

Zombywuf posted:

Er, yes? That is what I was talking about. (could also do a Finnish version though)

Oh whoops, didn't see it linked in the quote somehow.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Zombywuf posted:

(could also do a Finnish version though)

make our code ievan polkka

https://www.youtube.com/watch?v=8ySEwZN78nc

tef
May 30, 2004

-> some l-system crap ->
finnish polka? https://www.youtube.com/watch?v=9wVH1kxqT9k

Zombywuf
Mar 29, 2008

Any excuse to post a Lenningrad Cowboys video
https://www.youtube.com/watch?v=j3tKqPWQHkc

Zamujasa
Oct 27, 2010



Bread Liar
php:
<?
if(isset($_REQUEST["some_var"])) $some_var =  mysql_real_escape_string($_REQUEST["some_var"]);

/* ... */ 

$myxml = "<ShitXML Ver = \"1.0.0\">";
$myxml .= "<ShitVar>". $some_var ."</ShitVar>";
/* ... */
?>
Cargo culting at its finest.

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer
I don't think I've ever manually built XML like that, unless you count HTML. But recently I ported (from VB6 to C#) a part of an application that manually generates a particular type of EDI files, and I didn't change the approach at all. :shepface: My code is therefore full of crap like this:

C# code:
string formattedNetProfit = netProfit.ToString("0.00", CultureInfo.CurrentCulture);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("MOA"); // Monetary amount.
stringBuilder.Append(EDIElementDelimiter);
stringBuilder.Append("203"); // Code for item article line after deductions/additions.
stringBuilder.Append(EDIElementPartDelimiter);
stringBuilder.Append(formattedNetProfit); // The amount.
stringBuilder.Append(EDILineDelimiter);
string netProfitSection = stringBuilder.ToString();

Deus Rex
Mar 5, 2005

Zamujasa posted:

php:
<?
if(isset($_REQUEST["some_var"])) $some_var =  mysql_real_escape_string($_REQUEST["some_var"]);

/* ... */ 

$myxml = "<ShitXML Ver = \"1.0.0\">";
$myxml .= "<ShitVar>". $some_var ."</ShitVar>";
/* ... */
?>
Cargo culting at its finest.

i had to make a change to this script (written within the last two months!!) one time

PHP code:
<?
    function getWidget($platform,$name) {
        // returns a string of a JSON object a la the spaghetti code below
    }

    echo '{';
    if (isset($platform) ) {
        echo '"widgets": [';
        if (isset($widgetParam)) {
            $widgets = explode(',', $widgetParam);
            $count = count($widgets);
            for ($i = 0; $i < $count; $i++) {
                echo getWidget($platform, $widgets[$i]);
                if ($count != ($i + 1)) {
                    echo ',';
                }
            }
        } else {
            $dir = opendir('./widgets/'.$platform);
            $file = readdir($dir);
            while (false !== $file) {
                if (4 <= strlen($file) && '.' !== substr($file, 0, 1)) {
                    $woExtension = substr($file, 0, strlen($file) - 4);
                    echo getWidget($platform, $woExtension);
                    if (false !== ($file = readdir($dir))) {
                        echo ',';
                    }
                } else {
                    $file = readdir($dir);
                }
            }
        }
        echo ']';
    } else {
        echo '"error":"Must specify platform"';
    }
    echo '}';

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

LOOK I AM A TURTLE posted:

I don't think I've ever manually built XML like that, unless you count HTML. But recently I ported (from VB6 to C#) a part of an application that manually generates a particular type of EDI files, and I didn't change the approach at all. :shepface: My code is therefore full of crap like this:

I think Zamujasa was calling it cargo-cult because the author begins by using a database escape function, when the data seems not to be destined for a database. Thereby displaying a lack of insight into what the purpose of the escape function is and why it might appear in other code the author had seen.

how!!
Nov 19, 2011

by angerbot

Hammerite posted:

I think Zamujasa was calling it cargo-cult because the author begins by using a database escape function, when the data seems not to be destined for a database. Thereby displaying a lack of insight into what the purpose of the escape function is and why it might appear in other code the author had seen.

This is a case where is would be pertinent to comment why the mysql_real_escape_string is being called. Maybe the XML needs to be escaped that way for a legitimate reason? Without knowing the 'why', the next programmer is bound to think it's an error, remove it, and potentially cause a bug that is very hard to track down. In other words, the horror isn't necessarily the escaping, the horror is not properly commenting the escaping.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

LOOK I AM A TURTLE posted:

C# code:
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("MOA"); // Monetary amount.
why do people name variables like this, it's awful

Impotence
Nov 8, 2010
Lipstick Apathy

Deus Rex posted:

PHP code:
    } else {
        echo '"error":"Must specify platform"';
    }
    echo '}';

Well what did you expect, echo json_encode(array('error'=>'Must specify platform'));?

Golbez
Oct 9, 2002

1 2 3!
If you want to take a shot at me get in line, line
1 2 3!
Baby, I've had all my shots and I'm fine

A Flaming Chicken posted:

Emoji symbols work quite well in Google email addresses on a Mac too e.g foo+emojisymbol@gmail.com

As do they in many other Mac applications!

Doesn't matter too much for gmail, since everything after the + is extraneous. Assuming you meant that literally

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Golbez posted:

Doesn't matter too much for gmail, since everything after the + is extraneous. Assuming you meant that literally

It makes it easy to set up filters :ssh:

You basically get a bunch of different addresses, all of which end up in the same account.

Doctor w-rw-rw-
Jun 24, 2008

Aleksei Vasiliev posted:

why do people name variables like this, it's awful
Not really, unless you'd rather it be strB or something equivalently useless. It's only horrible when you have stringBuilder1, stringBuilder2, etc. Just naming it stringBuilder should be fine so long as the intent of the code isn't mangled. I don't thing MOAAppender would be a good name, for example. What if that changed? Out of context, anyway, it seems kosher to me.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Why not just use sb? Naming it stringBuilder has no positive effect and makes it unreasonably long.

PirateMathew
Apr 22, 2007

The dog is fine in Portugal - that big threat is away - you don't have to worry about crime anymore.

Aleksei Vasiliev posted:

Why not just use sb? Naming it stringBuilder has no positive effect and makes it unreasonably long.

Readability, you don't want to open a file with tons of abbreviated variables wondering what on earth they are used for. Surely some IDE's (like Visual Studio) just tell you what kind of object the variable is, but a ton of others don't.

If you're a solo developer, then by all means abbreviate the living hell out of your variable names, just don't put up others with the pain of trying to figure out what sb is used for.

Lonely Wolf
Jan 20, 2003

Will hawk false idols for heaps and heaps of dough.
sb is perfectly readable for a local variable that lasts all of 8 lines in one scope. It would be terrible for a parameter name or a global variable or anything like that, but saying, in this context, that stringBuilder is more readable is close to absurd.

hobbesmaster
Jan 28, 2008

Lonely Wolf posted:

sb is perfectly readable for a local variable that lasts all of 8 lines in one scope. It would be terrible for a parameter name or a global variable or anything like that, but saying, in this context, that stringBuilder is more readable is close to absurd.

I always use tmp for those variables. If its no longer clear what tmp does, it needs a real name.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Lonely Wolf posted:

sb is perfectly readable for a local variable that lasts all of 8 lines in one scope. It would be terrible for a parameter name or a global variable or anything like that, but saying, in this context, that stringBuilder is more readable is close to absurd.

Have to agree with this guy here.

Bunny Cuddlin
Dec 12, 2004

Lonely Wolf posted:

sb is perfectly readable for a local variable that lasts all of 8 lines in one scope. It would be terrible for a parameter name or a global variable or anything like that, but saying, in this context, that stringBuilder is more readable is close to absurd.

split the difference and call it builder and end this banal argument

Sedro
Dec 31, 2008
Why name it at all?
C# code:
string netProfitSection = new StringBuilder()
    .Append("MOA") // Monetary amount.
    .Append(EDIElementDelimiter)
    .Append("203") // Code for item article line after deductions/additions.
    .Append(EDIElementPartDelimiter)
    .AppendFormat("{0:0.00}", netProfit) // The amount.
    .Append(EDILineDelimiter)
    .ToString();

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Or just skip the StringBuilder entirely as it almost certainly doesn't have a meaningful speed benefit there and is twice as much code.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Seriously, you have a grand total of two actual string concatenations happening, the rest are all constant strings tacked on to other constant strings.

OddObserver
Apr 3, 2009
I am pretty sure Java desugars long String + chains into StringBuilder calls, does C# not do the same?

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

OddObserver posted:

I am pretty sure Java desugars long String + chains into StringBuilder calls, does C# not do the same?

C# doesn't do that, unless I'm hugely mistaken. It converts string concatention into string.Concat calls. Of course, it all falls under the umbrella of "useless micro-optimization".

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
Anytime you're creating a new builder, stuffing things into it, then turning it into a string without having a big loop of appending somewhere in the middle, it's usually pointless.

The correct way to use a string builder is to pass it around and have things append to it directly instead of creating strings themselves.

dizzywhip
Dec 23, 2005

hobbesmaster posted:

I always use tmp for those variables. If its no longer clear what tmp does, it needs a real name.

aughghghhhhhhhhhhhhhhhhh

There is nothing about that variable that makes it more temporary than the average local variable. You might as well call it data or var or stuff or thingy. All of them would be equally descriptive. It is never clear what tmp does based on the name. Even if the defining characteristic of the variable was that it was temporary, it's still not a good name. It's an adjective -- it would be like naming a variable big. I would absolutely never hire anyone who misunderstands the concept of naming things so fundamentally that they name them tmp.

Name things what they are. It's extremely simple. stringBuilder is a perfectly fine name, and if this were an object property or parameter name, it would be the only acceptable name to me (unless there were multiple StringBuilder properties or parameters, in which case the names would need to be made more specific). In this context as a local variable, builder would be fine.

sb is not nearly as bad as tmp, but it's still bad. It might not be that confusing in this particular instance, but if you ever have an abbreviated name that ends up getting used outside the immediate context of where it's declared, people aren't going to know what it is. If I just saw sb by itself I would have no idea what it means because it has no inherent meaning. In contrast I know exactly what stringBuilder means. I'll probably know what builder is too, or at the very least I'll know that it builds something.

If you're really worried about how long it takes to type out stringBuilder, take some typing lessons. And if you're working in an environment without autocomplete you're doing something wrong.

Adbot
ADBOT LOVES YOU

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Gordon Cole posted:

It is never clear what tmp does based on the name.

"tmp" is pretty much the worst name for a variable ever.

Every time I've seen a variable named tmp or temp, the surrounding code has been poo poo.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply