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
Doctor w-rw-rw-
Jun 24, 2008

Jewel posted:

Any good resources to learn it easily with no prior knowledge in anything of the sort? I know what a commit, a checkout, and a branch is. That's about it. I usually only use the bare minimum when it comes to SVN/Perforce, and I do it all visually, so going to a command line interface like GIT is daunting.

Also, using Windows 7, if that means anything.
This presentation is good for the programming-minded, but may or may not be intro-level:
https://www.youtube.com/watch?v=P3_ISMGXTBg
https://github.com/schacon/git-presentations/tree/master/railsconf08

This is, however, absolutely necessary for anyone who uses git from day to day. Worth the one hour to understand Git more deeply, definitely.

Thermopyle posted:

Anytime I encounter code along those lines I shake my fist at the sky.

I don't encounter other people's code that often as I usually work by myself, but the frequency with which I do encounter such a mess makes me wonder how any of you working in teams can handle it.
Well, to be fair, I haven't worked on a team in a while (because I was forced onto Android basically solo), and I'm not working, either, as I don't have a job. But it does IMO reflect Java's particular kind of enterprise-level shittiness, where interface stability actually matters, and huge APIs are published before they've had time to bake. Try looking at some of the more enterprisey frameworks for stuff and then find your eyes bleeding.

(BTW Android is a perfect example of lovely APIs made by inept buffoons who locked it into compatibility forevermore)

Doctor w-rw-rw- fucked around with this message at 16:30 on May 7, 2013

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...

hobbesmaster posted:

Its xchg eax, eax of course!

But uh, seriously don't write xor swap or inline asm for this poo poo. If its even a correct answer its likely not faster than what the compiler has for swap and a rather extreme example of premature optimization.

The best is when you pass xor swap two pointers to the same location which will silently zero it out.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Doctor w-rw-rw- posted:

This presentation is good for the programming-minded, but may or may not be intro-level:
https://www.youtube.com/watch?v=P3_ISMGXTBg
https://github.com/schacon/git-presentations/tree/master/railsconf08

This is, however, absolutely necessary for anyone who uses git from day to day. Worth the one hour to understand Git more deeply, definitely.

Well, to be fair, I haven't worked on a team in a while (because I was forced onto Android basically solo), and I'm not working, either, as I don't have a job. But it does IMO reflect Java's particular kind of enterprise-level shittiness, where interface stability actually matters, and huge APIs are published before they've had time to bake. Try looking at some of the more enterprisey frameworks for stuff and then find your eyes bleeding.

(BTW Android is a perfect example of lovely APIs made by inept buffoons who locked it into compatibility forevermore)

Java in general has a shitton of features that have been @deprecated since 1.1, but never removed. I admire the developers of Qt for actually daring to make API breaking changes between major versions.

Munkeymon
Aug 14, 2003

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



Jewel posted:

Also, using Windows 7, if that means anything.

It means you're a second-class citizen in git-land. Gitizen? Whatever - Mercurial works basically the same way (internally - actual commands issued will be different) and its extensions are less likely to be broken on Windows, so maybe consider that, too or instead of.

GentlemansSleepover
Apr 26, 2010

Ithaqua posted:

My ultimate response (after eliminating all of the "reflective surfaces" options) was to suggest that every person on the island pull out one of their eyes. This met with a horrified expression. I did not receive an offer.

You are my hero, I'd have offered you the job on the spot.

Suspicious Dish
Sep 24, 2011

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

Jewel posted:

Any good resources to learn it easily with no prior knowledge in anything of the sort? I know what a commit, a checkout, and a branch is. That's about it. I usually only use the bare minimum when it comes to SVN/Perforce, and I do it all visually, so going to a command line interface like GIT is daunting.

Also, using Windows 7, if that means anything.

git on Windows still isn't the best...

Just a friendly warning.

zeekner
Jul 14, 2007

Wait, what? Git on Win 7 works just as well as on linux or OSX for me. What exactly is broken?

TortoiseGit 4 lyfe.

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

Munkeymon posted:

It means you're a second-class citizen in git-land. Gitizen? Whatever - Mercurial works basically the same way (internally - actual commands issued will be different) and its extensions are less likely to be broken on Windows, so maybe consider that, too or instead of.

Not really so anymore. Github for Windows solves most of the problem. It gets you a nice GUI, msysgit, and posh-git (Powershell git for commandline) installed.

The Pro git book was pretty helpful.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Salvador Dalvik posted:

Wait, what? Git on Win 7 works just as well as on linux or OSX for me. What exactly is broken?
It's kinda slow, but not to a degree that actually matters very often. If anything the main problem with git on Windows is that it works exactly the same as git on other OSes and Windows users are less likely to be comfortable with a bash shell. autocrlf was buggy for a while, but that was fixed years ago.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I remember having some issues with GitHub for Windows with some of the more obscure commands, like git format-patch, git am, etc.

