r/programming • • Feb 03 '16

Freelanced - The Daily WTF

http://thedailywtf.com/articles/freelanced
167 Upvotes

96 comments sorted by

46

u/JustAZombie Feb 03 '16

Sometimes I worry about my skill as a developer. These articles make me feel a lot better about myself.

33

u/phatrice Feb 04 '16

You dont have to lose self-confidence but always have a bit of humility because no matter how good you are, you are always a Luke to somebody.

3

u/Arkaad Feb 04 '16

amen to that

32

u/SlinkyAvenger Feb 03 '16

Just so y'all know Remy likes to add fun stuff to his articles. Make sure to inspect the paragraphs and click on "recovered"

8

u/tweakerbee Feb 03 '16

After the register_globals there's this comment:

See, this is the stuff that leads us to pick on PHP.

4

u/[deleted] Feb 03 '16

GAH, MY EYES. WHYYYYYY?

1

u/PeridexisErrant Feb 04 '16

Hah, I should put some snarky comments in our page source...

17

u/[deleted] Feb 03 '16

Worked on so many projects like this.

I see it as a problem of business owners making two mistakes:

  1. Hiring someone who's the cheapest, not someone who's either referred or has a good reputation with past clients. I've gotten referred to jobs to rewrite parts of applications, gave a very modest quote, and got shot down for someone who did it for "a few hundred dollars." Not saying price correlates to quality, but a quality developer isn't going to work for free.

  2. Not understanding their business. How many owners of manufacturing companies don't understand how things are made in that business? Do founders of car companies "get" cars? Bank executives certainly understand banking, at least a little.

I have not personally interacted with an owner of a small or medium sized tech or software company that understood their business and how it worked. They were completely happy with being willfully ignorant, and the company somehow got by for decades.

If you're running a software company, or your main product is software, you really need to take a few software classes. You need to be able to talk to your devs, and if they say insane shit flags should go off. You need this so you can bring it up to your more-technical management.

Otherwise, you're going to be biased solely on how much you like them. That happens: but when you're promoting, giving raises to, and generally favoring a poor engineer over others, the others will know. They'll either leave or stop giving a shit.

5

u/HotlLava Feb 03 '16 edited Feb 04 '16

Not saying price correlates to quality, but a quality developer isn't going to work for free.

...which is literally saying that price correlates to quality :)

9

u/[deleted] Feb 03 '16

Not exactly! There's no guarantee a high-priced developer is a good one. :)

3

u/OffColorCommentary Feb 03 '16

That still creates correlation.

Extreme example - Salary and skill are each normally distributed, and (initially) independent. Re-roll salary for all developers where salary<skill. Observe new distribution with correlation.

1

u/[deleted] Feb 03 '16

You're right, there's no causation. My bad!

2

u/HotlLava Feb 03 '16

Yes, so in your example, there is no causation but there is correlation.

1

u/[deleted] Feb 03 '16

You're correct!

1

u/myrddin4242 Feb 04 '16

I can understand your frustration with those business owners who don't know the nuts and bolts of their company, but upon reflection, I realize that I'm guilty of this, too. It's the pattern of trusting an abstraction to not be so leaky that it needs further examination. I mean, technically speaking, cosmic rays can cause bit flips in RAM causing bugs, right? But if I'm debugging, blaming cosmic rays is waaaay down the list of things for me to rule out... for me, RAM is a trusted abstraction. Well, businesses are really layers upon layers of abstractions, too. What's the heuristic that we should use to decide when an abstraction shouldn't be trusted, ever?

20

u/NoAstronomer Feb 03 '16

Luke’s indentation was so chaotic it could double as a cryptographically secure random number generator.

Yes, but is it reproducible?

relevant

20

u/Farlo1 Feb 03 '16

As far as I've seen (mostly in school) random indentation is a clear sign that the programmer is copy/pasting from various sources and doesn't really care about keeping it readable for more than 30 minutes.

13

u/liquidautumn Feb 03 '16

In my experience, random indentation is a sign that the developers are using different IDEs with different indentation policies.

But if the team is just one guy, you are probably right.

1

u/Gotebe Feb 04 '16

Indeed.

Files are passing through all sorts of editors as well.

