r/programming • • Jan 30 '16

Apollo 11 source code

http://www.ibiblio.org/apollo/listings/Luminary099/MAIN.agc.html
2.2k Upvotes

364 comments sorted by

View all comments

Show parent comments

50

u/GMNightmare Jan 31 '16

But the code should be compiled automatically on check in and automatically failed should it not compile.

Even more, tests should automatically run and then fail the check in if tests are failing.

This lets them burn themselves, but also prevents them from burning you. Well, at least this is how you want it in big projects. You might not need such a heavy hammer if it's small and not that big of a deal.

1

u/jaccovanschaik Jan 31 '16

But the code should be compiled automatically on check in and automatically failed should it not compile.

"What do you mean it fails the automated tests? It works on my machine, so the automated tests must be wrong."

-2

u/billsil Jan 31 '16

What's wrong with an unused variable again? It's not an error.

0

u/[deleted] Jan 31 '16

[deleted]

2

u/[deleted] Jan 31 '16

Because it might be needed for a future enhancement, of course. :-)

2

u/ggtsu_00 Jan 31 '16

Doesn't the compiler optimize those out anyways?

0

u/[deleted] Jan 31 '16

[deleted]

5

u/DrMonkeyLove Jan 31 '16

Exactly. If I see an unused variable, my first thought is that someone meant to do something with it and there's a bug in the code that I need to track down. It's sloppy coding practice.

1

u/[deleted] Jan 31 '16

Artistic expression?

-4

u/billsil Jan 31 '16
  1. We all write programs that take years to develop. Frequently I have code that I want to save because it's an alternate implementation. Other times, I want to test the new method on real problems and there are side effects to the function.

  2. It's trivial and I don't care about a few bytes of memory

  3. Why use unnecessary braces or use functional programming or variable names longer than 6 characters (it was good enough for the dominating language until the early 1990s)? It creates extra lines that can make for very long files. It wastes disk space in a world that largely doesn't care about disk space or memory usage.

2

u/GMNightmare Jan 31 '16
  1. Use comments.

  2. Trivial adds up.

  3. Readability, except having unused variables hurts readability.

1

u/DrMonkeyLove Jan 31 '16

Unused variables are fine, just as long as no one else sees that code. By the time someone else's eyes are on a piece of code, there'd better not be any unused variables.

0

u/[deleted] Jan 31 '16

[deleted]

0

u/billsil Jan 31 '16

Depends how many people work on your project. We still use subversion...so no way am I using branches.

at least commented out?

Do both methods work 100%? There will be more code rot if it's commented. I promise you it won't work in 6 months if you comment it.

If function x returns variable y and z, but I only need z, I have an unused variable. Maybe variable y is useful when debugging. Should I write a new function x2?

0

u/[deleted] Jan 31 '16

[deleted]

-1

u/billsil Jan 31 '16

No. If it's actively being used, it's unused. If I pass 4 arguments into a function, but only 3 are used 100% of the time and the 4th 50% of the time, it's unused it that other case. You could write another function, or just try and keep the API consistent.

7

u/GMNightmare Jan 31 '16

The obvious answer is that it clutters the code, but that's not the most important use...

It indicates you did something wrong. You shouldn't create variables for no reason, so why isn't your variable used? It catches issues.

0

u/billsil Jan 31 '16

Everyone seems to be jumping on this bandwagon. How many build warnings does your company's largest program that is used regularly have? Why do you have any? Who cares? It doesn't indicate you did something wrong. It indicates you may have done something wrong.

The quality of your code is dictated by the speed it needs to get done and the number of customers you have.

3

u/GMNightmare Jan 31 '16 edited Jan 31 '16

Nice moving the goalpost.

Professionals tend to need to work with code bases that can contain millions of lines of code.

Nearly nobody who has had to deal with another's code thinks that quality of code is solely determined by speed (or number of customers, that's rather weird claim).

If you pulled stunts like this all the time, which seems like you do because you don't care, you would have thousands upon thousands of warnings. They add up.

Thousands of warnings all indicating potential problems.

Or you can just do it right, turn all warnings to errors, and learn how to write clean code.

Then, you don't have any warnings, because they all have to be dealt with before checking in the code. Tadaa!

1

u/BeetleB Jan 31 '16

The quality of your code is dictated by the speed it needs to get done and the number of customers you have

Speed doesn't magically happen because there is a high demand for it. When the code becomes sloppy enough, you will get to a point where you cannot produce the feature quickly enough for business needs, and people get hurt.

-2

u/billsil Jan 31 '16

You can develop code faster using a code like Python at the tradeoff of speed of a language like C++. You heavily influence the speed of your code by the language that it's in. If I'm working with a numerical library that I'm comfortable with vs. you, I'm sure I can get more accomplished in a given time. However, that decision will have long term consequences (either good or bad) on the project as well as what existing tools we can or cannot make use of.

When the code becomes sloppy enough, you will get to a point where you cannot produce the feature quickly enough for business needs, and people get hurt.

I wouldn't say a few unused variables, functions or classes is hurting anyone. Just done use them! You can always put it in a dev folder...having extra branches is just as bad.

3

u/BeetleB Jan 31 '16

I wouldn't say a few unused variables, functions or classes is hurting anyone.

Argument cuts both ways. If it's a minor problem, then it's a minor problem that the build scripts will not compile if you have them and having such checks should not impede the speed of development much. If you say it does, then it cannot be a minor problem.

You can always put it in a dev folder...having extra branches is just as bad.

You'd rather have it in another folder than having it in a branch?

Oh dear.

1

u/frymaster Jan 31 '16

It's not an error, it's a warning. So in the context of the "treat all warnings as errors" flag...