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
Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Does it count if the language itself is horrifying?

http://xplusplus.sourceforge.net/

quote:

Superx++ is an object-oriented language that is entirely based on XML's syntactical structure. Superx++ conforms with the XML version 1.0 specification as published on the W3C web site. Programming in XML itself has great potential and Superx++ pushes the envelope!

Class test code and its output
Array test code and its output

I found this from Category:XML-based programming languages.

Adbot
ADBOT LOVES YOU

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Orzo posted:

I'm not an IE apologist by any means, but this issue is not as simple as 'they were caught cheating' and it's irresponsible to state that as if it were true.
How about "specifically optimizing for SunSpider"?

Their dead-code analysis is in theory general-purpose, but is in practice A) incredibly fragile, and B) oddly works very well on SunSpider.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Hammerite posted:

So the planned remedy for this is to

1) Use PHPass which uses bcrypt; see here and here.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Sun's tutorial for commandline password masking.

Skip to the Making the Code Secure and Reliable section, since their original code used immutable strings to store the entered password.

Their "Reliable" code uses a second thread to go back and attempt to overwrite each character as it is entered with an asterisk. This fails if
* The user types fast
* The thread is running slow
* You're at the end of the current line in the terminal
* You paste a password (entire password minus last character is revealed)
* You press the left arrow key then press delete (entire password minus one character is revealed)

It also has an extra asterisk in the prompt.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Zombywuf posted:

The bug is in the double parser that iteratively approximates the correct value which doesn't work at MAX_DOUBLE. Rasmus decides that the problem is "compiler switches".
the issue is only on 32-bit, because PHP uses 80-bit floats on 32-bit systems, but 64-bit floats on 64-bit systems. It can be fixed with compiler switches, but they aren't exactly the problem.

And apparently they didn't think to check "can we improve this number's error any further?" instead of just while(error > 0.05)

It's fixed in SVN so I'm wondering what horrifying method they used to "fix" it.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
So is volatile in php magical? I am confused as to how this "fixes" the hang-on-certain-float bug.

Edit: Instead of blaming PHP programmers, they are blaming a design flaw in the x87 FPU.

Malloc Voidstar fucked around with this message at 04:21 on Jan 5, 2011

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Scaramouche posted:

If it was x87's fault wouldn't this... be an issue in other languages? Ditto for compiler switches?
It's a hardware issue in the same way PHP's == operator being bizarre and terrible is a programmer issue

That is to say, it isn't a hardware issue.

It doesn't happen without x87, but it also wouldn't happen if the PHP devs were competent.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

gastownlabs posted:

Minecraft has sold 1 million copies. Making every algorithm O(1) is not more important than shipping.
The game is literally unplayable on some high-end computers, for absolutely no reason other than lovely code.

A game with a nearly non-existent physics engine, using 16x16 textures, should be able to run on just about everything.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

ryanmfw posted:

Hey, not really defending poo poo coding, just arguing that poo poo coding isn't always about profit. It sucks that your netbook can't play 3D games but neither can mine, suck it up.
Notch is literally de-improving the game when he releases patches. He adds bugs that are bad enough to make the game Not Fun.

He can code fast, was inspired by a good idea, and has legions of autistic fans. That's all he has going for him.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

qntm posted:

When in history has anybody charged money for an alpha release of something? In fact, when has an alpha release ever been made available to the general public?
For the first: Natural Selection 2. Its alpha was available to pre-orderers of the special edition.

But it looks like this and is running on their own proprietary engine, so they kind of needed the money. Also they are constantly fixing bugs, whereas Notch will release a game-breaking patch and then go to sleep. (Patches are silent and automatic on launch)

Unknown Worlds is essentially doing the same thing Notch is, except they're producing a far more complex game with less money. And doing a much better job of it.


Minecraft: Making every thread mentioning it into a Minecraft thread since 2010.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

ErIog posted:

