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
necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
I fear most the programmer that does not think what they wrote is a mistake.

Adbot
ADBOT LOVES YOU

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!
It's really amazing how many times I'll write something and think it's pretty great, only to look at it the next day (or week, month, whatever) and wonder who the hell could ever write such garbage.

canis minor
May 4, 2011

The more experience I gain, the less impactful are the mistakes that I make, at least I think. I've also learned to accept that mistakes will be made, to never be sure about anything and to test, test, test, document, document and test that code.

Vanadium
Jan 8, 2005

Apologism: I figure you make a lot of tiny tradeoffs that were correct, but aren't obvious or even applicable anymore when you come back months later.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Vanadium posted:

Apologism: I figure you make a lot of tiny tradeoffs that were correct, but aren't obvious or even applicable anymore when you come back months later.

This is an insightful point that rings true to me as an explanation for at least part of the phenomenon of "WTF did i write?".

LLSix
Jan 20, 2010

The real power behind countless overlords

TooMuchAbstraction posted:

Ten thousand mistakes!

Or to put it another way, it is entirely possible to make a ton of mistakes and still not be an expert at anything other than loving up.

This is a pretty awesome site. Thanks for linking it, I'd never read it before.

Plorkyeran
Mar 22, 2007

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

LongSack posted:

I have yet to come across a problem that required functional programming. Quite probably, this is because of the types of problems that I need to solve.

I have yet to come across a problem that required any specific style of programming. I'm not sure how such a problem could even exist.

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

Plorkyeran posted:

I have yet to come across a problem that required any specific style of programming. I'm not sure how such a problem could even exist.

About all I can think of is enforced domain-specific styles, like having to write assembly because your target platform doesn't have a compiler.

LLSix posted:

This is a pretty awesome site. Thanks for linking it, I'd never read it before.

I would take its stories with a grain of salt, but they can be amusing and occasionally insightful.

Doc Hawkins
Jun 15, 2010

Dashing? But I'm not even moving!


Kilson posted:

It's really amazing how many times I'll write something and think it's pretty great, only to look at it the next day (or week, month, whatever) and wonder who the hell could ever write such garbage.

:same: but also :therapy:

hyphz
Aug 5, 2003

Number 1 Nerd Tear Farmer 2022.

Keep it up, champ.

Also you're a skeleton warrior now. Kree.
Unlockable Ben

VikingofRock posted:

I'd argue that LISPs have very nice syntax. Sure there are a lot of parentheses, but the syntactical simplicity makes it very easy to tell what is going on.

It does get a bit bothersome when some commands break the syntax rules. Setq/setf are way harder to understand as exceptions than they need to be.

vOv
Feb 8, 2014

VikingofRock posted:

the syntactical simplicity makes it very easy to tell what is going on.

Don't worry, all the macros fix that.

code:
(loop for x from 1 to 5
      for y = (* x 2)
      collect y)
Which of those tokens are quoted and which aren't? Who knows!

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
Ruby def with no closing parentheses on the arg list? Real easy to read. :psyduck: And no parentheses on the function call, that took a few looks. He who wrote this mess has clearly never tried to support it.

Ghost of Reagan Past
Oct 7, 2003

rock and roll fun
Just lol if you don't laugh at your dumb coding mistakes from last week.

Because we all make mistakes, what matters is how we handle them.

Absurd Alhazred
Mar 27, 2010

by Athanatos

Ghost of Reagan Past posted:

Just lol if you don't laugh at your dumb coding mistakes from last week.

Because we all make mistakes, what matters is how we handle them.

I joke about my dumb coding mistakes with the other coders all the time.

Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
People always wonder why I'm so great at debugging stuff. My secret is that I've spent over ten thousand hours debugging my own gently caress ups...

dougdrums
Feb 25, 2005
CLIENT REQUESTED ELECTRONIC FUNDING RECEIPT (FUNDS NOW)
I was debugging a rather hastily written program; I can't remember what the problem was, but I fixed it right away and left a comment with the problem. A coworker was surprised that I fixed it that quickly, and I was like, "yeah, I've made that same mistake like 100 times so it went pretty quick this time."

Honestly I'd say the mark of a good programmer is the having the ability to use debugging tools effectively.

hyphz
Aug 5, 2003