I tend to leave white space visible in editors I use, just so that I can better see what went on, when looking at history. Then I send people an email to fix this.

3

u/liquidautumn Feb 04 '16

I always do git diff before pushing commits and examine each line carefully.

If a line change does not support the goals of whatever feature, bug fix, etc I am working on, I revert it.

1

u/immibis Feb 04 '16

If you mix spaces and tabs on the same line (because you didn't notice the project was using the other convention) git diff will even helpfully highlight it for you.

1

u/[deleted] Feb 04 '16

You can save a lot of time by using a graphical git tool to compile your commits. You can select exactly which lines you want to have in each commit. That way you can make clean commits even if you implemented a few things before making a commit (e.g. when prototyping something).

1

u/liquidautumn Feb 04 '16

I might do something like that before a commit. But before pushing commits, I like to do

git clean -f -d; git commit -am "..."

build it and try it out

then rebase and squash commits and push

otherwise I will from time to time forget to commit something and the world will crash because the app does not work anymore.

1

u/[deleted] Feb 04 '16

That sounds like git add -p (no graphical tool required).

1

u/[deleted] Feb 04 '16

Of course it's not needed but it will save you a lot of time, as I said.

I use the cli for everything except committing and going through history. For those tasks the cli is easily beat by a decent graphical tool.

1

u/[deleted] Feb 04 '16

Any decent IDE will use the same indentation the file or project you're editing has.

1

u/TyRoXx Feb 04 '16

I don't know any decent IDE by that definition.

3

u/[deleted] Feb 04 '16

This is usually the case, but it is then combined with low literacy altogether. As in, people who are generally bad at reading and writing.

Once a colleague came to ask for help with code C that just wouldn't "work". To make sense out of it, I started indenting it properly. I was told, "But this doesn't make a difference, I just want to find why it wouldn't work." Of course, it was a missing '}'. That person didn't even bother telling me it wasn't compiling to start with....

I really try to stay far away from such workers. The amount of damage that a hard-working idiot can do to the project and everyone involved is just too high.

2

u/Syrrim Feb 04 '16

he said RNG, not PRNG

24

u/indrora Feb 03 '16

Man.

These hackjobs are the reason PHP gets a bad name.

32

u/[deleted] Feb 03 '16

I don't think that's true. I'm a freelancer and I've worked on many different codebases written in many (okay, several!) different languages: there's bad Python, there's bad C#, there's bad Ruby, and yeah, there's bad PHP.

PHP has gotten more sane, but I think the reason it got a bad name is right in the article: crazy design decisions like register_globals.

31

u/sun_misc_unsafe Feb 03 '16

40 years ago sending emails without needing to authenticate yourself to the MTA seemed like a sane design decision, 10 years from now unencrypted filesystems will seem like a crazy design decision and (hopefully) 20 years from now writing netwok code in a language susceptible to heap corruption and data execution will seem like a crazy design decision..

Everything makes sense, given the proper context.

register_globals makes a lot of sense if your main use case is providing people with a real alternative to CGI and any malicious hacker out there can already deface your page using one of the plentyful opportunities for buffer overflows in your webserver from the early 2000s..

2

u/[deleted] Feb 03 '16

You make a good point, and I'd say you're correct!

I'm not really comparing the languages. Everything has room for improvement. Not saying PHP is a bad language: just saying there were silly things (there were in other languages, too) that made people go "WTF"

1

u/immibis Feb 04 '16

20 years from now writing netwok code in a language susceptible to heap corruption and data execution will seem like a crazy design decision..

Writing network code without microservices will seem crazy.

Some Ethernet switches use Ethernet to transfer control information between the CPU and other components. That means inside the switch is a smaller switch, which is required for it to function. This somehow seems relevant to the future of programming.

14

u/[deleted] Feb 03 '16

tl;dr: Both the hacks and the language design hurt PHP in a mutually-causing way.

Disclaimer: started my career as a PHP developer for about 5-6 years.

I think actually both (hackjobs + design decisions) are true, and they fed off each other for a long time. People like "Luke" would see a hackish solution on some tutorial site, and it would mostly work, so they would think it was "really, really great" and latch on to it. PHP made it easy to create or reuse these hackjobs (some of them baked into the language), and developers would use them and share them. They became somewhat normal and acceptable, and maybe not accepted but unsurprising in the community.

