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
Impotence
Nov 8, 2010
Lipstick Apathy

Soricidus posted:

Nobody who is familiar with both C++ and Java would claim that they are the same language. I will charitably assume you know one of them, and are being misled by the superficial syntactic similarities.

Just write macros for java syntax, then write your c++ in java

Adbot
ADBOT LOVES YOU

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

Firstkind posted:

I understand about 20% of the poo poo in this thread. I am googling poo poo like mad and researching all this garbage I don't know. But I have to say this one out loud.

You can't be real. You made that all up didn't you. I refuse to believe that this makes sense to someone.

Designing your own language is called 'job security'. :smug:

Also like most people have said already, a lot of languages seem to melt together when you've got a few under your belt. I'm not saying you need to be totally proficient, just enough to go "hey this is like that thing in that other language".

ExcessBLarg!
Sep 1, 2001

Firstkind posted:

You can't be real. You made that all up didn't you. I refuse to believe that this makes sense to someone.
It makes sense, and I understand the complaint. It's when you have two objects that maintain internal references to each other. It complicates ownership and tends to indicate that one or more workflows bounce back and forth between methods in the two objects.

Yeah, computer programming is a vast discipline. Nobody is really expected to be an expert horizontally (i.e., nobody is expected to be fluent in all languages), and even vertical expertise is long-acquired. That's exactly why junior positions exist.

The thing is, when you work with someone who clearly has more (better?) experience, it's often good to listen to them and follow their advice.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that
I feel like this is like getting angry at musicians for having too many genres of music.

fritz
Jul 26, 2003

Pavlov posted:

I feel like this is like getting angry at musicians for having too many genres of music.

"There are eighty eight keys on this thing?!?!?!?"

Firstkind
Apr 10, 2015

by 2017 exmarx

ExcessBLarg! posted:

The thing is, when you work with someone who clearly has more (better?) experience, it's often good to listen to them and follow their advice.

If and when I find this guy I will hook on to them like a parasite and blame all my life's failures on them from that point forward. With that being said, anyone in the state of Massachusetts hiring for a junior position that will pay enough to live off bread and water and happen to have a nice shining bald head in which for me to latch my starfish like appendages on?

uncleTomOfFinland
May 25, 2008


:ssh: don't tell anyone but the actual hard part is not the languages but all the libraries, builds, idioms and other poo poo "Learn LANGUAGE_NAME_HERE" books don't teach you.

pigdog
Apr 23, 2004

by Smythe

uncleTomOfFinland posted:

:ssh: don't tell anyone but the actual hard part is not the languages but all the libraries, builds, idioms and other poo poo "Learn LANGUAGE_NAME_HERE" books don't teach you.

There are some very good programming books out there these days.

That said, most of your time would likely be spent trying to make sense of other use people's code and your specific problem domain.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

uncleTomOfFinland posted:

:ssh: don't tell anyone but the actual hard part is not the languages but all the libraries, builds, idioms and other poo poo "Learn LANGUAGE_NAME_HERE" books don't teach you.

True programming is learning how to deal with code that stores all important program state in a global ArrayList<HashMap<String, Object>>.

Purple Prince
Aug 20, 2011

Pavlov posted:

True programming is learning how to deal with code that stores all important program state in a global ArrayList<HashMap<String, Object>>.

Related to this: discovered my own coding horror in writing a template-based binary search tree which essentially does the same thing as stl::map and spending significant time getting it to work.

Soricidus
Oct 21, 2010
freedom-hating statist shill

Pavlov posted:

True programming is learning how to deal with code that stores all important program state in a global untyped Vector.

Mr Shiny Pants
Nov 12, 2012

uncleTomOfFinland posted:

:ssh: don't tell anyone but the actual hard part is not the languages but all the libraries, builds, idioms and other poo poo "Learn LANGUAGE_NAME_HERE" books don't teach you.

This, syntax is relatively easy but design patterns, testing and all the other stuff is a lot more work.

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Wardende posted:

You can write procedural or functional code in all of those languages.

Yes. You can also do logical programming using C++ template metaprograms, but that doesn't mean it's a good language for doing that.

tyrelhill
Jul 30, 2006

Pavlov posted:

True programming is learning how to deal with code that stores all important program state in a global ArrayList<HashMap<String, Object>>.

Is this some sort of Java pattern or something cause I see Java programmers do this often and it drives me nuts.

Pavlov
Oct 21, 2012

I've long been fascinated with how the alt-right develops elaborate and obscure dog whistles to try to communicate their meaning without having to say it out loud
Stepan Andreyevich Bandera being the most prominent example of that

tyrelhill posted:

Is this some sort of Java pattern or something cause I see Java programmers do this often and it drives me nuts.