You're gonna need to provide a source for this because I'm seeing that Unknown Worlds has received 2 rounds of outside investment plus whatever Zen of Sudoku made plus whatever pre-orders for NS2 make. They've also been working on NS2 for about 3 years at this point. You're comparing 2 very different games at two different stages of development with two very different budgets.
6 months before the alpha was released, they had $220,000 from preorders and $500,000 from investors. 4 months after the alpha was released they went to closed beta. So the alpha was developed on less than a million dollars. The entire game engine is their own code and deals with rather high quality graphics.

Minecraft, on the other hand, has sold one million copies. And is still in alpha. And is still commonly unplayable. And still often has new game-breaking bugs introduced. Notch does no real private testing other than "It mostly works on my computer." (NS2 has builds internally tested by the devs and some players before they are released to all the closed beta members)

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
http://thedailywtf.com/Articles/Confessions-The-Shopping-Cart.aspx

quote:

The project called for a shopping cart and, after reading a 30 minute "getting started" guide on SQL, I created my first database. I figured a Shopping Cart is a logical unit of data, and as such deserving of its own table. And since each Shopper had their own shopping cart, they should also have their own Shopping Cart table.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Alternatively, consider using the WCF Integration Pack for Enterprise Library. It contains classes that you can use directly to enable storage of and access to the container in WCF applications, and it can be used to automatically populate dependencies in your classes.


Forward-thinking documentation.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Mustach posted:

Despite being totally harmless, whenever I see a parenthesized return expression, I feel that it's a very telling instance of bad style.
I like adding extraneous parentheses to lines like return ((((m-1)/t)*t)*((((((m-1)/t)*t)+t)*10)/(t*2)))/10; since that looks better to me than having naked numbers/whatevers like in this example. Cosmetic.

Edit: But return(stuff); is just weird.

Malloc Voidstar fucked around with this message at 21:50 on Jan 23, 2011

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

NotShadowStar posted:

Pretty sure you'd need UAC elevation to do that, since changing the same properties in the Control Panel asks for UAC access.
Obviously he should inject into explorer.exe, then.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Munkeymon posted:

explorer doesn't run elevated by default :confused: - at least not that I can see?
It's on the hardcoded UAC whitelist, which means injecting into it bypasses UAC on the default Windows 7 level of security (doesn't affect Vista)
That code was released during the beta and still works on a fully-patched W7 system.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Wanted to add a stemmer to a small program I'm writing. (A stemmer reduces words to their stem; "writing" becomes "write")

Used Apache's modification of the generated Java version of the Snowball Porter2 stemmer. (Snowball code here)

It worked fine, but then I decided to look at the Java code and :gonk:

The Snowball->Java compiler apparently writes everything as labeled while(true){} statements or do {} while (false); statements.
code:
                    v_9 = limit - cursor;
                    lab11: do {
                        // call Step_2, line 220
                        if (!r_Step_2())
                        {
                            break lab11;
                        }
                    } while (false);
                    cursor = limit - v_9;
                    // do, line 221
                    v_10 = limit - cursor;
                    lab12: do {
                        // call Step_3, line 221
                        if (!r_Step_3())
                        {
                            break lab12;
                        }
                    } while (false);
                    cursor = limit - v_10;
