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
Jaded Burnout
Jul 10, 2004


I'm going to give that joke a hard pants.

Adbot
ADBOT LOVES YOU

darthbob88
Oct 13, 2011

YOSPOS

Internet Janitor posted:

I don't own pants, but a friend lends me his whenever I need them. In turn I lend the pants I'm borrowing to others I know and trust. This thrifty reputation-based economy is an example of pants-by-reference.

A) This can't just disappear with the last page.
B) gently caress you.

Steve French
Sep 8, 2003

TooMuchAbstraction posted:

You can fake a set in Go by using map[whatever]bool, so long as you only care about membership (and not intersection/unity/set equality/etc.). But note that I said the code was outputting a list of elements, that happened to be ordered based on the order in which the code iterated over a map. So basically our options were either a) sort the map keys, to enforce a consistent order in the output list, or b) write a comparison function that takes two input lists, sorts them (or converts them to maps, etc.), then iterates over both of them to ensure that every element in each is also in the other.

It happens that this pattern shows up many times in our codebase, and that the keys are always int32s (they're database primary keys, and yes, 4 billion of them should be enough for many, many years), so we just implemented SortableInt32. We still have to remember to sort the keys every time we iterate over a map that's feeding into a result list, lest our tests break, though.

You did say that you are returning a list of elements, but apparently in arbitrary order. Unless there may be duplicates, a set seems a likely candidate to use instead?

Reformed Pissboy
Nov 6, 2003

MC Jaded Burnout posted:

I'm going to give that joke a hard pants.

Mmm, gotta go mustard on this one.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


This code made me laugh.

I can't even copy and paste it, the entities get all messed up.

Bongo Bill
Jan 17, 2012

Doc Hawkins posted:

This code made me laugh.

I can't even copy and paste it, the entities get all messed up.

Racket is a trip.

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

Steve French posted:

You did say that you are returning a list of elements, but apparently in arbitrary order. Unless there may be duplicates, a set seems a likely candidate to use instead?

It would be! And if Go had a builtin set, we would use it. As has been thoroughly covered by now, Go does not have such a data structure. And we are not (yet) at the point of using code generators to produce all the different set types we might need.

Horse Clocks
Dec 14, 2004


The other month I got a PR from an 'experienced contractor' along the lines of


code:

count = 0
for item in (const_A, const_B):
    count += 1
    if count < 2:
        return process(item)

Despite telling the 'tech lead' multiple times about his incompetence it took a month to get him fired.

The kicker: his task was to change the value fed in from a CSV file that populated some initial data. He did change the CSV but by a factor of 0.5 instead of 0.25. Hence the for-loop shittery. Which in turn broke functionality.

:psyduck: no idea how the guy survives.

[Edit]
The entire project is a coding horror of: what happens when you ask a consultancy (that wants to be a vendor in the same industry as you instead) 'make me an app' with no stipulations, no review, and only let junior developers write code with no senior oversight.

you subsidise the development of their product, and then they stop developing yours when they get bored.

Such gems as:

Supplier wrote their own open-source build tool because the world needs another bazel clone. Supplier subsequently overrode *their* build tools build definitions in the project for reasons I'm yet to determine.

Horse Clocks fucked around with this message at 08:00 on Jul 10, 2017

Jaded Burnout
Jul 10, 2004


Horse Clocks posted:

:psyduck: no idea how the guy survives.

It's "unprofessional" to be public about a lovely employee or employer, so everyone "quits" for BS reasons and the cycle continues.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Horse Clocks posted:

what happens when you ask a consultancy (that wants to be a vendor in the same industry as you instead) 'make me an app' with no stipulations, no review, and only let junior developers write code with no senior oversight.

Oh hey it's the Facebook origin story.

Munkeymon
Aug 14, 2003

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



b0lt posted:

That isn't even the worst part about D. Their equivalent of boost declared an intifada:

Haha holy poo poo. Too bad - it seemed like a pretty nice language when I last checked it out.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

B-Nasty posted:

After all I don't put one leg through my underwear, then in one pant leg, then one sock, then that side's shoe.

Me either, until now. Now that's going to be the only way I ever get dressed.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Good news folks, pad-left has been obsoleted by ES8!

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner
Wait, there's left-pad and pad-left? gently caress off

UraniumAnchor
May 21, 2006

Not a walrus.

Meat Beat Agent posted:

Wait, there's left-pad and pad-left? gently caress off

Javascript is taking a page from Ruby's book by having eight different ways to do something all with subtle quirks.

Except in this case it's micro-libraries instead of language features.

Jaded Burnout
Jul 10, 2004


UraniumAnchor posted:

Javascript is taking a page from Ruby's book by having eight different ways to do something all with subtle quirks.

What do you expect from a language based on Perl

necrotic
Aug 2, 2005
I owe my brother big time for this!

Meat Beat Agent posted:

Wait, there's left-pad and pad-left? gently caress off

pad-left is a whole 1% faster than left-pad!! The gains will be immense!

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

necrotic posted:

pad-left is a whole 1% faster than left-pad!! The gains will be immense!

Sadly, I would absolutely be willing to believe this to be true.

Space Kablooey
May 6, 2009


TooMuchAbstraction posted:

Sadly, I would absolutely be willing to believe this to be true.

pad-left has a benchmark section vs left-pad in the pad-left NPM page.

Nippashish
Nov 2, 2005

Let me see you dance!

HardDiskD posted:

pad-left has a benchmark section vs left-pad in the pad-left NPM page.

I like the special case for numeric 0.

necrotic
Aug 2, 2005
I owe my brother big time for this!

TooMuchAbstraction posted:

Sadly, I would absolutely be willing to believe this to be true.

Yeah, its the main selling point of pad-left. All over their readme.

as well as links to like 20 other projects of a similar style, such as pad-left-keys!

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

necrotic posted:

Yeah, its the main selling point of pad-left. All over their readme.

as well as links to like 20 other projects of a similar style, such as pad-left-keys!

"Man this fellow sure has an impressive resume!" - the HR guy at your dream corporation

TooMuchAbstraction
Oct 14, 2012

I spent four years making
Waves of Steel
Hell yes I'm going to turn my avatar into an ad for it.
Fun Shoe

necrotic posted:

Yeah, its the main selling point of pad-left. All over their readme.

as well as links to like 20 other projects of a similar style, such as pad-left-keys!

I wasn't arguing that they aren't 1% faster, just saying that I could absolutely believe that having a 1% faster implementation of "insert some spaces on the left side of this text" results in big performance gains for at least some sites.

necrotic
Aug 2, 2005
I owe my brother big time for this!
Ah, I thought you were commenting on the fact that it was a main selling point, not the "immense gains". Yeah if some thing has to do a shitload of left padding you'd see some worthwhile gains, but that's a pretty narrow target. I just love how proud they are of a 1% gain.

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies
And we can now all translate our PHP codebases to JS so we can harness these wonderful new features using babel-preset-php. Truly a wonderful time to be alive.

Meat Beat Agent
Aug 5, 2007

felonious assault with a sproinging boner
The "1%" in those benchmarks is the margin of error, not the difference.

Not that it's, you know, that important, ideally.

necrotic
Aug 2, 2005
I owe my brother big time for this!

Meat Beat Agent posted:

The "1%" in those benchmarks is the margin of error, not the difference.

Not that it's, you know, that important, ideally.

oh yeah i read that totally wrong.

canis minor
May 4, 2011

Master_Odin posted:

And we can now all translate our PHP codebases to JS so we can harness these wonderful new features using babel-preset-php. Truly a wonderful time to be alive.

While it's a horror on its own I like the word transpiler

https://github.com/fabiosantoscode/js2cpp - JS to C++ using CoffeeScript :allears:

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

canis minor posted:

While it's a horror on its own I like the word transpiler

https://github.com/fabiosantoscode/js2cpp - JS to C++ using CoffeeScript :allears:

What happens if you point this and emscripten at each other? Do they eventually converge to a transpilation-stable implementation, or do you get infinitely nested emscripten memory arrays?

canis minor
May 4, 2011

NihilCredo posted:

What happens if you point this and emscripten at each other? Do they eventually converge to a transpilation-stable implementation, or do you get infinitely nested emscripten memory arrays?

Translation party, but with programming languages. What a wonderful idea (I'd place my bets on the second though)

Also - https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js

nolen
Apr 4, 2004

butts.
code:
public List<long> GetDefaultSkus(string category)
{
	List<long> skus = new List<long>();

	//loop through the default items
	foreach (KeyValuePair<string, long> kvp in Model.DefaultSkus)
	{
		string loopType = kvp.Key;
		long sku = kvp.Value;

		//if the category matches
		if (category == loopType)
		{
			//add to list
			skus.Add(sku);
		}

		return skus;
	}
}
Somebody doesn't know how Dictionary lookups work.

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
Holy poo poo.

That's bad.

Space Kablooey
May 6, 2009



I like the return inside of the foreach.

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer

HardDiskD posted:

I like the return inside of the foreach.

I was gonna say "what's wrong with that?"

Then I realized it's outside of the if.

(Initially I didn't notice it was returning a list)

So yeah, that code returns the first item if it matches, otherwise it returns an empty list.

nolen
Apr 4, 2004

butts.

Snak posted:

I was gonna say "what's wrong with that?"

Then I realized it's outside of the if.

(Initially I didn't notice it was returning a list)

So yeah, that code returns the first item if it matches, otherwise it returns an empty list.

The best part is that a Dictionary can only ever have one entry for a given Key, so this logic would only ever return a single item anyway, defeating the purpose of having a List.

Edit: The guy's title is Software Engineer III :smugjones:

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
It's like every single part of that code is wrong.

The method shouldn't even exist unless to implement error handling.

Dirty Frank
Jul 8, 2004

I thought it was bad form to post student code?

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
That code should be an exam question. "Rewrite this code to fix all errors."

Doom Mathematic
Sep 2, 2008

Internet Janitor posted:

Good news folks, pad-left has been obsoleted by ES8!

Thankfully, the ES8 implementation actually truncates the output to the correct length instead of, like pad-left and left-pad, just blindly assuming that the filler string has length 1, and returning garbage if it doesn't.

Adbot
ADBOT LOVES YOU

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

boo_radley posted:

This seems like a bonkers thing to do. It's always been my assumption that in hashes, the ordering and storage of elements in part of the black box and subject to the whims of designers, compilers and etc. etc. etc. all the time.
Not so much whims. A hash table is basically an array where the key is translated into an index with sufficient voodoo to avoid collisions. You can store order of insertion, but nine times out of ten who gives a poo poo.

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