I've only encountered this recently, but I was talking about it with some guys, and the best guess we came up with was that it might be people with a background in databases trying to use a data-model they're familiar with. It makes a little sense because the way you access it kind of thing looks a little like a badly mangled SQL query.

Space Kablooey
May 6, 2009


tyrelhill posted:

Is this some sort of Java pattern or something cause I see Java programmers do this often and it drives me nuts.

It's probably more a pattern of Java programmers. :v:


EDIT:

Munkeymon posted:

I never knew I needed a collective noun for Java programmers but thanks for coming up with one!

Glad to help. :)

Space Kablooey fucked around with this message at 19:36 on May 4, 2015

xzzy
Mar 5, 2009

tyrelhill posted:

Is this some sort of Java pattern or something cause I see Java programmers do this often and it drives me nuts.

I don't know if it's taught for Java but it's probably going to be the first idea that pops into a neophyte programmer's head when they need to have certain bits of information available everywhere. We all had that phase, right?

"I got it! This is a totally justifiable exception to the never use globals rule!"

Munkeymon
Aug 14, 2003

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



HardDisk posted:

a pattern of Java programmers

I never knew I needed a collective noun for Java programmers but thanks for coming up with one!

Purple Prince
Aug 20, 2011

Just for fun, decided to write a primitive brute forcer to see how quickly my laptop could crack alphanumeric passwords of a given length (the answer is under 5 seconds for a 5-character password, with the obvious exponential increase to 3 minutes for 6 characters and a ridiculous length of time for anything longer -- but it should remind us all to use more than 7 characters in our passwords, since a determined attacker isn't going to balk at waiting an hour for admin access). It doesn't actually do anything offensive, just generates all possible alphanumeric strings.

code:
void bruteForceNonRecursive(unsigned char* password){
    unsigned char curPos = 0;
    do{
        curPos++;
        while(password[curPos] != 255){password[curPos] = 0; curPos++;}
        curPos--;
        while(password[curPos] < 62) password[curPos]++;
        while(password[curPos] == 62){
            curPos--;
            if(curPos != 255) password[curPos]++;
        }
    } while(curPos != 255);
}
Pros: succinctness.
Cons: everything else.

It's me, I'm the coding horror.

Purple Prince fucked around with this message at 20:31 on May 4, 2015

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


Purple Prince posted:

code:
void bruteForceNonRecursive(unsigned char* password){
    unsigned char curPos = 0;
    do{
        curPos++;
        while(password[curPos] != 255){password[curPos] = 0; curPos++;}
        curPos--;
        while(password[curPos] < 62) password[curPos]++;
        while(password[curPos] == 62){
            curPos--;
            if(curPos != 255) password[curPos]++;
        }
    } while(curPos != 255);
}

This one took me longer than I'd care to admit to grok but I think it's very clever :)

If you wanted to sacrifice speed for more "fun" , all you gotta do is condense those increments! :unsmigghh: I probably got something wrong here but I gave it a shot:

code:
void bruteForceNonRecursive(unsigned char* password){
    unsigned char curPos = 0;
    do{
        while(password[++curPos] != 255){password[curPos] = 0;}
        while(password[--curPos] < 62) password[curPos++]++;
        while(password[curPos--] == 62){
            if(curPos != 255) password[curPos]++;
        }
    } while(++curPos != 255);
}
I'm partial to the 2nd inner while loop!

Coffee Mugshot
Jun 26, 2010

by Lowtax

VikingofRock
Aug 24, 2008




Ruzihm posted:

This one took me longer than I'd care to admit to grok but I think it's very clever :)

Honestly I'm still stumped by it. I can't figure out why password[curPos] would ever reach 255 (other than having been that already), and I can't figure out what meaning 62 has.

Linear Zoetrope
Nov 28, 2011

A hero must cook
It kind of reminds me of some too-clever example code in libfreenect:

code:
void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp)
{
	int i;
	uint16_t *depth = (uint16_t*)v_depth;

	pthread_mutex_lock(&gl_backbuf_mutex);
	for (i=0; i<640*480; i++) {
		int pval = t_gamma[depth[i]];
		int lb = pval & 0xff;
		switch (pval>>8) {
			case 0:
				depth_mid[3*i+0] = 255;
				depth_mid[3*i+1] = 255-lb;
				depth_mid[3*i+2] = 255-lb;
				break;
			case 1:
				depth_mid[3*i+0] = 255;
				depth_mid[3*i+1] = lb;
				depth_mid[3*i+2] = 0;
				break;
			case 2:
				depth_mid[3*i+0] = 255-lb;
				depth_mid[3*i+1] = 255;
				depth_mid[3*i+2] = 0;
				break;
			case 3:
				depth_mid[3*i+0] = 0;
				depth_mid[3*i+1] = 255;
				depth_mid[3*i+2] = lb;
				break;
			case 4:
				depth_mid[3*i+0] = 0;
				depth_mid[3*i+1] = 255-lb;
				depth_mid[3*i+2] = 255;
				break;
			case 5:
				depth_mid[3*i+0] = 0;
				depth_mid[3*i+1] = 0;
				depth_mid[3*i+2] = 255-lb;
				break;
			default:
				depth_mid[3*i+0] = 0;
				depth_mid[3*i+1] = 0;
				depth_mid[3*i+2] = 0;
				break;
		}
	}
	got_depth++;
	pthread_cond_signal(&gl_frame_cond);
	pthread_mutex_unlock(&gl_backbuf_mutex);
}
So, you see, the Kinect sends its depth information as an unsigned 11-bit integer, and what this code is doing is basically separating the depth into cases. Either it's a sensor error, in which case it paints black, or else it slices it up into 5 "depth" regions and effectively interpolates between them (so white is very close, red is close, blue is far away, and green is in the middle). The effect it produces is really cool and useful for understanding the depth output you're getting, but I had to stare at that for a couple days before I really got it.

Linear Zoetrope fucked around with this message at 08:21 on May 5, 2015

Purple Prince
Aug 20, 2011

VikingofRock posted:

Honestly I'm still stumped by it. I can't figure out why password[curPos] would ever reach 255 (other than having been that already), and I can't figure out what meaning 62 has.

The string is declared with its final position (think of it as a null terminator) at 255 elsewhere (I think this is unnecessary in retrospect; it should be possible to generate a string meeting that requirement based on length alone), and 62 is the number of alphanumeric characters (26+26+10).

EDIT: I think this is the shortest you can make the code.

code:
void bruteForceNonRecursive(unsigned char length){
    unsigned char curPos = 0;
    unsigned char* password = new unsigned char[length+1];
    password[length] = 255;
    do{
        while(password[curPos] != 255) password[curPos++] = 0;
        curPos--;
        while(password[curPos]++ < 62);
        while(password[curPos] >= 62) if(--curPos != 255) password[curPos]++;
    } while(curPos++ != 255);
}

Purple Prince fucked around with this message at 11:12 on May 5, 2015

Coffee Mugshot
Jun 26, 2010

by Lowtax


hmmm

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
I've always hated that browsers default the confirm buttons to OK and Cancel. And there's no good way that I know of in JS to do a blocking dialog where you can specify your own button text.

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!



That's just sad.

That's a lesson to avoid any use of the word "cancel" to avoid ambiguity. Also, keep away from negative questions so you don't get your users into double-negative territory! Something along the lines of "This will empty your cart completely. Continue?" would be great.

lord funk
Feb 16, 2004

Ruzihm posted:

That's just sad.

That's a lesson to avoid any use of the word "cancel" to avoid ambiguity. Also, keep away from negative questions so you don't get your users into double-negative territory! Something along the lines of "This will empty your cart completely. Continue?" would be great.

[Cancel] is fine, but [OK] is always a terrible button. It should always be active, like [Delete] or [Remove] or [Clear], so I don't even have to read the message text at all.

loinburger
Jul 10, 2004
Sweet Sauce Jones
I was working on the back end of a website where users could make posts and whatever, and the post form included a box where they could include a youtube link that would then be embedded with the post. The product team wanted to add the ability for a user to upload a video from the post form, which would then be embedded; this was my job.

This was a startup, I'd been working there for about four months at this point, and Senior rear end in a top hat had been there from the beginning (three or four years). He dictated how I had to implement this, which was that users would be uploading videos to the company's youtube account. I pointed out that users would upload copyrighted pornography and get our account deleted, and he said that we'd delete any offending videos before youtube could flag them (which is horseshit). I found a post on the youtube api blog saying that this would be a terrible idea because users would upload copyrighted pornography to our account (and also we'd probably run into quota issues); instead, we should use youtube direct (lite), which is just an iframe that lets users upload videos to their account after which we could optionally add the video to a playlist on our account (but if the video was copyrighted pornography then the user would be dinged, not us), which would also be much faster because the user would upload the video directly to youtube instead of uploading it to our server where we'd then upload it to youtube. But Senior rear end in a top hat knew better than the youtube api team, and the one person who was senior to him who could overrule him didn't want to get involved, so I could either do it the wrong way or quit - I didn't think this was anything that was stupid enough that we'd get sued over it (as opposed to, say, storing credit cards in plaintext), so I opted for the former.

