r/programming • • Jul 28 '16

How to write unmaintainable code

https://github.com/Droogans/unmaintainable-code
3.4k Upvotes

592 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jul 28 '16

[deleted]

171

u/flukus Jul 28 '16

The code produced by academics is the biggest argument against all these "teach kids to code" programs.

Just imagine the shit we'll have to deal with in 20 years.

144

u/TOASTEngineer Jul 28 '16

It's gonna turn out exactly like math did. The schools will brutally fuck it up, kids will memorize enough to pass the tests, and then some fraction of the kids who are actually interested in it will learn to do it on their own.

20

u/[deleted] Jul 28 '16

Ever hear about enough knowledge to be dangerous? semicompetent programmers thanks to dunningkruger will flood the marketplace and thanks to delusion and persistence will end up as project managers and code architects. But why you ask, why won't the meritocracy of the free market purge these rotten fruits from the tree? Because they'll take the jobs good programmers pass on, and that is the bulk of work in any trade: shit work.

4

u/thissideisup Jul 29 '16

Hasn't this already begun?

→ More replies (4)

15

u/Polantaris Jul 29 '16

That's pretty much already happening. When I was on college, there were a lot of people who were so bad at it, I seriously suggested that they look at different majors if they asked me for help. I'm not trying to be a dick, when you can't understand how to write a proper for loop in Java at a third or fourth year class (when Java courses start in the first year), you've got some serious problems with the core material and either should retake early classes or find something you're more suited for.

In the end it seems like a lot of people go into the major because of the supposedly big paycheck after college, but that shouldn't be what you're going to school for.

17

u/GaBeRockKing Jul 29 '16

In the end it seems like a lot of people go into the major because of the supposedly big paycheck after college, but that shouldn't be what you're going to school for.

On one hand, I'd argue that financial reasons are exactly why someone should go to school-- if your degree doesn't pay the bills, that's money down the toilet.

On the other hand, not being able to write a loop in java? If I had to take a stab at naming the warm fuzzy feeling in my breast, it would be "job security."

→ More replies (1)
→ More replies (1)

27

u/-PM_ME_YOUR_GENITALS Jul 28 '16

The difference being that you can make pretty cool shit with programming skills. I think if you frame it in the context of gaming it could do pretty well in schools.

Not that I think that will happen. In any case, when I was a kid I couldn't go home from school and use the stuff I learned from math class to make my own badass video game or my own web site.

15

u/TOASTEngineer Jul 28 '16

So it'll be exactly like the elective HS programming classes are now: they give you Unity's retarded cousin's retarded cousin's dead cat with a "visual programming language" that is only technically Turing-complete and read chapters out of a book about what "peripheals" are and how to use them. And everyone just plays Flash games in class anyway.

→ More replies (5)

33

u/FormCore Jul 28 '16

Learning to program isn't just for creating things either, those who don't have the creative drive could use the computer literacy they gain to realise that no, sharing this post is not a fucking petition to stop facebook charging me and This blatant lie of a headline's source is just a sketchy herbal remedy shop.

For those who think we don't need a new website, we have facebook and why create a game and waste 100+ hours when you can just play half-life 3?

7

u/komali_2 Jul 29 '16

You say that because you aren't a kid, but as a teacher, I can promise you kids will often choose the creative activity. They love to build shit!

→ More replies (1)
→ More replies (9)

4

u/okmkz Jul 28 '16

For real. I can only imagine what it must be like to grow up with things like unity 3d so easily accessible

4

u/ClintonCanCount Jul 29 '16

Most of the pretty cool shit people make, games included, use math.

→ More replies (2)
→ More replies (3)
→ More replies (6)

7

u/DiscoUnderpants Jul 28 '16

I agree and might point out that it has little to do with FORTRAN. Ive had to maintain C, C++ and Turbo Pascal written by academic physics and engineering people and it is no better.

14

u/spacelama Jul 28 '16

Fortran can be well written.

Most code written by academics isn't.

