Questions tagged [language-agnostic]

This tag is for questions that aren't specific to a programming language or environment.

This tag is for questions that aren't specific to a programming language or environment. This tag is not a tag for opinion questions, rather for questions asking about code structuring and design that is applicable in any language, or, for books that do not relate to a specific langugage, rather to programming as a whole, I.E.: Pragmatic Programmers, Code Complete.

Book list

549 questions
259
votes
21 answers

Are `break` and `continue` bad programming practices?

My boss keeps mentioning nonchalantly that bad programmers use break and continue in loops. I use them all the time because they make sense; let me show you the inspiration: function verify(object) { if (object->value < 0) return false; if…
252
votes
11 answers

Why do many exception messages not contain useful details?

It seems there is a certain amount of agreement that exception messages should contain useful details. Why is it that many common exceptions from system components do not contain useful details? A few examples: .NET List index access…
Martin Ba
  • 7,578
  • 7
  • 34
  • 56
245
votes
174 answers

What should every programmer know?

Regardless of programming language(s) or operating system(s) used or the environment they develop for, what should every programmer know? Some background: I'm interested in becoming the best programmer I can. As part of this process I'm trying to…
Matt Lacey
  • 2,433
  • 3
  • 16
  • 10
144
votes
10 answers

When is it a good idea to force garbage collection?

So I was reading a question about forcing the C# garbage collector to run where almost every single answer is the same: you can do it, but you shouldn't - except for some very rare cases. Sadly, nobody there elaborates on what are such cases. Can…
Saturn
  • 3,887
  • 9
  • 30
  • 40
140
votes
18 answers

Is there an excuse for short variable names?

This has become a large frustration with the codebase I'm currently working in; many of our variable names are short and undescriptive. I'm the only developer left on the project, and there isn't documentation as to what most of them do, so I have…
KChaloux
  • 5,773
  • 4
  • 35
  • 34
128
votes
11 answers

The modern way to perform error handling...

I've been pondering this problem for a while now and find myself continually finding caveats and contradictions, so I'm hoping someone can produce a conclusion to the following: Favour exceptions over error codes As far as I'm aware, from working in…
RichK
  • 1,457
  • 2
  • 12
  • 12
124
votes
14 answers

Why don't we store the syntax tree instead of the source code?

We have a lot of programming languages. Every language is parsed and syntax checked before being translated into code so an abstract syntax tree (AST) is built. We have this abstract syntax tree, why don't we store this syntax tree instead of the…
Calmarius
  • 1,883
  • 2
  • 14
  • 17
112
votes
9 answers

Why use try … finally without a catch clause?

The classical way to program is with try ... catch. When is it appropriate to use try without catch? In Python the following appears legal and can make sense: try: #do work finally: #do something unconditional However, the code didn't catch…
Niklas Rosencrantz
  • 8,008
  • 17
  • 56
  • 95
99
votes
1 answer

Is there really a fundamental difference between callbacks and Promises?

When doing single-threaded asynchronous programming, there are two main techniques that I'm familiar with. The most common one is using callbacks. That means passing to the function that acts asynchronously a callback-function as a parameter. When…
Aviv Cohn
  • 21,190
  • 31
  • 118
  • 178
97
votes
53 answers

Harmful temptations in programming

Just curious, what kinds of temptations in programming turned out to be really harmful in your projects? Like when you really feel the urge to do something and you believe it's going to benefit the project or else you just trick yourself into…
Dan
  • 2,902
  • 1
  • 25
  • 30
92
votes
7 answers

Short circuit evaluation, is it bad practice?

Something that I've known for a while but never considered is that in most languages it is possible to give priority to operators in an if statement based on their order. I often use this as a way to prevent null reference exceptions, e.g.: if…
innova
  • 1,031
  • 1
  • 8
  • 11
87
votes
6 answers

How does garbage collection work in languages which are natively compiled?

After browsing several answers an Stack Overflow, it is clear that some natively compiled languages have garbage collection. But it is unclear to me how exactly this would work. I understand how garbage collection could work with an interpreted…
Christian Dean
  • 2,790
  • 1
  • 22
  • 38
87
votes
7 answers

What is early and late binding?

I keep hearing about early and late binding, but I do not understand what they are. I found the following explanation which I do not understand: Early binding refers to assignment of values to variables during design time whereas late binding…
SAMIR RATHOD
  • 1,005
  • 1
  • 9
  • 9
82
votes
18 answers

What is the best way to discern an excellent programmer in a job interview?

In the setting of an interview: What is the best way to reliably identify when somebody is an excellent programmer. By this I mean he is one of those that is 10-15 times more efficient / rapid / better than his peers towards the lower end of the…
Claudiu
  • 779
  • 1
  • 6
  • 12
78
votes
17 answers

How to train yourself to avoid writing “clever” code?

Do you know that feeling when you just need to show off that new trick with Expressions or generalize three different procedures? This does not have to be on Architecture Astronaut scale and in fact may be helpful but I can't help but notice someone…
Dan
  • 2,902
  • 1
  • 25
  • 30
1
2 3
36 37