Number 1 Nerd Tear Farmer 2022.

Keep it up, champ.

Also you're a skeleton warrior now. Kree.
Unlockable Ben
This is just currently making my head ache.

code:

  void addressCalc(byte[] array, int i) {
        int n = 3;
        for (int j = 0; j < array.length; ++j) {
            array[j] = 0;
        }
        while (i != 0) {
            array[n] = (byte)(i & 0x7F);
            i >>= 7;
            --n;
        }
    }

 void FillFirstAddressRQ(byte[] array) {
        array[0] = -16;
        array[1] = 65;
        array[2] = 16;
        array[3] = 0;
        array[5] = (array[4] = 0);
        array[6] = 57;
        array[7] = 17;
    }

  long fromNibbleLongToLong(int n, long n2) {
        long n3 = 0L;
        for (int i = 0; i < n; ++i) {
            n3 = (n3 << 7 | (n2 >> 8 * (n - (i + 1)) & 0x7FL));
        }
        return n3;
    }
    
int ReadSysexcMasterTune() {
        byte[] array = new byte[4];
        addressCalc(array, 5);
        byte[] array2 = new byte[firstAddressLength + 4 + array.length + 1 + 1];
        FillFirstAddressRQ(array2);
        long n = fromNibbleLongToLong(4, 3145728L) + fromNibbleLongToLong(4, 262144L);
        byte[] array3 = new byte[4];
        fromLongToNibble(4, array3, n);
        PrepareSysexc(array3[3], array3[2], array3[1], array3[0], array, array.length, array2);
        return 1;
    }
... and it goes on with ridiculous combinations of bit shifting that I'm sure could be combined MUCH more nicely.

FrantzX
Jan 28, 2007
code:
 void FillFirstAddressRQ(byte[] array) {
        array[0] = -16;
        array[1] = 65;
        array[2] = 16;
        array[3] = 0;
        array[5] = (array[4] = 0);
        array[6] = 57;
        array[7] = 17;
    }
Shouldn't that be
code:
array[5] = (array[4] == 0);
?

Colonel Taint
Mar 14, 2004


It looks like they're filling in all the values of the array and just assigning array[5] = array[4] = 0;

I don't get why the same isn't done with array[3] though if this is the case. Or why the parentheses are there.

LLSix
Jan 20, 2010

The real power behind countless overlords

Colonel Taint posted:

It looks like they're filling in all the values of the array and just assigning array[5] = array[4] = 0;

I don't get why the same isn't done with array[3] though if this is the case. Or why the parentheses are there.

Someone thinks they're being clever.

FrantzX posted:

code:
 void FillFirstAddressRQ(byte[] array) {
        array[0] = -16;
        array[1] = 65;
        array[2] = 16;
        array[3] = 0;
        array[5] = (array[4] = 0);
        array[6] = 57;
        array[7] = 17;
    }
Shouldn't that be
code:
array[5] = (array[4] == 0);
?
I'm horrified that they're not passing in the array length or have any sort of null check.

FrantzX posted:

Shouldn't that be
code:
array[5] = (array[4] == 0);
?
I think Colonel Taint is right based on what the surrounding code is doing. But there are no comments so the original programmer could have just as easily meant to use == and left array[4] unmodified. Those values are all bonkers so who knows.

Ranzear
Jul 25, 2013

https://blog.fuzzing-project.org/60-Optionsbleed-HTTP-OPTIONS-method-can-leak-Apaches-server-memory.html

tl;dr: Any bad method on a Limit directive in any .htaccess file causes Apache to spew random memory to an OPTIONS request.

Bonus: The methods for Limit are case sensitive.

Beef
Jul 26, 2004

vOv posted:

Don't worry, all the macros fix that.

code:
(loop for x from 1 to 5
      for y = (* x 2)
      collect y)
Which of those tokens are quoted and which aren't? Who knows!

Oh loop macro, how I miss thee :sigh:. The loop syntax was the only documentation I printed out and hung up on the wall behind me. Working with python relatively anemic loop constructs has made me literally look back fondly.

On the topic of syntax and macros: syntactic simplicity/uniformity is an important element in enabling user-defined syntactic abstractions. Any small additional syntactic element complicates doing macros in your language.

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

Beef posted:

Oh loop macro, how I miss thee :sigh:. The loop syntax was the only documentation I printed out and hung up on the wall behind me. Working with python relatively anemic loop constructs has made me literally look back fondly.

You could use Go, which only has for loops! :haw:

Pollyanna
Mar 5, 2005

Milk's on them.


Not quite coding but

https://twitter.com/selenalarson/status/910536229451579393

Nude
Nov 16, 2014

I have no idea what I'm doing.

TooMuchAbstraction posted:

You could use Go, which only has for loops! :haw:

And it doesn't support the traditional syntax for(var i = 0; i < max; i++) right? Kind of curious if in that environment it's because it's rarely needed or if it's just a really weird opinion on what for loops should be.

Eela6
May 25, 2007
Shredded Hen
No, go supports traditional loops.


code:

for i:=0; i<5; i++ {
    //foo
}

does exactly what you'd expect.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!

Eela6 posted:

No, go supports traditional loops.
code:

for i:=0; i<5; i++ {
    //foo
}
does exactly what you'd expect.

I'd expect it to throw a compiler parsing error for missing parentheses and a warning about superfluous spaces. :shrug:

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

PhantomOfTheCopier posted:

I'd expect it to throw a compiler parsing error for missing parentheses and a warning about superfluous spaces. :shrug:

Go will yell at you for putting the parentheses in.

McGlockenshire
Dec 16, 2005

GOLLOCKS!
So are there any actual upsides to Go because all I ever hear about it is whining. Or (realtalk) is it like PHP in that it does what it does very well but anyone well versed in it is going to hate it?

Eela6
May 25, 2007
Shredded Hen

McGlockenshire posted:

So are there any actual upsides to Go because all I ever hear about it is whining. Or (realtalk) is it like PHP in that it does what it does very well but anyone well versed in it is going to hate it?

It's the latter. Go is good for simple things that you want to compile to a binary. If you want to work on the back-end, you could do a lot worse.

It works just fine, it's just ugly, boring and verbose (but nor as verbose as Java).

Go is infuriating because it's not too hard to see a world where it's actually good, rather than 'fine, I guess'.

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

McGlockenshire posted:

So are there any actual upsides to Go because all I ever hear about it is whining. Or (realtalk) is it like PHP in that it does what it does very well but anyone well versed in it is going to hate it?

It's pretty easy to deploy, it's strongly-typed, it has decent webserver libraries, probably a few more benefits that I haven't encountered because they're outside my use cases. Honestly I think a lot of the griping is because people want something like Go, but they didn't want all the weird decisions it made. If it had been an actually awful language then nobody would use it and so there'd be no complaints. Instead it feels like it's legitimately close to being a really good language, if only they'd done things a bit differently.

chutwig
May 28, 2001

BURLAP SATCHEL OF CRACKERJACKS

Eela6 posted:

Go is infuriating because it's not too hard to see a world where it's actually good, rather than 'fine, I guess'.

The #1 thing requested on the user survey is "generics", so if Rob Pike can get over himself in time for Go 2.0, maybe there's some hope? Personally, not having generics hasn't honestly bothered me. If I were given a choice between generics or better package management/richer ways of dealing with slices/better error handling, I would pick any one of those three as a bigger priority. My primary gripe is the amount of boilerplate that Go mandates, to the point where it feels like the language actively encourages copypasta.
code:
if someShit, err := doAThing(toAThing); err == nil {
    // you win
} else {
    // world is on fire
}
REPEAT FOUR HUNDRED TIMES

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
Generics are what keep the language from having better slices, functional-style programming, and a bunch of other juicy stuff. The lack of good exceptions/error handling is irritating, absolutely, but generics are waaaaay more important.

Sadly, I hear (thirdhand, so grain of salt and all that) that the way Go is implemented makes generics really hard to add, so I'm not holding my breath for them to be added. :(

Coffee Mugshot
Jun 26, 2010

by Lowtax

chutwig posted:

The #1 thing requested on the user survey is "generics", so if Rob Pike can get over himself in time for Go 2.0, maybe there's some hope? Personally, not having generics hasn't honestly bothered me. If I were given a choice between generics or better package management/richer ways of dealing with slices/better error handling, I would pick any one of those three as a bigger priority. My primary gripe is the amount of boilerplate that Go mandates, to the point where it feels like the language actively encourages copypasta.
code:
if someShit, err := doAThing(toAThing); err == nil {
    // you win
} else {
    // world is on fire
}
REPEAT FOUR HUNDRED TIMES

