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
kuf
May 12, 2007
aaaaaa

evensevenone posted:

it's the end of the quarter, and I already wrote transpose, so why waste time?
code:
GraphRef copyGraph(GraphRef G)
{
	return transpose(transpose(G));
}

were you that rear end in a top hat who got 100 on the first midterm

Adbot
ADBOT LOVES YOU

evensevenone
May 12, 2001
Glass is a solid.
98 :cool: I thought a lot of people got 100s though.

Munkeymon
Aug 14, 2003

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



Internet Janitor posted:

poor spelling certainly is a pro trait.

the keystroke commands simply execute out of order because the parallel hardware can't guarantee consistent interleaving without expensive locking operations

Pardot
Jul 25, 2001




I present Groovy's ArrayUtil.java

code:
public class ArrayUtil {
    private static final Object[] EMPTY = new Object[0]
            ;

    public static Object[] createArray() {
        return EMPTY;
    }

    public static Object[] createArray(Object arg0) {
        return new Object[]{
                arg0};
    }

    public static Object[] createArray(Object arg0, Object arg1) {
        return new Object[]{
                arg0, arg1};
    }

    public static Object[] createArray(Object arg0, Object arg1, Object arg2) {
        return new Object[]{
                arg0, arg1, arg2};
    }

    public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3) {
        return new Object[]{
                arg0, arg1, arg2, arg3};
    }

    public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) {
        return new Object[]{
                arg0, arg1, arg2, arg3, arg4};
    }
and so on up to arg249

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Java isn't my strongest language, but you can declare arrays inline like new object[] {obj1, obj2, obj3};, right?

if so, :ughh:

Kelson
Jan 23, 2005

Ryouga Inverse posted:

Java isn't my strongest language, but you can declare arrays inline like new object[] {obj1, obj2, obj3};, right?

if so, :ughh:

That's exactly what createArray does internally!

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog

Ryouga Inverse posted:

Java isn't my strongest language, but you can declare arrays inline like new object[] {obj1, obj2, obj3};, right?

if so, :ughh:

Yes, that's exactly what those methods are doing.

pseudorandom name
May 6, 2007

To be fair, those methods are part of the Groovy runtime and only called by generated code.

Which doesn't explain why the code generator doesn't just create the arrays inline, but it isn't like humans are actually using that abomination directly.

BigRedDot
Mar 6, 2008

Pardot posted:

and so on up to arg249
If that's not a gauntlet thrown, I don't know what is.

raminasi
Jan 25, 2005

a last drink with no ice

Munkeymon posted:

the keystroke commands simply execute out of order because the parallel hardware can't guarantee consistent interleaving without expensive locking operations

This actually happens to me when typing sometimes (the hardware is my nervous system)

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
For what it's worth, those functions do change program semantics: they change evaluation order so that the array is allocated after the operands are evaluated, rather than before. Why that would be desireable, I don't know.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Kelson posted:

That's exactly what createArray does internally!

Could you do something more like:
code:
createArray(Object... blah) {
  return blah
}
?

I'm not sure what the semantics of the variable-arity call in Java are.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

i'm an idiot

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Kilson: that's completely equivalent to the standard array-initializer expression, yes.

Presto
Nov 22, 2002

Keep calm and Harry on.

Pardot posted:

and so on up to arg249
Should have gone to arg255. Everyone knows if you're going to pick an arbitrary point to stop at, you pick a power of 2. That way people think there's some deep-seated reason for it.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Presto posted:

Should have gone to arg255. Everyone knows if you're going to pick an arbitrary point to stop at, you pick a power of 2. That way people think there's some deep-seated reason for it.

It makes me wonder if they tried that and maybe there's some JVM limitation that prevents more than 250 arguments (and the difference accounts for some overhead that would add up to 255-256 somethings).

I don't care enough to actually investigate this, however.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

Kilson posted:

Could you do something more like:
code:
createArray(Object... blah) {
  return blah
}
?

I'm not sure what the semantics of the variable-arity call in Java are.

Yes you can. You can also sprinkle a few Generics there:
code:
public static <T> T[] createArray(T...t) {
    return t;
}
Tada! Now you actually get out what you put into it. Granted, this is rather pointless in generated code but still you can do it.