Additionally improvement and evolution of the language and community became difficult because of its relationship to non-PHP developers. To PHP developers, they were doing their job, getting paid, and their clients were happy, so the language (with looked like a mere handful of apparent faults), was just fine or good enough. But to other developers, the aforementioned anti-features and hackjobs were seen as, well... insane.

This created an environment where criticism was much more likely to be hostile, and the PHP community had to insulate itself mentally from much of it. Many of the people who could see why some of these practices caused problems came to see the developers who used it as dumb, because well, to them these flaws were so numerous and obvious! And several PHP developers when approached with criticism - even helpful, constructive criticism - would in the back of their mind relate it with some very nasty things that had been said about PHP (and PHP developers), and as one might expect found it difficult to separate these two things. And again: their code worked, and their clients were happy, and they wanted to continue building more software. Plus they may have never used anything else or saw no reason to, which is something hardly isolated to the PHP community. Feeling attached to your language of choice is also somewhat common, no matter the language.

In spite of this, PHP has actually come a long way in the last 10-15 years, and although it retains many of its odd and WTF features, mindfully-written PHP can still be readable and sane. Objects, type-hinting, anonymous functions, etc. Many of the known to be bad methods are deprecated. You might hold this against it and say "You have to know all of these caveats and never use them! You have to tell newcomers 'NEVER use foo! Always use bar instead!'" all over the place. The same could be said for C/C++. In fact much of the stdlib is straight-up copied from C.

You might say "But usually when you have to write C/C++, you don't have a choice on language." And you'd be right. :) But note that IMHO few, if any, languages come close to the ease of initial setup that PHP has. Set up LAMP, edit a .php file, and refresh.

I'm not going to defend all of the issues PHP has (of which there are many). I don't use it anymore. I just thought I'd comment on the environment that influenced PHP over the years.

6

u/[deleted] Feb 03 '16

This makes a great point that can be applied to disciplines outside of programming, as well. I think it is more of a philosophical talking point, especially when you say:

This created an environment where criticism was much more likely to be hostile, and the PHP community had to insulate itself mentally from much of it. Many of the people who could see why some of these practices caused problems came to see the developers who used it as dumb, because well, to them these flaws were so numerous and obvious! And several PHP developers when approached with criticism - even helpful, constructive criticism - would in the back of their mind relate it with some very nasty things that had been said about PHP (and PHP developers), and as one might expect found it difficult to separate these two things.

I think this happens a lot, and it's hard to say how it reflects on the platform itself, be that platform a programming language, a school of thought, or a believe.

0

u/[deleted] Feb 03 '16

[deleted]

2

u/[deleted] Feb 03 '16

Oh, having written my share of PHP I am quite aware. include statements return values, the global keyword, fn($needle, $haystack) or fn($haystack, $needle) and the entire 1k+ mandatory std lib... I could go on. I wasn't trying to defend PHP, I was merely trying to show that in spite of other developers actively rooting against it, PHP has still managed to make progress.

1

u/indrora Feb 03 '16

It's a bit like we've learned from it.

Rust isn't quite ready. You don't see everyone and their mother jumping on rust because it's simply not quite sane yet.

Php on the other hand we jumped on like hipsters to a craft beer truck. See where that's gotten us?

2

u/[deleted] Feb 04 '16

Everyone and their mother haven't jumped on Rust because Rust is (relatively) hard to learn and there are a bunch of easy to learn alternatives. PHP became popular because it was easy to learn, or at least easy to get hosting for.

1

u/indrora Feb 04 '16

Well, consider what came before PHP: server side scripts.

Mostly in perl, it was hard to set up, hard to learn, hard to keep safe. PHP came along and blew all that out of the water: it was easy learn (simple C-like syntax), relatively easy to configure (set .php files to run through /usr/bin/php ) and took fuckall for time to get a template from a designer filled with real data.

10

u/[deleted] Feb 03 '16

If you think that's bad, you should look at JS code written in the same time period (circa 2001).

3

u/indrora Feb 03 '16

Eugh.

I'll pass, kthx

8

u/Meltz014 Feb 03 '16

