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
Thermopyle
Jul 1, 2003

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

Bleh, the whole attitude that makes people resistant to libraries sucks. Use a goddamn library, losers.

(I can see being cautious about adding another dependency, and how big a deal that is will depend on your environment, audience, and product.)

Adbot
ADBOT LOVES YOU

JawnV6
Jul 4, 2004

So hot ...
Huh, I could use a library, glue poo poo together, and be done today. Oooooor I could rewrite all the functionality myself and be entertained all week!!

Zombywuf
Mar 29, 2008

There is also the issue that some libraries are awful, which some people use as an excuse to never use another one. Which is somewhat understandable, imagine if your first exposure to a library was urllib2.

Plorkyeran
Mar 22, 2007

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

That Turkey Story posted:

I guess, but on the other hand, when a library is small I often hear a similar but opposite rationale to avoid it, perhaps especially if the problem is seemingly simple:

Why would I use <some small library>? It's simple enough that I can replicate its capabilities with a handful of functions without pulling in a dependency.

Really, in my experience it's just difficult to get people to use a library period. I spend a lot of time bug-fixing or rewriting functions of freely available libraries for projects because people don't want to use them, even if the quality is high and licensing is free of restrictions. The size of a library is often referenced whether large or small.

In the specific case of C and C++, this is because dependency management is terrible. In Python, Ruby, Javascript, Objective-C (and a bunch of other languages I haven't used for real projects), adding a new dependency consists of adding a single line to the config file and everything just works. Unsurprisingly, it's common to end up with small projects that use 30 simple single-purpose libraries.

In C++ I have to add poo poo to the configure script for each library (which may involve writing some custom autoconf macros), telling people where to get the library, describing how to build it (because Debian only has a 8-year-old version of it packaged, and some distros don't have it at all), and now the number of steps involved in building my application is greater than the acceptable maximum (one). Alternatively, I can spend two weeks trying to automate dependency fetching and end up with something that half-works but annoys all the people that want to use the system copies of libraries.

Or I could just spend a few days reinventing the wheel because it's less work than using the existing wheel.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
There's also the problem of ABI bumps. C++ libraries in particular seem to care less about ABI stability, where libstdc++ will get a soname bump and the rest of the world will have to rebuild to accommodate. Complexity of dynamic linking, especially when caring about Windows / POSIX portability, is such a hassle that sometimes long dependency chains are hard to manage.

We use a lot of GNU and POSIX libraries in the GNOME/GTK+ stack, but some developers focused on Windows aren't particularly keen about that.

Thermopyle
Jul 1, 2003

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

Zombywuf posted:

Which is somewhat understandable, imagine if your first exposure to a library was urllib2.

Oh man, this is truth.


Plorkyeran posted:

Unsurprisingly, it's common to end up with small projects that use 30 simple single-purpose libraries.

I have a pretty simple database-backed site in Python and the requirements.txt file is 46 lines long.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
And then you get the guy at work that didn't like having to use existing terminal programs and wrote one in Python.

Edit: You know, because it's fast.

Workaday Wizard
Oct 23, 2009

by Pragmatica

Zombywuf posted:

imagine if your first exposure to a library was urllib2.

I once used urllib2 to make a simple web spider but didn't look too deep into it.

What's wrong with it? (Disclaimer: I am not a Python programmer)

QuarkJets
Sep 8, 2008

Thermopyle posted:

Bleh, the whole attitude that makes people resistant to libraries sucks. Use a goddamn library, losers.

(I can see being cautious about adding another dependency, and how big a deal that is will depend on your environment, audience, and product.)

In some lines of work, this can actually be problematic. If you're on an isolated network where installing a new library may be a 3 month process (for example, some government systems), and you just need one function out of that library, it can be easier to just code the function yourself and be done with it.

If you have a library or easy access to a library, then you may as well just use it instead of reinventing the wheel over and over. This was the philosophy behind MIT's change from Scheme to PYthon in their intro programming course. Of course, if getting that library into your build process is actually a week-long project, then it may be better to reinvent the wheel.

xtal
Jan 9, 2011

by Fluffdaddy

Shinku ABOOKEN posted:

I once used urllib2 to make a simple web spider but didn't look too deep into it.

What's wrong with it? (Disclaimer: I am not a Python programmer)

https://gist.github.com/kennethreitz/973705

raminasi
Jan 25, 2005

a last drink with no ice

OzyMandrill posted:

In C++, most operator= overloads I have seen tend to be:
code:
class& class::operator=( const type& )
{
   ...
   return (*this);
}
And if 'type' is different to 'class', then what is passed out must be different to what was passed in.

You would need the extra functions ( like type::operator=(const class&) )to allow the conversion from 'class' back to 'type', and if class was a write-only accessor object, then these probably wouldn't exist.

Well, yeah, it's C++. I wanted to avoid talking about C++ because its assignment behavior is user-definable (at least for non-POD types). Of course, for POD types, I assume it behaves the same way it does for C, where, as it turns out, neither IBM nor Microsoft agree with me (although Wikipedia does!). I'm apparently wrong for Java, but right for C#. And I can't actually find an Objective-C language reference, which is I guess what started all this.

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

GrumpyDoctor posted:

Of course, for POD types, I assume it behaves the same way it does for C, where, as it turns out, neither IBM nor Microsoft agree with me (although Wikipedia does!).
Wikipedia is wrong:

C99 6.5.16 posted:

An assignment expression has the value of the left operand after the assignment, but is not an lvalue.

"C++11 5.17 [expr.rear end posted:

"]All [assignment operators] require a modifiable lvalue as their left operand and return an lvalue referring to the left operand.

Dren
Jan 5, 2001

Pillbug

QuarkJets posted:

In some lines of work, this can actually be problematic. If you're on an isolated network where installing a new library may be a 3 month process (for example, some government systems), and you just need one function out of that library, it can be easier to just code the function yourself and be done with it.

If you have a library or easy access to a library, then you may as well just use it instead of reinventing the wheel over and over. This was the philosophy behind MIT's change from Scheme to PYthon in their intro programming course. Of course, if getting that library into your build process is actually a week-long project, then it may be better to reinvent the wheel.

Hahahahahaha you have the worst job.

HFX
Nov 29, 2004

Dren posted:

Hahahahahaha you have the worst job.

Large corporations often have similar policies I'm finding where I work now. We can't get the lawyers to white list by license type. Instead they want to look over every license for everything we might want to pull in.

Dren
Jan 5, 2001

Pillbug

HFX posted:

Large corporations often have similar policies I'm finding where I work now. We can't get the lawyers to white list by license type. Instead they want to look over every license for everything we might want to pull in.

Yeah, how bad is it? That government stuff he's talking about is awful. Put request in for something incredibly normal like, say, Maven. Hear back 3 months later if you're lucky. gently caress that. Never again.

HFX
Nov 29, 2004

Dren posted:

Yeah, how bad is it? That government stuff he's talking about is awful. Put request in for something incredibly normal like, say, Maven. Hear back 3 months later if you're lucky. gently caress that. Never again.

It is about 1-2 months here at GM. To be fair, they got screwed by a contractor on some source code related to the Volt. However, they should be able to white list things like BSD, Creative Commons, Apache, Eclipse, etc rather then being on a library by library need.

UxP
Aug 27, 2007

xtal posted:

Abusing alias like that is a horror. Especially because if that was properly in a file called git-yolo, you'd be able to use "git yolo" on the command line!

code:
$ cat ~/.gitconfig

...
[alias]
        yolo = !sh -c 'git commit -am \"`curl -s [url]http://whatthecommit.com/index.txt[/url]`\"'

...
It's kinda impossible to subshell from a git alias, but it's possible to call commands directly, making this horror even more of a horror.

Plorkyeran
Mar 22, 2007

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

HFX posted:

Large corporations often have similar policies I'm finding where I work now. We can't get the lawyers to white list by license type. Instead they want to look over every license for everything we might want to pull in.
Are they also evaluating whether or not the license is actually valid and not just some dude slapping a license on something that he doesn't actually own? If so that'd make sense.

leftist heap
Feb 28, 2013

Fun Shoe

JawnV6 posted:

Huh, I could use a library, glue poo poo together, and be done today. Oooooor I could rewrite all the functionality myself and be entertained all week!!

Or better yet, be entertained months/years down the road when your code fails on some corner case you failed to account for, but the library had covered!

My own coding horror lately is the BlackBerry 7 browser which delightfully kills any javascript execution that takes longer than 10 seconds. Of course, this wouldn't be so bad if the actual BB devices weren't painfully slow. Our testing failed to pick this up because the BlackBerry simulators are actually faster than the actual phones. I've had to rewrite a significant portion of an AngularJS application to get the fucker to work on BB7 devices.

ephphatha
Dec 18, 2009




Thermopyle posted:

Bleh, the whole attitude that makes people resistant to libraries sucks. Use a goddamn library, losers.

(I can see being cautious about adding another dependency, and how big a deal that is will depend on your environment, audience, and product.)

Though if you already include a library as a dependency and you reinvent the wheel anyway, gently caress you.

code:
use URI::Encode;

sub encode_url {
  #incomplete implementation of rfc3986 here that could've been replaced by uri_encode
}
(An example from one of the projects at work)

Currently I'm looking through a file that has a whole lot of bad variable/function names. Nothing overly horrifying, but here's a sample of the names used:
date (todays date)
date2 (todays date)
date3 (a date 3 days in the past)
datee (todays date formatted in DD/MM/YYYY)
10_days (a date 50 days in the past)
20_days (a date 40 days in the past)
30_days (a date 30 days in the past)
display_interface (a function that sets the date format mask)
email_header (a function that opens a file)
email_body (a function that builds and sends an email with some complicated logic)
write_header1 (a function that writes the header of an email)
write_header2 (a function that writes the header of an email, one word differs from the above function)
write_header3 (a function that writes the body of an email)
write_body1 (a function that writes the body of an email)
write_body2 (a function that writes a complete email)
write_body3 (a function that writes the body of an email, using the text from write_body1 - copy/pasted - with an added paragraph)
write_textN (four functions that wrote one line each to a file, but are never actually called)

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Ephphatha posted:

10_days (a date 50 days in the past)
20_days (a date 40 days in the past)
30_days (a date 30 days in the past)

Ahaha

"I don't see the problem with this, each function's name says very clearly the number of days since 60 days ago!"

EntranceJew
Nov 5, 2009

Ephphatha posted:

Currently I'm looking through a file that has a whole lot of bad variable/function names. Nothing overly horrifying, but here's a sample of the names used:

It feels like you have a programmer in your midst that doesn't know that they could rename the variables / functions and they have one master template they copy/pasted together seven years ago.

ephphatha
Dec 18, 2009




These are all from an SQR program. SQR defaults to using the global namespace for everything, unless you declare a function as local or specify the parameters it takes. It is very rare to see a function taking explicit parameters in our codebase, so everything is global. You also can't have multiple select statements pull out columns with the same name in the same namespace, so it's common to see things like "&id" "&id2" "&my_func_id" scattered throughout a file.

Hell, thanks to the magic of SQRs concept of includes we have multiple mutually dependent files. File A declares x y z, never uses them. Uses foo bar baz without ever declaring or defining them. File B includes File A and declares foo bar baz, never uses them. File B uses x y z. File C includes File A and declares foo bar baz but uses different values to File B. File C uses x and z only, and in a different context to File B. None of this is documented.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I'm just trying to get over SQR as an actual thing. I had never even heard of it before. Is it actually that common? I'm having a hard time coming to terms with people not technically inclined going way out of their way to find something specialized and obscure and then crapping inside it.

Extortionist
Aug 31, 2001

Leave the gun. Take the cannoli.

quiggy posted:

Smart people use whitespace like this. Dumb people use whitespace like this.
I wish I could dump large bits of my company's codebase on here, because I could demonstrate quite clearly the ways in which dumb people use whitespace.

It doesn't really have anything to do with tabs vs spaces, though--at least where I work, it seems to be more "this script won't run, so I'll just add more braces at the end until it will" kind of stuff.

sturgeon general
Jun 27, 2005

Smells like sushi.
At one of my old jobs, we had a contractor that decided it'd be a good idea to cache employee-specific JSON and HTML data for a Drupal site's header and footer... in a MySQL table.

When I left the table was at least 2 GB. It was also the common cache table for a Wordpress installation. And it was backed up nightly along with the rest of the DB.

sturgeon general fucked around with this message at 07:17 on Aug 16, 2013

Captain Capacitor
Jan 21, 2008

The code you say?

HFX posted:

Large corporations often have similar policies I'm finding where I work now. We can't get the lawyers to white list by license type. Instead they want to look over every license for everything we might want to pull in.

This makes me glad that the big M has pre-approved policies for using OSS.

Releasing code as Open source is another question entirely.

Amarkov
Jun 21, 2010
code:
public static final String STATUS_FINISHED = "STATUS_COMPLETED";

[...]

if(status == "STATUS_FINISH") {
    end();
}
How did this even happen?

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

erotic dad posted:

At one of my old jobs, we had a contractor that decided it'd be a good idea to cache employee-specific JSON and HTML data for a Drupal site's header and footer... in a MySQL table.

When I left the table was at least 2 GB. It was also the common cache table for a Wordpress installation. And it was backed up nightly along with the rest of the DB.

I love the idea of backing up user-specific cached HTML every night. It's just pure essence of incompetence.

Coffee Mugshot
Jun 26, 2010

by Lowtax

Extortionist posted:

I wish I could dump large bits of my company's codebase on here, because I could demonstrate quite clearly the ways in which dumb people use whitespace.

It doesn't really have anything to do with tabs vs spaces, though--at least where I work, it seems to be more "this script won't run, so I'll just add more braces at the end until it will" kind of stuff.

Should've use Go and gofmt, scrubs :smug:

NtotheTC
Dec 31, 2007


Whoops.

Still at least the software was well tested apparently.

E: my friend sold this to me as a Java horror. I'm not too clued up on Java but by the looks of it it could have been easily avoided.

NtotheTC fucked around with this message at 11:42 on Aug 16, 2013

..btt
Mar 26, 2008
That's incredible - "hmm, I just totalled millions of dollars worth of equipment - hire a competent software dev? Re-examine testing methodology? Nah, I'll just post to stack overflow and try again, that'll be cheaper"

xf86enodev
Mar 27, 2010

dis catte!

..btt posted:

That's incredible - "hmm, I just totalled millions of dollars worth of equipment - hire a competent software dev? Re-examine testing methodology? Nah, I'll just post to stack overflow and try again, that'll be cheaper"

True, a smart dev would've posted to SO before trying to run thread-safe Java.

Zombywuf
Mar 29, 2008

Watching Java devs struggle understand concurrent access is just delicious.

Zombywuf
Mar 29, 2008

Today in bad commit messages:

quote:

checking in unknown changes that are hanging around <unnamed machine account>

Drythe
Aug 26, 2012


 
Going through one of our forms to add some functionality and I needed to add an addition to our validate field only to learn this is how the person had programmed it:

code:
var query = (from s in db.junk
                         where s.junk == junk
                         select s).SingleOrDefault();

            if (query != null)
            {
                if (junk.Checked && junk.Checked && junk.Checked && junk.Checked &&
                    junk.Checked && junk.Checked &&
                    !String.IsNullOrEmpty(junk.Text) && !String.IsNullOrEmpty(junk.Text))
                // first text fields
                {
                    if ((Convert.ToBoolean(query.junk) != false || Convert.ToBoolean(query.junk) != false ||
                            Convert.ToBoolean(query.junk) != false || Convert.ToBoolean(query.junk) != false ||
                            Convert.ToBoolean(query.junk) != false || Convert.ToBoolean(query.junk) != false) &&
                            query.junk.ToString().Trim() != "")
                    {
                        if (Convert.ToBoolean(query.junk)) //second text field
                        {
                            if (Convert.ToBoolean(query.junk)) // third text field
                            {
                                if (Convert.ToBoolean(query.junk)) // fourth text field
                                {
                                    if (Convert.ToBoolean(query.junk)) // more god drat text fields
                                    {
                                        //Code to actually submit all these changes here which is longer than this nested piece of poo poo.
				    }

                                }
                                else // handle the text field
                                {

                                }
                            }
                            else // handle more text fields
                            {

                            }
                        }
                        else // just use a drat validation already
                        {

                        }
                    }
                    else
                    {

                    }
                }
                else // I hate you
                {

                }

                lblMessage.Focus();
            }
Seriously this is a .net page, can't they just use field validation or something? I can't even begin to figure out where one if ends and another begins to add my validations to this horrible format.

Vanadium
Jan 8, 2005

Zombywuf posted:

Watching Java devs struggle understand concurrent access is just delicious.

Is the problem just that the compiler happily reorders the object initialization until after the assignment of the pointer to the (now uninitialized) object?

Plorkyeran
Mar 22, 2007

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

Vanadium posted:

Is the problem just that the compiler happily reorders the object initialization until after the assignment of the pointer to the (now uninitialized) object?
No, it can happen with zero reorderings or compiler optimizations of any sort when multiple processors are involved if the new address of the pointer happens to be flushed to RAM before the new values of the members.

Zombywuf
Mar 29, 2008

Vanadium posted:

Is the problem just that the compiler happily reorders the object initialization until after the assignment of the pointer to the (now uninitialized) object?

It looks to me that x + 1 == y is the bit that fucks up because the object may change between each side of the equality operator being read. The empty synchronised block appears to be some sort of magical ward against it but as far as I'm aware it does basically nothing in this case. I'm not really up to date on Java though so maybe it does actually do something useful.

Adbot
ADBOT LOVES YOU

raminasi
Jan 25, 2005

a last drink with no ice

Zombywuf posted:

It looks to me that x + 1 == y is the bit that fucks up because the object may change between each side of the equality operator being read. The empty synchronised block appears to be some sort of magical ward against it but as far as I'm aware it does basically nothing in this case. I'm not really up to date on Java though so maybe it does actually do something useful.

According to the SO thread it's only there to get the behavior to reproduce in the example.

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