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
Optimus Prime Ribs
Jul 25, 2007

darthbob88 posted:

in a final product that would, he assures me, make us zillions of dollars if I just do the backend work for him.

He wanted you to work for free, and only compensate you after its success, didn't he?

Adbot
ADBOT LOVES YOU

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Haud posted:

code:
if(x == 0)
   //Do Nothing
else
   DoSomething();

I actually like this style a lot when there are multiple interesting cases (i.e. at least one 'else if'). Sometimes you want to make sure some case doesn't fall through any of the following checks; repeating the logic in the guards for those blocks is expensive, redundant, and exclusive of using 'else'.

That is, I claim it's better to have:

code:
if (summoners.empty() || !hasBook || !hasCandle) {
  // do nothing
} else if (summoners.size() == 1) {
  // Only one summoner;  use the Rite of Kae Pum Ix An.
  ...
} else {
  // Multiple summoners;  use the Rite of Kaer Cham Ix Anu.
  ...
}
Than:

code:
if (summoners.size() == 1 && hasBook && hasCandle) {
  // Only one summoner;  use the Rite of Kae Pum Ix An.
  ...
} else if (summoners.size() > 1 && hasBook && hasCandle) {
  // Multiple summoners;  use the Rite of Kaer Cham Ix Anu.
  ...
}
I mean, usually I would just structure this so that I can use an early return/break/continue/goto/resume-continuation/abort/hlt instead of chaining the conditions, but sometimes life gives you lemons.

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

darthbob88 posted:

Is it cool to talk about terrible ideas here? Because a colleague/relation of mine had a brilliant idea to create a StackOverflow-type site, where the users post a poll with their question, "Which answer is right?". Other folks vote on that poll and by the Wisdom of the Group truth shall emerge and the best answer will win out, and those who voted for the correct answer get karma/rep for being right or just agreeing with the most people, which gives them more weight in any further polls they vote on. It would combine all the wisdom of Stack Overflow with the democracy of Reddit, in a final product that would, he assures me, make us zillions of dollars if I just do the backend work for him. Additional problems include the obvious fact that many users won't have a good idea as to what the truth is, and the old Put down the chocolate covered banana situations. I do like that phrase.

Incidentally, this same dude thought the Unix Millennium bug could be solved by replacing the ints everywhere with doubles, because they have a larger range. :eng99:

It sounds like a terrible idea, but it wouldn't be the first terrible idea to make zillions of dollars. (Doesn't Stack Overflow already have voting on answers? That seems to be the key element of this guy's idea.)

Tinestram
Jan 13, 2006

Excalibur? More like "Needle"

Grimey Drawer
code:
var y:Number = this.y;

Munkeymon
Aug 14, 2003

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



prefect posted:

It sounds like a terrible idea, but it wouldn't be the first terrible idea to make zillions of dollars. (Doesn't Stack Overflow already have voting on answers? That seems to be the key element of this guy's idea.)

On SO, the person who asks the question gets to pick the 'correct' answer which gets top billing in the answer list no matter what anyone votes for. Yeah, I put the word in quotes for the reason think I did.

tef
May 30, 2004

-> some l-system crap ->
it sounds like an algorithmic circle jerk :q:

Lysidas
Jul 26, 2002

John Diefenbaker is a madman who thinks he's John Diefenbaker.
Pillbug

tef posted:

it sounds like an algorithmic circle jerk :q:

So is that like dining philosphers

darthbob88
Oct 13, 2011

YOSPOS

prefect posted:

It sounds like a terrible idea, but it wouldn't be the first terrible idea to make zillions of dollars. (Doesn't Stack Overflow already have voting on answers? That seems to be the key element of this guy's idea.)

That's another part of why it's terrible; he wants to start it on StackExchange, in direct competition with Stack Overflow. But his idea would win because it's the better choice. Free Market and all that.

Optimus Prime Ribs posted:

He wanted you to work for free, and only compensate you after its success, didn't he?
Dunno, I opted out before the issue of any kind of compensation came up. I've already got a pretty awesome job (:D), so I don't need to take on any more outside work.

Munkeymon
Aug 14, 2003

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



darthbob88 posted:

That's another part of why it's terrible; he wants to start it on StackExchange, in direct competition with Stack Overflow. But his idea would win because it's the better choice. Free Market and all that.

Wait what? Why would they host a second, competing set of Q&A sites on their network? How would he get them to you know what gently caress it spending more than 30 seconds thinking about this has already wasted too much time.

No Safe Word
Feb 26, 2005

darthbob88 posted:

That's another part of why it's terrible; he wants to start it on StackExchange, in direct competition with Stack Overflow. But his idea would win because it's the better choice. Free Market and all that.