Flobbster posted:

It makes me wonder if they tried that and maybe there's some JVM limitation that prevents more than 250 arguments (and the difference accounts for some overhead that would add up to 255-256 somethings).

I don't care enough to actually investigate this, however.

If I remember correctly, JVM bytecode supports up to 65536 parameters per method and 65536 methods per class.

Parantumaton fucked around with this message at 18:21 on Nov 30, 2010

NotShadowStar
Sep 20, 2000

Parantumaton posted:

If I remember correctly, JVM bytecode supports up to 65536 parameters per method and 65536 methods per class.

The challenge is on: somebody find a blog post containing somebody bitching about this limitation. The real ultimate horror will have been found.

SavageMessiah
Jan 28, 2009

Emotionally drained and spookified

Toilet Rascal
The zillion overloads are for performance reasons. Variable arity methods in Java are significantly slower than dispatching to a fixed-arity overload. Clojure does the same thing - the call method on whatever the basic lambda class has tons of fixed overloads with one last variable arity one to catch the rest of the cases.

No idea why this particular method exists though.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost

NotShadowStar posted:

The challenge is on: somebody find a blog post containing somebody bitching about this limitation. The real ultimate horror will have been found.
This is a commonly reached limitation. Usually it comes up when JSP is mentioned (although it has to do with method size limitations). That's the root of the horror.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I found something of my own that's a small h horror but still resulted in head slapping from me. It was a quick little log viewer app that I whipped up in a couple minutes a few years ago:
code:
If Thing = 'blah' then
   'Do nothing
Else if Thing = 'blah blah'
   'Do nothing
Else
   'Do something
End If
Nothing like testing for conditions that don't have to be handled first...

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

necrobobsledder posted:

This is a commonly reached limitation. Usually it comes up when JSP is mentioned (although it has to do with method size limitations). That's the root of the horror.

I've seen poorly written monolithic jsp's that blow past the method size limitations. I was both astounded and kind of amused; the mother fucker who wrote it was being paid over $100 an hour.

Incoherence
May 22, 2004

POYO AND TEAR

Scaramouche posted:

I found something of my own that's a small h horror but still resulted in head slapping from me. It was a quick little log viewer app that I whipped up in a couple minutes a few years ago:
code:
If Thing = 'blah' then
   'Do nothing
Else if Thing = 'blah blah'
   'Do nothing
Else
   'Do something
End If
Nothing like testing for conditions that don't have to be handled first...
I've done the "if X, do nothing, else do something" pattern before when the condition was sufficiently painful to look at that I didn't want to deal with inverting it. The else if is a bit interesting, though.

markerstore
Dec 5, 2003
Canny!

SavageMessiah posted:

The zillion overloads are for performance reasons. Variable arity methods in Java are significantly slower than dispatching to a fixed-arity overload.

But isn't the difference in performance there just the array creation? Which is exactly what these methods are doing in the body? I mean, you all realize that the varargs version is a no-op and would probably be optimized out by Hotspot, if not the compiler, right?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Incoherence posted:

I've done the "if X, do nothing, else do something" pattern before when the condition was sufficiently painful to look at that I didn't want to deal with inverting it. The else if is a bit interesting, though.

I guess the best way would be to do "if Thing <> 'blah' or Thing <> 'blah blah' then DoSomething" but I guess the younger me can't think clearly (these weren't complex cases). It gets even better though, I shouldn't even have been checking for blah there anyway because the input gets scrubbed before the function starts. Basically the condition is always met. Remember kids, friends don't let friends code when they're in a hurry.

Opinion Haver
Apr 9, 2007

Scaramouche posted:

I guess the best way would be to do "if Thing <> 'blah' or Thing <> 'blah blah' then DoSomething" but I guess the younger me can't think clearly (these weren't complex cases).
I guess you still can't because this is always true :haw:

Argue
Sep 29, 2005

I represent the Philippines
Okay, so do you guys know how software devs try to be cute and name their releases after random things? Like, I don't know, Antsy Aardvark, or Microsoft Excel: Charmander edition or whatever. I realize that these titles almost never relate to the actual product, but our client takes it to the extreme.