And sometimes doesn't understand the concept of arrays.
code:
        public boolean stem() {
            int v_1;
            int v_2;
            int v_3;
            int v_4;
            int v_5;
            int v_6;
            int v_7;
            int v_8;
            int v_9;
            int v_10;
            int v_11;
            int v_12;
            int v_13;
Pastebinned code

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Qwertycoatl posted:

Treating generated code as anything other than an object file is a horror itself. You're not supposed to read it, so it's fine for a generator to make life easy on itself with stuff like do { ....} while (false) and whatever.
Apache modified it to eliminate reflection, and use an abstract class instead, so the real horror here is... Apache

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
the comments

skip += blksize; //skip = skip + blksize

:negative:

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

pseudorandom name posted:

What, four spaces instead of a (8 space, as is right and proper) tab?
code:
for ( eof = 0, skip = 0; ; )
{
    for ( numchar = 0; numchar < blksize; numchar += n )
    {
        n = read( fdin, &buf[ numchar ], blksize - numchar );
        if ( n < 0)
            err_sys("read error");
        if ( n == 0 )
        {
            eof = 1;	// end of file
            break;	// if n = 0 terminates the execution the nearest loop
        }
    }
if ( numchar == blksize )
{ 
does this help demonstrate

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
no, you fool, don't you remember what happened the last time somebody posted Minecraft code in here?!

but anyway
code:
// in LoginForm.class of the Minecraft launcher
private Cipher getCipher(int mode, String password) throws Exception {
    Random random = new Random(43287234L);
    byte[] salt = new byte[8];
    random.nextBytes(salt);
    PBEParameterSpec pbeParamSpec = new PBEParameterSpec(salt, 5);

    SecretKey pbeKey = SecretKeyFactory.getInstance("PBEWithMD5AndDES").generateSecret(
            new PBEKeySpec(password.toCharArray()));
    Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
    cipher.init(mode, pbeKey, pbeParamSpec);
    return cipher;
}
that's what encrypts/decrypts the lastlogin file that stores the user's username and password

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

zootm posted:

This is apparently a method which can return a varied number (using the Random) or a constant depending on what type of block (allegedly what the class represents) it is. It's sadly not a coding horror.
Provide a public static Random in some class, refer to it if needed?

Edit: aw what the gently caress

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
Did RIM do the Joel Spolsky thing and use an intern who didn't know Java or the language he was working in in order to write a JVM that bad?

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Scaevolus posted:

It's probably a straightforward interpreter, with zero optimization:
But in what possible world would "Strings that can never be changed/reassigned are slower than Strings that can" make sense?

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
mysql> select aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy');
+-------------------------------------------------------------------------------------+
| aes_encrypt('hello', '') = aes_encrypt('hello', '4re35na2aTaVasAy4re35na2aTaVasAy') |
+-------------------------------------------------------------------------------------+
|                                                                                   1 |
+-------------------------------------------------------------------------------------+


http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.5/view/head:/mysys/my_aes.c

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
*key is a pointer to the password
rkey is an array of length 16 (AES_KEY_LENGTH = 128, /8 = 16. see my_aes.h for the define)
rkey is the actual key that will be used to encrypt/decrypt

  for (ptr= rkey, sptr= key; sptr < key_end; ptr++,sptr++)
  {
    if (ptr == rkey_end)
      ptr= rkey;  /*  Just loop over tmp_key until we used all key */
    *ptr^= (uint8) *sptr;
  }


sptr = the password pointer

it first zeroes the realkey, if the given password is 0-length then it's done creating the realkey, the loop doesn't run

if not, then it will iterate through the realkey[16] for as many bytes as there are in the password, XORing as it goes. that's this line: *ptr^= (uint8) *sptr;.( ^= is XOR-assignment). if it hits the realkey's end, then it will reset to the beginning of the array. the password index is not changed.

did this help


(also I'm a Java programmer so my explanation might be totally wrong :v: )

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
code:
private static void vehicle(String arg) {
	String vehicle;
	vehicle =  ( ( arg == "B" ) ? "bus" : 
		     ( arg == "A" ) ? "airplane" : 
		     ( arg == "T" ) ? "train" : 
		     ( arg == "C" ) ? "car" : 
		     ( arg == "H" ) ? "horse" : 
		     "feet" );
	System.out.println(vehicle);
}
vehicle("T");
train


php:
<?
$arg = 'T';
$vehicle = ( ( $arg == 'B' ) ? 'bus' :
             ( $arg == 'A' ) ? 'airplane' :
             ( $arg == 'T' ) ? 'train' :
             ( $arg == 'C' ) ? 'car' :
             ( $arg == 'H' ) ? 'horse' :
             'feet' );
echo $vehicle;
?>
horse


:buddy:

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

GrumpyDoctor posted:

What's wrong with ternary chaining?
It's commonly abused.

but it is useful if the language you are working in doesn't support if-else or switch

# Create spatially interpolated bob-clips
dbob = clp.bob(0,0.5)
edi  = (EdiMode=="NNEDI2") ? defined(edeint) ? (border) ? edeint.pointresize(width(o),height(o)+8, 0,-4,-0,height(o)+8.001 ) : edeint : clp.nnedi2(field=-2)
 \   : (EdiMode=="EEDI2")  ? clp.SeparateFields().EEDI2(field=-2, maxd=EEDI2maxd) 
 \   : (EdiMode=="Yadif")  ? clp.Yadif(mode=1)
 \                        : dbob

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

bobthecheese posted:

Most of the problems with php are, as you said, pretty much centred on people not reading the available documentation
Also that PHP's developers are incompetent

http://bugs.php.net/bug.php?id=32100
'You don't need finally blocks, just don't handle your exceptions, not a big deal'

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

NotShadowStar posted:

White people drive like THIS, black people drive like THIS.
And Asian people can't drive at all.

(php programmers === asian people)

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

tef posted:

(ie the coding horror is you)
we obviously need a Coder Horror thread
for example:
https://groups.google.com/group/microsoft.public.win32.programmer.kernel/browse_thread/thread/6326c306e22e05bb/c0fee26e301bbcf2
wherein a programmer decides to use 32-bit Windows process IDs as 16-bit indexes to a flat array and refuses to listen to everybody saying "what, no"

quote:

Obviously I can't disclose the underlying motivation but suffice to say it has reduced a small CPU intensive bottleneck in an area that is otherwise impossible to address, we are seeing a 50% drop in CPU on an operation that is small but performed frequently in our case.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
I don't think this is really a horror but it's horribly ugly to me so whatever

I'm converting the subtitles of TED Talks, which is in this JSON structure:
http://www.ted.com/talks/subtitles/id/1032/lang/eng

Using Google Gson to deserialize that:
code:
Gson gs = new Gson();
Type type = new TypeToken<Map<String, List<Map<String, String>>>>(){}.getType();
Map<String, List<Map<String, String>>> raw = gs.fromJson(jsonSubString, type);
List<Map<String, String>> subs = raw.get("captions"); // actual List of the subtitle objects
too many angle brackets :(

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
http://jtcfrost.svn.sourceforge.net...in&pathrev=2865

I'd better comment this out in case anyone needs it later!

*Commits code to SVN repo*

:downs:

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
I don't like HTML5 because it's a living standard. :colbert:

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
I'm mad about markup

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Mustach posted:

Can we all agree that (X)HTML, XML, and the W3C are terrible?
the WHATWG is worse than the W3C. an unversioned standard that changes without notice? what a great idea

also, gently caress Java with its decade old bugs: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4414164

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Otto Skorzeny posted:

Also if Perl-Compatible Regular Expressions were anything but a subset of the regexes that Perl supports, something is horribly wrong
Apparently PCREs are a subset of Perl regexes, but Perl only supports a subset of PCRE settings.
why would you do that

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
code:
loop0:  for (;;) {
      switch(state){  
      case c0_top:
        dindex =  (((((int) ((0x21) * ((((((((int)((in[ip+1+2+1] & 0xff) << (6)) ^ (in[ip+1+1+1] & 0xff) << (5)) ^ (in[ip+1+0] & 0xff) << (5)) ^ (in[ip+0] & 0xff))))) >> 5) & (((1 << (14)) - 1) >> (0))) << (0)))));
it is vitally important that this be one line!!!!

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Volte posted:

That looks like generated code to me.
https://code.google.com/p/java-compress/source/browse/src/org/jvcompress/lzo/MiniLZO.java#137

It's not generated code, it's a partial port of MiniLZO from C.

Adbot
ADBOT LOVES YOU

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Zombywuf posted:

Look at the graph for the part before the Perl one goes crazy. It's orders of magnitude slower for the non pathological case.
Important note: The Perl graph's y-axis is seconds, the Thompson NFA's y-axis is microseconds.

Also see:

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