You mean like start it on their Area51 site and try to build a groundswell until it's an actual official StackExchange site? I don't see how it would be "started on StackExchange" and then move away from it...

I mean, the idea is horrible enough but is the secondary horror the fact that there's no way to accomplish the plan for that horrible idea?

darthbob88
Oct 13, 2011

YOSPOS

No Safe Word posted:

You mean like start it on their Area51 site and try to build a groundswell until it's an actual official StackExchange site? I don't see how it would be "started on StackExchange" and then move away from it...

I mean, the idea is horrible enough but is the secondary horror the fact that there's no way to accomplish the plan for that horrible idea?

I think he did mean Area51, but the secondary horror is the fact that it'd be competing with the site that spawned it and that it was based on. Say again, I refused this proposition before any technical details got hashed out.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

darthbob88 posted:

It would combine all the wisdom of Stack Overflow with the democracy of Reddit, in a final product that would, he assures me, make us zillions of dollars if I just do the backend work for him.

Ah yes, zillions of dollars by basing your business model around sites that have had lots of trouble finding a viable monetization strategy.




runupon cracker posted:

code:
var y:Number = this.y;

This is ActionScript 3? If they profiled this, this could result in a big speedup during a tight loop. Adobe's ASC compiler is terrible, and this.y compiles to:

code:
getlocal 0
getproperty ::y
... Every time the variable is referenced. This would result in a hashmap lookup... But there's a JIT, right? Nope! The JIT just emits code that calls a "getproperty" thunk that does the aformentioned hashmap lookup, as it could trigger a getter. If this.y is a property getter, as it is on a DisplayObject, that means running the getter on every lookup, too.

Wheras var y:Number = this.y; will only do the hashmap lookup and getter once. It looks like:

code:
getlocal 0
getproperty ::y
convert_d
setlocal 1
(The convert_d instruction is the cast to Number)

For more evidence of Adobe's inability to write a decent compiler, have a puzzle: obj[prop] += 5; naively desugars to obj[prop] = obj[prop] + 5; (where obj and prop are arbitrary expressions). Guess why this is semantically incorrect and slow, kids!

OddObserver
Apr 3, 2009
That's not correct even when obj and prop are both variable names (and obj doesn't have custom setters or getters) :D

OddObserver fucked around with this message at 04:55 on Feb 21, 2012

Hammerite
Mar 9, 2007

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

prefect posted:

It sounds like a terrible idea, but it wouldn't be the first terrible idea to make zillions of dollars. (Doesn't Stack Overflow already have voting on answers? That seems to be the key element of this guy's idea.)

From the description it sounds like the questioner is supposed to provide a list of answers, and the other users merely vote on those answers, much like a poll on a web forum. So it's a much stupider system than Stack Exchange because the person posing the question (who presumably has deficiencies in their knowledge of the subject matter, or they wouldn't need to ask questions about it) has to supply the set of possible answers, in all likelihood missing the best or most correct answers because they don't know what the gently caress.

I'm thinking endless variations on "Which of these is the best regular-expression approach to manipulating XML?", with legions of potential answerers having aneurisms because "use an XML parsing library instead" isn't present as an option.

Unless they can add new answers to the poll following suggestions from the other users, in which case it's an inferior version of the functionality offered by Stack Exchange style sites.

ToxicFrog
Apr 26, 2008


Suspicious Dish posted:

For more evidence of Adobe's inability to write a decent compiler, have a puzzle: obj[prop] += 5; naively desugars to obj[prop] = obj[prop] + 5; (where obj and prop are arbitrary expressions). Guess why this is semantically incorrect and slow, kids!

What you seem to be implying is that both obj and prop will get evaluated twice, complete with any side effects, and with the added bonus that either or both could have different values on the left and right hand sides as a result of said side effects.

But surely not even Adobe would screw up the compiler that badly. :psyduck:

Vanadium
Jan 8, 2005

At the very least it's implying two hash lookups.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

ToxicFrog posted:

But surely not even Adobe would screw up the compiler that badly. :psyduck:
That's giving Adobe a lot of credit.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

ToxicFrog posted:

What you seem to be implying is that both obj and prop will get evaluated twice, complete with any side effects, and with the added bonus that either or both could have different values on the left and right hand sides as a result of said side effects.

Yep. That's exactly it.

pre:
$ cat asctest.as
var a = [0, 1];
var i = 0;
a[(i++)] += 1;
print("a is ", a);
print("i is ", i);

$ ./avmshell_64 asctest.abc
a is 2,1
i is 2