hobbesmaster
Jan 28, 2008

Wheany posted:

Java in general has a shitton of features that have been @deprecated since 1.1, but never removed. I admire the developers of Qt for actually daring to make API breaking changes between major versions.

I liked how at one point they marked QSettings for removal in Qt5 and stated they had no intention to replace it.

This was backtracked reasonably quickly.

Jewel
May 2, 2009

I tried GitHub For Windows a while back, and while I really liked it for easily checking out branches, and a fairly nice layout, it was missing a LOT of features (I couldn't even find many good diff features? Like you had to only view the commits and had no way of viewing history/diffs for a specific file iirc. Also like no special features other than commit and checkout?)

No Safe Word
Feb 26, 2005

Jewel posted:

I tried GitHub For Windows a while back, and while I really liked it for easily checking out branches, and a fairly nice layout, it was missing a LOT of features (I couldn't even find many good diff features? Like you had to only view the commits and had no way of viewing history/diffs for a specific file iirc. Also like no special features other than commit and checkout?)

Not exactly a coding horror though? :confused:

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
code:
AtomicBoolean registeredWithFoo = new AtomicBoolean(false);

private void addBar(...) {
  ...
  if(!registeredWithFoo.get()) {
    foo.addCallback(this);
    registeredWithFoo.set(true);
  }
  ...
}
:cripes:

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
e: oh

Janitor Prime fucked around with this message at 18:27 on May 7, 2013

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
"How is that not thread-safe? I'm using an ATOMIC boolean, right there!"

Munkeymon
Aug 14, 2003

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



gariig posted:

Not really so anymore. Github for Windows solves most of the problem. It gets you a nice GUI, msysgit, and posh-git (Powershell git for commandline) installed.

The Pro git book was pretty helpful.

Did they fix the thing where cloning a repo also marked most of it as modified? There's no loving way I'm going to deal with that poo poo otherwise. SourceTree seems pretty nice, though.

I was also talking about git extensions like the one that, IIRC, was mentioned a few pages ago. There's no windows port which is only required because there's no cross-platform git. Mercurial extensions are usually Python and so will run as long as mercurial itself runs and that cross-platform compatibility, in my mind, makes it a better piece of software than git. Not that that matters much - they're both basically the same so they're both great, but in my opinion the wrong one 'won' somehow. Maybe Ruby people turned up their noses at using a Python based tool and drove adoption?

E: http://whatthecommit.com/125242ec6ea1910024a0166ae01ff9c5 actually is valid in many cases but lacking the profanity IE deserves.

Munkeymon fucked around with this message at 18:25 on May 7, 2013

Scaevolus
Apr 16, 2007

Volte posted:

The naive (and correct) solution is std::swap(a, b);
just use STL types, do swap(a, b); and let ADL sort it out

hobbesmaster
Jan 28, 2008

ADL is in the running with vector<bool> as the most ill advised feature in C++.

That Turkey Story
Mar 30, 2003

hobbesmaster posted:

ADL is in the running with vector<bool> as the most ill advised feature in C++.

Not really. ADL is very important, although it does mean that you should qualify your calls much more than people do in practice.

b0lt
Apr 29, 2005

hobbesmaster posted:

ADL is in the running with vector<bool> as the most ill advised feature in C++.

Operator overloading on &&, ||, and , is pretty loving stupid.

That Turkey Story
Mar 30, 2003

b0lt posted:

Operator overloading on &&, ||, and , is pretty loving stupid.

:confused: Why do you think overloading || and && is bad?

b0lt
Apr 29, 2005

That Turkey Story posted:

:confused: Why do you think overloading || and && is bad?

code:
#include <stdlib.h>

struct TrueObject {
    operator bool(void) const { return true; }
    bool operator &&(bool rhs) const { return bool(*this) && rhs; }
};

int main(void) {
    TrueObject() && system("rm -rf /");
}

That Turkey Story
Mar 30, 2003

b0lt posted:

code:
#include <stdlib.h>

struct TrueObject {
    operator bool(void) const { return true; }
    bool operator &&(bool rhs) const { return bool(*this) && rhs; }
};

int main(void) {
    TrueObject() && system("rm -rf /");
}

Not exactly seeing your point, here, nor an example that makes any practical sense.

b0lt
Apr 29, 2005

That Turkey Story posted:

Not exactly seeing your point, here, nor an example that makes any practical sense.

The entire point of operator && is shortcircuiting, and overloaded operator && explicitly doesn't shortcircuit.

hobbesmaster
Jan 28, 2008

That Turkey Story posted:

Not exactly seeing your point, here, nor an example that makes any practical sense.

And "you can make something do something else" isn't much of an argument.

Flobbster
Feb 17, 2005

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

That Turkey Story posted:

Not exactly seeing your point, here, nor an example that makes any practical sense.

The example is a bit contrived but I think the problem in general is that short-circuiting isn't guaranteed (in fact, it's not possible) for overloaded && and || because both sides must be evaluated to form the argument list for the operator method. At the very least, it violates the Principle of Least Surprise.

edit: beaten because I'm SO VERBOSE

That Turkey Story
Mar 30, 2003

b0lt posted:

The entire point of operator && is shortcircuiting, and overloaded operator && explicitly doesn't shortcircuit.

No, that's how && and || apply to bool. When you overload the operator in a different domain, you shouldn't expect it to be the same. It's a similar reason to why it's not a "bad idea" to overload operator + for strings.

Opinion Haver
Apr 9, 2007

You shouldn't operate + for strings because strings don't form a group under concatenation :colbert:

Suspicious Dish
Sep 24, 2011

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

That Turkey Story posted:

No, that's how && and || apply to bool. When you overload the operator in a different domain, you shouldn't expect it to be the same. It's a similar reason to why it's not a "bad idea" to overload operator + for strings.

But there's *no way* to ask for short circuiting behavior.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

That Turkey Story posted:

No, that's how && and || apply to bool. When you overload the operator in a different domain, you shouldn't expect it to be the same. It's a similar reason to why it's not a "bad idea" to overload operator + for strings.

Sed contra, if the behavior of the operator in a different domain isn't similar to its behavior in the domain where it is already defined, you shouldn't overload it in that domain.

That Turkey Story
Mar 30, 2003

Suspicious Dish posted:

But there's *no way* to ask for short circuiting behavior.

Yeah, and??? That doesn't change anything.

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

yaoi prophet posted:

You shouldn't operate + for strings because strings don't form a group under concatenation :colbert:

They totally can, though, if you introduce strings where every element can either be positive or negative. If a positive character is next to a negative character with the same character value, then the two cancel out and the string gets shorter. Such strings are a trivial generalization of "normal" (or "strictly positive") strings, and readily form a group under concatenation.

They also let you unprint stuff, or untransmit things from the network. Obviously a useful feature, hopefully we'll see these in C++14.

shrughes
Oct 11, 2008

(call/cc call/cc)

That Turkey Story posted:

No, that's how && and || apply to bool. When you overload the operator in a different domain, you shouldn't expect it to be the same. It's a similar reason to why it's not a "bad idea" to overload operator + for strings.

&& and || short-circuit with non-booleans all the time.

Dren
Jan 5, 2001

Pillbug

Otto Skorzeny posted:

Sed contra, if the behavior of the operator in a different domain isn't similar to its behavior in the domain where it is already defined, you shouldn't overload it in that domain.

Hello, boost::filesystem::path and operator/.

That Turkey Story
Mar 30, 2003

hobbesmaster posted:

And "you can make something do something else" isn't much of an argument.

It's exactly as acceptable as it is for overloading of functions in general. Perhaps, though, you think that general function overloading isn't a good idea because it "makes something do something else." All an operator is is a function with a fancy name/syntax.

shrughes
Oct 11, 2008

(call/cc call/cc)

That Turkey Story posted:

It's exactly as acceptable as it is for overloading of functions in general.

No it's not, stop being retarded. It affects control flow. Other overloadings do not and are plain function calls.

tractor fanatic
Sep 9, 2005

Pillbug

ShoulderDaemon posted:

They totally can, though, if you introduce strings where every element can either be positive or negative. If a positive character is next to a negative character with the same character value, then the two cancel out and the string gets shorter. Such strings are a trivial generalization of "normal" (or "strictly positive") strings, and readily form a group under concatenation.

They also let you unprint stuff, or untransmit things from the network. Obviously a useful feature, hopefully we'll see these in C++14.

But it doesn't form an Abelian group, which is what you use + for.

That Turkey Story
Mar 30, 2003

shrughes posted:

No it's not, stop being retarded. It affects control flow. Other overloadings do not and are plain function calls.

So what? Hypothetically, if && and || didn't short-circuit in C++ (as is the case for logical or and logical and in plenty of other languages), then would you consider these to be acceptable overloads? I don't see how that matters at all in theory nor in practice. When you see || and && in places that don't deal with bool you don't freak out about short-circuiting. It simply doesn't apply to those types.

Adbot
ADBOT LOVES YOU

Van Kraken
Feb 13, 2012

tractor fanatic posted:

But it doesn't form an Abelian group, which is what you use + for.

It's settled, we're using * for string concatenation now.

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