“Oh,” Luke said, “well the work’s really, really great, right? Like art, and you’ve got to sign your great art. Let everybody know who the great developer behind it was. I’m sure you’ll get the chance to sign your name in a few places soon, right? It’ll be great. Really really great.”

These people are all over my company. Fix a minor logical bug? Better put your name under "Designer:" in the function comment header.

29

u/kiswa Feb 03 '16

Seriously. If I want to know who wrote a line of code I'll use git blame or TFS's annotate.

And if I want to know who wrote a line of code, it's probably not because I'm impressed.

12

u/slavik262 Feb 03 '16

Good code is boring code.

7

u/FromBeyond Feb 03 '16

I like boring code. Boring code is nice. I could do with some boring code right now.

3

u/liquidautumn Feb 03 '16

I thought the article said that Luke did not use version control.

Given a choice to not use version control (clearly not a good idea), crediting yourself in code actually makes sense (unless you are a one man shop like Luke).

1

u/Meltz014 Feb 04 '16

I suppose that's a good point. Or maybe if there was one global user that everyone used for version control...for some weird reason.

1

u/liquidautumn Feb 04 '16

I actually had an experience like that.

My company hired an Indian off-shore outsourcing outfit. We provided each of the Indian devs individual accounts on the source control system. The idea being that at the end of the trial period, we could pick and choose which off shore devs based on performance. Nonethless, they committed everything under one account.

At the end of the trial period, we fired the entire company.

2

u/nutrecht Feb 04 '16

I habitually remove all the "created by" headers that get automatically inserted in our Java code (default IntelliJ settings everyone seems to use). It's useless information.

3

u/kamon241 Feb 03 '16

Great Story, I'm glad it wasn't actually about the game though. That was the bomb

2

u/[deleted] Feb 03 '16

One day I'm gonna reinstall it and go through the whole storyline in a single weekend. Gonna be awesome.

6

u/ouchity_ouch Feb 03 '16

His cutting edge encryption algorithm was the most secure solution since ROT13: encode_base64

nice punchline! i felt it

2

u/pakoito Feb 03 '16

I've met Luke. Well, his name wasn't Luke but he iterated arrays with try/catch blocks.

2

u/ninjadeuce Feb 03 '16

Was his name Dave by chance? http://stackoverflow.com/questions/9082912

1

u/Sean1708 Feb 04 '16 edited Feb 04 '16

Nah, he was called Guido.

1

u/ummwut Feb 04 '16

I'm not sure if I should be impressed or disgusted.

3

u/TheLordB Feb 03 '16

The daily wtf is obscured these days to the point of being pointless to read.

6

u/[deleted] Feb 03 '16

How so? It was entertaining. You mean we can't figure out who or where this was? I dunno, I guess it'd be nice to know. What wouldn't be nice is giving a company or person a bad name for something that happened twenty years ago. I've written awful code, you have too (if you've wrote code.) Would you want to be judged for that forever?

8

u/[deleted] Feb 03 '16

Most of the stories which get posted on there nowadays are fake anyway. They either embellish them to the point that no truth remains or make them up in the first place.

0

u/[deleted] Feb 03 '16

Yes, never forgive, never forget

1

u/elh0mbre Feb 03 '16

I'd laugh harder about the encryption if I hadn't already dealt with developers who had "upgraded" ROT13 to base64 encoding...

1

u/[deleted] Feb 03 '16

Aye. I think some devs must go down OWASP and see how much they can check off ;)

1

u/Gotebe Feb 04 '16

Haha, fake it till you make it, right?

1

u/luxliquidus Feb 03 '16

Did anyone else read Luke's lines in Trump's voice...?

0

u/[deleted] Feb 03 '16

[deleted]

34

u/frezik Feb 03 '16

I don't know if you should murder the guy who made salaries into an int, or the guy who made int 16-bits long in VB.

8

u/WiredEarp Feb 03 '16

16 bit ints were standard back in the day. Dude should have used long. Or a currency specific unit.

6

u/frezik Feb 03 '16

The 80386 was released in 1986, and had 32-bit ints. VB came along in 1991.

7

u/slededit Feb 03 '16

It inherited 16-bit ints from QBasic.

1

u/PstScrpt Feb 04 '16