I was just browsing our client's branches folder and found the part where they tag releases. There doesn't seem to be any pattern to the naming. I checked, and it isn't in alphabetical order, or by common theme, or anything.

The names of their last few releases are:
  • 25_click-0.3.1_02-Feb-09/
  • 18_narnia_0.2.10/
  • 25_50firstdates_0.1.0_18-Oct-07/
  • 24_pirates_of_the_caribbean_2_deadmanchest_release_apr30/

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
There's a common theme there.

Argue
Sep 29, 2005

I represent the Philippines
Is it... bad code? :smug:

bobthecheese
Jun 7, 2006
Although I've never met Martha Stewart, I'll probably never birth her child.
That, and bad movies.

Maybe it's just "Name it after which movie I saw last"

Also, your client is an Adam Sandler fan, by the looks.

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

Incoherence posted:

I've done the "if X, do nothing, else do something" pattern before when the condition was sufficiently painful to look at that I didn't want to deal with inverting it. The else if is a bit interesting, though.

In that case why not simply do "if !X, do something"? There's no need to figure out how to invert it if you just wrap it up in brackets and throw a negation on the front.

Incoherence
May 22, 2004

POYO AND TEAR

HappyHippo posted:

In that case why not simply do "if !X, do something"? There's no need to figure out how to invert it if you just wrap it up in brackets and throw a negation on the front.
Because it's usually something like
code:
if (!(a && b) || c || d) {
  // do nothing
} else {
  // do something
}
(imagine a, b, c, and d are relatively long as well) and just leaving it that way is easier to parse than wrapping the whole thing in a !() and trying to figure out what it means in six months.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Incoherence posted:

Because it's usually something like
code:
if (!(a && b) || c || d) {
  // do nothing
} else {
  // do something
}
(imagine a, b, c, and d are relatively long as well) and just leaving it that way is easier to parse than wrapping the whole thing in a !() and trying to figure out what it means in six months.

Probably, but it's even easier to do

code:
bool ThingHasBeenDone(a, b, c, d) {
    return (a && b) || c || d;
}

if (!ThingHasBeenDone(a, b, c, d))

Scaevolus
Apr 16, 2007

Jabor posted:

Probably, but it's even easier to do

code:
bool ThingHasBeenDone(a, b, c, d) {
    return (a && b) || c || d;
}

if (!ThingHasBeenDone(a, b, c, d))
This is a horror.

Null Pointer
May 20, 2004

Oh no!

Scaevolus posted:

This is a horror.

Yes.

De Morgan's laws.

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

Incoherence posted:

Because it's usually something like
code:
if (!(a && b) || c || d) {
  // do nothing
} else {
  // do something
}
(imagine a, b, c, and d are relatively long as well) and just leaving it that way is easier to parse than wrapping the whole thing in a !() and trying to figure out what it means in six months.

Really? If you're too lazy to work out the proper inverse !(...) seems just as clear to me as if(...){}else{...}

Munkeymon
Aug 14, 2003

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



Argue posted:

The names of their last few releases are:
  • 25_click-0.3.1_02-Feb-09/
  • 18_narnia_0.2.10/
  • 25_50firstdates_0.1.0_18-Oct-07/
  • 24_pirates_of_the_caribbean_2_deadmanchest_release_apr30/

Naming your release after the last movie you saw isn't totally unreasonable. I could see it giving a movie buff some context to help pull up associated memories.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Munkeymon posted:

Naming your release after the last movie you saw isn't totally unreasonable. I could see it giving a movie buff some context to help pull up associated memories.

So long as that context includes the missing year of a date and missing version numbers, and said movie buff still works there, I'm with you.

Maybe the Click release worked around something really annoying.

return0
Apr 11, 2007

Scaevolus posted:

This is a horror.

Inline your booleans!

Adbot
ADBOT LOVES YOU

POKEMAN SAM
Jul 8, 2004

Munkeymon posted:

Naming your release after the last movie you saw isn't totally unreasonable. I could see it giving a movie buff some context to help pull up associated memories.

I really hope you're joking/trolling here.

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