$ fusion-swfdump asctest.abc | gist
https://gist.github.com/1875229
If you can't read that, don't worry, most of it is junk for setting up the environment. Just note that there are two increment instructions there. Also, for some strange reason the bug goes away when I remove the parens.


Aleksei Vasiliev posted:

That's giving Adobe a lot of credit.

If you're curious about the history, the compiler was contracted to Jeff Dyer of the Mountain View Compiler Company by Macromedia. Eventually he dropped his compiler company and went full-time at Macromedia, and even served on TC-39, the ECMA standards commitee that standardizes ECMAScript. He left Adobe a little while ago, and is now doing his own thing called "Art Compiler":

Useless Web Page
Not so useless, if outdated, web page
GitHub page
His explanation when I asked him about it at a year ago

Opinion Haver
Apr 9, 2007

php is the worst loving language oh my god
code:
$ php
<?
echo 0x0 +2, "\n", 0x0 +3.5, "\n", 0x0 +2e1;
?>
code:
4
6.5
757

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe

Suspicious Dish posted:

https://gist.github.com/1875229

That's awesome. The base and key and evaluated twice, but in reverse order from what I'd expect: the load is actually performed with the values from the second evaluation, and the store is done with the values from the first. In retrospect, it's the more sensible order to do it given that the target is a stack machine. Well, more sensible but still obviously wrong semantically.

The instruction sequence emitted to perform a post-increment is really ridiculous; it goes through a temporary local for no apparent reason at all, and then has to kill it four instructions later.

Optimus Prime Ribs
Jul 25, 2007

yaoi prophet posted:

php is the worst loving language oh my god
code:
$ php
<?
echo 0x0 +2, "\n", 0x0 +3.5, "\n", 0x0 +2e1;
?>
code:
4
6.5
757

What version of PHP causes this?

I tried that here, and it works as it should:
http://ideone.com/OaHC4
http://codepad.org/HfFKOjed

Then I tried the it on my work's server (PHP 5.3.3, newer than Ideone's PHP 5.2.11), and it got the same, incorrect, 4/6.5/757 crap.

The hell is going on here? :psyduck:

Strong Sauce
Jul 2, 2003

You know I am not really your father.





Optimus Prime Ribs posted:

What version of PHP causes this?

I tried that here, and it works as it should:
http://ideone.com/OaHC4
http://codepad.org/HfFKOjed

Then I tried the it on my work's server (PHP 5.3.3, newer than Ideone's PHP 5.2.11), and it got the same, incorrect, 4/6.5/757 crap.

The hell is going on here? :psyduck:

According to the thread: this "optimization" https://github.com/php/php-src/commit/0accb4b0094b8fdda905e0a374843f0c775f4537

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Strong Sauce posted:

According to the thread: this "optimization" https://github.com/php/php-src/commit/0accb4b0094b8fdda905e0a374843f0c775f4537

Man, changing the indentation of code really screws up git diffs.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Jabor posted:

Man, changing the indentation of code really screws up git diffs.

You can use git diff -w to ignore whitespace. Thankfully, GitHub exposes this feature too: add ?w=1 to the end of URLs, like so:

https://github.com/php/php-src/commit/0accb4b0094b8fdda905e0a374843f0c775f4537?w=1

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?
code:
switch (writelength_upper)
{
    case 0:
        writemask_upper = 1;
        break;
    case 1:
        writemask_upper = 3;
        break;
    case 2:
        writemask_upper = 7;
        break;
    case 3:
        writemask_upper = 15;
        break;
    case 4:
        writemask_upper = 31;
        break;
    case 5:
        writemask_upper = 63;
        break;
    case 6:
        writemask_upper = 127;
        break;
    case 7:
        writemask_upper = 255;
        break;
    case 8:
        writemask_upper = 511;
        break;
    case 9:
        writemask_upper = 1023;
        break;
    case 10:
        writemask_upper = 2047;
        break;
    case 11:
        writemask_upper = 4095;
        break;
    case 12:
        writemask_upper = 8191;
        break;
    case 13:
        writemask_upper = 16383;
        break;
    case 14:
        writemask_upper = 32767;
        break;
    case 15:
        writemask_upper = 65535;
        break;
    case 16:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 17:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 18:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 19:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 20:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 21:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 22:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 23:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 24:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 25:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 26:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 27:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 28:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 29:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 30:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 31:
        //writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        writemask_upper = 4294967295;
        break;
    default:
        writemask_upper = 1;
        break;
}
This is in C#

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

I like how somebody has apparently looked at the result for writelength_upper == 31, thought "wait, that isn't right", and then hard-coded the value.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
They do know that power is not ^, right?

EDIT: also, please tell me that you replaced it with return (2 << writelength_upper) - 1;.