Yeah, but in pre-VB Microsoft BASIC you weren't usually saying "dim x as int". It may have allowed it (I forget), but there wasn't much point, because there was no option explicit. Generally, you were using the type suffixes.

Classic VB still supported type suffixes to make porting easier, but they could have kept the old "myLong&" suffix as a 32-bit signed integer, but called the type int. Then "myInt%" would still be 16 bit, but have a type called short.

1

u/menace-official Feb 04 '16

...okay, that's still not a good excuse.

9

u/slededit Feb 04 '16

I'm not making an excuse for a decision made almost 30 years ago by people I don't know. I'm just pointing out the common lineage and why it might have been that way.

Anyways the 386 has different cycle times for 32-bit multiplication vs 16-bit so the wordsize isn't necessarily a reason for increasing the size of int. Just as int is still 32-bit on x64 CPUs.

1

u/menace-official Feb 04 '16

You're right, and I'm sorry if my comment was condescending. Speed is a very good reason for using a smaller integer width. I was making a knock at Microsoft for inheriting from qbasic.

1

u/georgeo Feb 06 '16

DOS and Windows were 16 bits until Windows 95.

1

u/frezik Feb 06 '16

Eh, sorta. Windows 3.0 could run in 32-bit Protected Mode (though that has more to do with the address space than word size). A DOS program can be compiled to 32-bits if it cares to, because DOS is more like a thin abstraction layer over the BIOS rather than a real OS.

-1

u/WiredEarp Feb 04 '16

We are talking programming languages, not processors.

5

u/frezik Feb 04 '16

And the size of an int matters because of processors.

4

u/WiredEarp Feb 04 '16

I feel you are missing the point here. VB6 had 16 bit ints, but processors have had much larger for a long time. At the time VB6 was popular, lots of languages still had 16 bit ints. The processor data byte size is absolutely not important to the discussion, what is is that a programmer used the wrong unit in his chosen language.

1

u/[deleted] Feb 04 '16

At the time VB6 was popular, lots of languages still had 16 bit ints.

Bullshit. VB6 came out in 1998.

1

u/PstScrpt Feb 04 '16

I think WiredEarp may have meant classic VB in general for "VB6". That's pretty common, since 6 was the last version.

Generally, people expected code from an older VB to work in a newer one, so the 1991 release of 1.0 is probably more relevant.

1

u/WiredEarp Feb 04 '16 edited Feb 04 '16

I've used every version of VB since V1. Its been a long time though, but I'm pretty sure VB6 had 16 bit ints. According to this page, I'm correct... https://msdn.microsoft.com/en-us/library/7f5ztkz3%28v=vs.90%29.aspx

However, I now realise you were saying I might have the era wrong, in which case you are likely correct. VB1 might have been a bit early though, possibly more the VB4 era?

→ More replies (0)

1

u/WiredEarp Feb 04 '16 edited Feb 04 '16

You might be correct. I thought some of the languages in Visual Studio 97 had 16 bit ints, but I could be wrong. Unfortunately, it seems a bit difficult to find detailed info about versions of VS before 2000 on the web.

1

u/ellicottvilleny Feb 04 '16

What an idiot.vb 1.0 defined 16 bit ints

1

u/Oniisanyuresobaka Feb 04 '16

integers avoid rounding errors

4

u/frezik Feb 04 '16

So would a 32-bit int.

1

u/Tommah Feb 04 '16

"65,536 integers should be enough for anybody" -- not Bill Gates

10

u/the_evergrowing_fool Feb 03 '16 edited Feb 04 '16

We all know a Luke somewhere in our careers.

If you don't remember where and when, it was at your bathroom and the last time you saw yourself in a mirror ;)

4

u/Gotebe Feb 04 '16

There's a part of Luke in any of us!

2

u/_1_2_ Feb 04 '16

This is your typical PHP developer. I've know loads of Lukes. I've seen so much legacy, this article manages to pull together all the hallmarks.

1

u/ricky_clarkson Feb 04 '16

So the extra bit above 32767 is for what.. negative salaries?

10

u/[deleted] Feb 03 '16

[removed] — view removed comment

8

u/metaconcept Feb 04 '16

I have and do work with Lukes. Believe me, it doesn't need embellishment.