I don't why people refer to Rob Pike so much when he hasn't worked on the project for like a year at this point. Also, your code sample is completely the opposite of what is recommended. Go has a lot of warts or w/e, but sometimes y'all write incredibly strange code just in general. Write something like this instead
code:
someShit, err := doAThing(toAThing)
if err != nil {
   // world is on fire
}
Generic containers are something Go2 needs to address in a serious way. Go isn't implemented in some way that makes generics hard to add, but generics are really pervasive and aren't really something you add to any sort of language as an afterthought. It turns out, generic implementation are very difficult and I'm sure the Java and C++ experts who have followed the ways those language's generic implementations have trended and churned over time can probably speak to that in a serious way.

Anyways, I suggest people just read Ian Lance Taylor's many generic proposals, such as https://github.com/golang/proposal/blob/master/design/15292-generics.md if they actually care about this problem. Something something metaprogramming and parametric polymorphism. For the record, we wanted to try the same approach as C++ wants to eventually do with concepts (http://en.cppreference.com/w/cpp/language/constraints), but it didn't work out. Oh well.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
I love this example because in one short source file it does a lovely job of illustrating that Rob Pike has a weak grasp of functional idioms, zero self-awareness and that his language is extremely clunky to use:

https://github.com/robpike/filter/blob/master/reduce.go

rob pike posted:

I wanted to see how hard it was to implement this sort of thing in Go, with as nice an API as I could manage. It wasn't hard.

Having written it a couple of years ago, I haven't had occasion to use it once. Instead, I just use "for" loops.

You shouldn't use it either.

JewKiller 3000
Nov 28, 2006

by Lowtax

quote:

someShit, err := doAThing(toAThing)
if err != nil {

we have had an unequivocally better solution to this problem since the nineteen-loving-seventies. designing this "idiom" into a new language is absolutely inexcusable

KernelSlanders
May 27, 2013

Rogue operating systems on occasion spread lies and rumors about me.

JewKiller 3000 posted:

we have had an unequivocally better solution to this problem since the nineteen-loving-seventies. designing this "idiom" into a new language is absolutely inexcusable

What "unequivocally better solution" are you referring to?

Please don't say exceptions because those are also horrible and go recognized the problem, but like everything else in that language the attempted fix fell way short of its potential.

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
I would have said monads, but those are a slightly more recent development.

nielsm
Jun 1, 2009



JewKiller 3000 posted:

we have had an unequivocally better solution to this problem since the nineteen-loving-seventies. designing this "idiom" into a new language is absolutely inexcusable

What did programmers do when Java gave them checked exceptions?

try { thingThatCanFail(); } catch (Exception e) { /* gotta catch 'em all */ }

Adbot
ADBOT LOVES YOU

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

nielsm posted:

What did programmers do when Java gave them checked exceptions?

try { thingThatCanFail(); } catch (Exception e) { /* gotta catch 'em all */ }

I fail to see how this is any worse (or better) than the Go equivalent:
code:
foo, _ := thingThatCanFail(); // second return val is an error, but who cares?
The thing that bugs me most about Go's error handling is that you don't get stack traces out of it. Like, the zero-effort thing to do with exceptions is just let them propagate up to a top-level exception handler, which then says "hey, this function buried ten levels deep in your program tried to use a dead network connection on line 128 of db.java, you dumbass." Whereas in Go you have to do stuff like this for every single function call:
code:
if err := doAThing(); err != nil {
  return fmt.Errorf("couldn't doAThing: %s", err)
}
And then you get to decipher the corresponding top-level message: "couldn't process request: couldn't retrieve customer details: couldn't get customer ID: couldn't doAThing: database connection went away". And if you don't write a little description for each error, and instead just return the bare error, then you get errors like "couldn't process request: database connection went away", which is absolutely inscrutable.

Languages should make it easy to do the right thing. But far more important than making it easy to do the right thing is making it harder to do the wrong thing. Go's mistake here is that the mechanism it came up with becomes useless when misused, and misusing it is what lazy programmers are going to do because it saves them a little typing/thinking in the short term.

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