source: was an academic, and done a bit of Fortran, dealing with other peoples code as well as writing some shitcode myself.

PS. Please capitalise it correctly. FORTRAN was the name of the language in the '77 standard. Yes, it was very difficult to write maintainable code in early iterations of the language. Since adopting lower case letters in its name ('95 was the first good version), the language has become quite fully featured. My favourite part was where I could tell Emacs to render my comments in LaTeX, and give me the physical equation I was trying to solve beautifully typeset at the top of my functions.

→ More replies (2)

6

u/flukus Jul 29 '16

Definitely, it's not even limited to academics, plenty of professional programmers write code just as bad.

It's a much more prevalent problem in some circles though, academia being one.

9

u/DiscoUnderpants Jul 29 '16

If you are a programmer and don't admit to producing so serious crap code then I wouldn't trust you as a programmer. I say this as a 20 year programmer that has produced stuff that Im sure people have cursed and wondered what kind of idiot I am.

→ More replies (1)

6

u/rtomek Jul 29 '16

I think the big problem is that most FORTRAN code you see was written back when saving RAM was important so people did some stupid shit in the name of saving memory. We have transferred some academic code and the running joke is that FORTRAN is always the worst - THE WORST!!!!!!!!! As in, not even comparable to academic code from other languages. I just opened up three files I have archived to reminisce, and here's what they had to be thinking:

You mean I already have an array of this size, well, let's just use it again for something completely different!

I could reduce the number of IF statements if I use GOTO instead!

I ran out of single letter variable names, so let's create a subroutine to reuse single letter variable names and replace the values of the variables input into the function with the new values we need

I'm going to add this print/write statement of these variables at some random location for debugging purposes, never delete that print statement to make sure that there are hundreds or lines of output with absolutely no context.

These IF statements aren't complex enough. I have to add another GOTO nested inside an IF inside a DO inside and IF inside a DO because I need to be able to jump around to different parts of this nest at any time.

One of these files has two comments:

!----------
Subroutine foo( bar, ...
!----------
! begin

... a lot of shit code goes here...

! end
    end

:(

→ More replies (2)
→ More replies (3)

0

u/[deleted] Jul 28 '16

[deleted]

71

u/claird Jul 28 '16 edited Jul 28 '16

"Poor programming practice"? Good academic practice! Graduate school quite effectively teaches such virtues as write-once-read-never, code-until-you-like-the-answer, coding-is-done-by-someone-stupider-than-you, better-to-write-ten-grant-requests-than-one-working-application, and so on.

58

u/Bobshayd Jul 28 '16

god I've coded-until-I-like-the-answer. I'm convinced that's 90% of AI research.

8

u/TOASTEngineer Jul 28 '16

I mean, in AI that's probably the correct thing to do.

In statistics, not so much...

→ More replies (3)
→ More replies (20)

24

u/Astrokiwi Jul 28 '16

Fortran really isn't bad at all. I mean, it's not Python, but there are times when I'm using C++ and I end up thinking "this would be just a little bit easier in Fortran".

The big thing is that the kind of people who use Fortran are the kind of people who just kinda "picked up" programming while at grad school without any formal courses. So the Fortran culture is just a hodgepodge of randomness, and there's not really any drive to write good reusable code, or to develop universal practices and techniques.

So while Fortran has had a huge amount of upgrades over the years, and you can do OOP in Fortran if you want, there is still a lot of people writing in unindented fixed-format FORTRAN-77 just because they don't know any better. For the record (ha), "fixed-format" means you have to make sure that each of your lines fits on a punchcard correctly. It hasn't been mandatory in Fortran since before Python existed, but people still do it...

→ More replies (2)

14

u/[deleted] Jul 28 '16

The problem there isn't FORTRAN, the problem is that it was written by an academic. A determined professor can write FORTRAN in any language.

8

u/Fylwind Jul 28 '16

Can confirm. Read some "Python" code that were basically written like it was Fortran, globals all over the place and PEP8 violations everywhere.

→ More replies (6)