At this point I was debating whether to sabotage the functionality after it was released to production by uploading a bunch of copyrighted pornography and getting our account deleted - I'd rather that the functionality break sooner (when we'd lose a day's worth of uploaded videos, most of which users would still have on their hard drives) rather than later (when we'd lose a month's worth of uploaded videos). Fortunately it never came to that, because Senior rear end in a top hat couldn't figure out how to set up our OAuth tokens and didn't trust anybody else to do it, and so the project quietly died.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀

Bognar posted:

I've always hated that browsers default the confirm buttons to OK and Cancel. And there's no good way that I know of in JS to do a blocking dialog where you can specify your own button text.

That's it. This one sort of dialogue blocks execution, whereas every other kind of dialogue box works through callbacks.

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


lord funk posted:

[Cancel] is fine, but [OK] is always a terrible button. It should always be active, like [Delete] or [Remove] or [Clear], so I don't even have to read the message text at all.

You know, I 100% agree. But the phrasing of the question is important so that if you do read the message you don't get confused. Cancel is actually fine if you adhere to the "avoid double negatives" rule.

QuarkJets
Sep 8, 2008

Ruzihm posted:

That's just sad.

That's a lesson to avoid any use of the word "cancel" to avoid ambiguity. Also, keep away from negative questions so you don't get your users into double-negative territory! Something along the lines of "This will empty your cart completely. Continue?" would be great.

Would you like to cancel the cancellation of the original cancellation?

Ruzihm
Aug 11, 2010

Group up and push mid, proletariat!


QuarkJets posted:

Would you like to cancel the cancellation of the original cancellation?

Azerban
Oct 28, 2003



lord funk posted:

[Cancel] is fine, but [OK] is always a terrible button. It should always be active, like [Delete] or [Remove] or [Clear], so I don't even have to read the message text at all.

lord funk
Feb 16, 2004

There was an old Mac program called Hyperupic that converted images to sound. It was a really cool tool, but the author decided to be wacky and give all the alert buttons names like [Rock It!] and [Get Outta Here] and [Dang].

What was amazing is that you would work measurably slower in the app because you kept getting tripped up by the alert names.

qntm
Jun 17, 2009

lord funk posted:

There was an old Mac program called Hyperupic that converted images to sound. It was a really cool tool, but the author decided to be wacky and give all the alert buttons names like [Rock It!] and [Get Outta Here] and [Dang].

What was amazing is that you would work measurably slower in the app because you kept getting tripped up by the alert names.

This is one of my minor UI irritations right now. Words like "OK", "Cancel", "Yes" and "No" are generally fairly neutral, but if you start getting creative then it does start tripping people up, as you mentioned, but it's also effectively putting words in the user's mouth, words that the user doesn't necessarily want there. Google seems to have made a global habit out of putting "Got it" instead of "OK" on all of their acknowledgement buttons, which irks me because "Got it" simply is not me.

Worse, occasionally I see UIs where the acknowledgement button says "Thanks!", which is a great way to make people angry if they aren't particularly grateful for whatever it is the software just did, or if they're already angry at or frustrated with the software for any reason.

I think UI designers think that this kind of thing equates to user-friendly software, but what it actually is is making the user be friendly to the software. Bearing in mind how much most of us hate almost all software, this is a bad road to start down.

This said, I am okay with that one JavaScript dialogue box only having two hard-coded options, "OK" and "Cancel", because I believe that if you can't phrase your prompt in such a way that these two options are totally unambiguous, then you need to rephrase your prompt.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

qntm posted:

This said, I am okay with that one JavaScript dialogue box only having two hard-coded options, "OK" and "Cancel", because I believe that if you can't phrase your prompt in such a way that these two options are totally unambiguous, then you need to rephrase your prompt.

But why not "Yes" and "No"? It seems like the obvious choice when the question for confirmation is almost always "Are you sure..."

ExcessBLarg!
Sep 1, 2001

Bognar posted:

But why not "Yes" and "No"?
"Cancel" is at least recognized as "don't proceed with any changes" and is (usually) a safe answer to any question about a potentially-dangerous operation.

The problem with "Yes" an "No" is that questions can, and are worded such that it's unclear which of "Yes" or "No" is the less-dangerous operation.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

I never thought I'd hear an earnest argument against verb buttons but here we are.

Adbot
ADBOT LOVES YOU

lord funk
Feb 16, 2004

carry on then posted:

I never thought I'd hear an earnest argument against verb buttons but here we are.

It belongs in this thread because it really is a coding horror to see three paragraphs of dialog alert text with [YES] [NO] at the bottom of it, and every developer should know that.

1000x this:

ExcessBLarg! posted:

"Cancel" is at least recognized as "don't proceed with any changes" and is (usually) a safe answer to any question about a potentially-dangerous operation.

The problem with "Yes" an "No" is that questions can, and are worded such that it's unclear which of "Yes" or "No" is the less-dangerous operation.

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