Suspicious Dish fucked around with this message at 23:25 on Feb 24, 2012

Fiend
Dec 2, 2001

HappyHippo posted:


This is in C#

The only thing left is to update the code commenting "//using hard coded values so as not to waste precious CPU cycles" then create a new Extension Method on System.Math. Now the coding horror will live on to entertain future generations.

HappyHippo
Nov 19, 2003
Do you have an Air Miles Card?

Isilkor posted:

I like how somebody has apparently looked at the result for writelength_upper == 31, thought "wait, that isn't right", and then hard-coded the value.

That's my favorite part. They're probably quite proud they caught that "bug."

quote:

They do know that power is not ^, right?

Evidently not...

PalmTreeFun
Apr 25, 2010

*toot*

HappyHippo posted:

code:
switch (writelength_upper)
{
    case 0:
        writemask_upper = 1;
        break;
    case 1:
        writemask_upper = 3;
        break;
    case 2:
        writemask_upper = 7;
        break;
    case 3:
        writemask_upper = 15;
        break;
    case 4:
        writemask_upper = 31;
        break;
    case 5:
        writemask_upper = 63;
        break;
    case 6:
        writemask_upper = 127;
        break;
    case 7:
        writemask_upper = 255;
        break;
    case 8:
        writemask_upper = 511;
        break;
    case 9:
        writemask_upper = 1023;
        break;
    case 10:
        writemask_upper = 2047;
        break;
    case 11:
        writemask_upper = 4095;
        break;
    case 12:
        writemask_upper = 8191;
        break;
    case 13:
        writemask_upper = 16383;
        break;
    case 14:
        writemask_upper = 32767;
        break;
    case 15:
        writemask_upper = 65535;
        break;
    case 16:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 17:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 18:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 19:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 20:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 21:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 22:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 23:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 24:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 25:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 26:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 27:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 28:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 29:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 30:
        writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        break;
    case 31:
        //writemask_upper = 2 ^ (writelength_upper + 1) - 1;
        writemask_upper = 4294967295;
        break;
    default:
        writemask_upper = 1;
        break;
}
This is in C#

I made code like this. When I was 13.

Haud
Dec 6, 2007

World's Worst Interview

PalmTreeFun posted:

I made code like this. When I was 13.

I definitely am guilty of doing this when I first started programming,.

PalmTreeFun
Apr 25, 2010

*toot*

Haud posted:

I definitely am guilty of doing this when I first started programming,.

I just happened to start when I was 13 or so. v:v:v

PDP-1
Oct 12, 2004

It's a beautiful day in the neighborhood.

HappyHippo posted:

That's my favorite part. They're probably quite proud they caught that "bug."

And then left the incorrect output of cases 16-30 as they were anyway. That odd output for case 31 was probably due to overflow, no need to test anything else, right guys?

:downsgun:

Haud
Dec 6, 2007

World's Worst Interview

PalmTreeFun posted:

I just happened to start when I was 13 or so. v:v:v

And I started when I was...24 :v:

TheRagamuffin
Aug 31, 2008

In Paradox Space, when you cross the line, your nuts are mine.

PalmTreeFun posted:

I made code like this. When I was 13.

I heard about a Junior CS student at my school doing something like this just yesterday for a FizzBuzz implementation. :suicide:

Vanadium
Jan 8, 2005

I just read up on D, it's kinda fun.

code:
struct S {}
class C {}

static assert(is(typeof(new int*) == int**));  // ok
static assert(is(typeof(new int)  == int*));   // ok
static assert(is(typeof(new S*)   == S**));    // ok
static assert(is(typeof(new S)    == S*));     // ok
static assert(is(typeof(new C*)   == C**));    // ok
static assert(is(typeof(new C)    == C*));     // Error: static assert  (is(C == C*)) is false


Gotta love having Java-style new and C++-style new in the same language. You can't use new to get a C*, that is a pointer to an object reference, directly, because that syntax is already reserved for creating an object and returning the reference. It's perfectly sensible in trying to be like Java's reference types but it intersects with C++-inspired features in a really awkward way.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I wonder how many GPL violations there are here...

Dransparency
Jul 19, 2006

quote:

CHILKAT S/MIME
Handle MIME and S/MIME with ease.

poo poo, sign me up.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.
PHP 5.4 got released.
http://gcov.php.net/viewer.php?version=PHP_5_4

quote:

Overview of PHP_5_4

Build Status: OK
Last Build Time: 46 hours

Compile Warnings: 1119
Code Coverage: 70.1%
Test Failures: 82
Expected Test Failures: 44
Valgrind Reports: 65

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Hahahaha "expected test failures"

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