20 Answered Questions for the topic language agnostic

08/02/19

Learning garbage collection theory?

I want to learn the theory behind garbage collection. How do i go about it? The obvious answer is - a compiler textbook... The question is, is it necessary to learn lexical analysis, parsing and... more

08/01/19

Understanding "randomness"?

I can't get my head around this, which is more random? rand()OR rand() * rand() ?

07/29/19

Purpose of singletons in programming?

This is admittedly a rather loose question. My current understanding of singletons is that they are a class that you set up in such a way that only one instance is ever created.This sounds a lot... more

07/27/19

07/25/19

Determine Whether Two Date Ranges Overlap?

Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges overlap?As an example, suppose we have ranges denoted by DateTime variables StartDate1... more

07/19/19

What does it mean to "program to an interface"?

I have seen this mentioned a few times and I am not clear on what it means. When and why would you do this? I know what interfaces do, but the fact I am not clear on this makes me think I am... more

07/11/19

Interface vs Base class?

When should I use an interface and when should I use a base class? Should it always be an interface if I don't want to actually define a base implementation of the methods?

07/06/19

XOR of three values?

What is the simplest way to do a three-way exclusive OR? In other words, I have three values, and I want a statement that evaluates to true IFF only *one* of the three values is true. So far,... more

07/05/19

C# logic order and compiler behavior?

In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement? Example: DataTable myDt = new DataTable(); if (myDt != null &&... more

07/03/19

Prefer composition over inheritance?

Why prefer composition over inheritance? What trade-offs are there for each approach? When should you choose inheritance over composition?

07/02/19

Should a function have only one return statement?

Are there good reasons why it's a better practice to have only one return statement in a function? Or is it okay to return from a function as soon as it is logically correct to do so, meaning there... more

06/22/19

Learning to write a compiler?

*Preferred languages*: C/C++, Java, and Ruby.I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java,... more

06/22/19

What's the difference between a method and a function?

Can someone provide a simple explanation of methods vs. functions in OOP context?

06/19/19

How do you find a point at a given perpendicular distance from a line?

I have a line that I draw in a window and I let the user drag it around. So, my line is defined by two points: (x1,y1) and (x2,y2). But now I would like to draw "caps" at the end of my line, that... more

06/03/19

What is the fastest way to get the value of π?

I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using #define constants like M_PI, or hard-coding the... more

06/01/19

Is floating point math broken?

Consider the following code:<!-- language: lang-js --> 0.1 + 0.2 == 0.3 -> false<!-- language: lang-js --> 0.1 + 0.2 -> 0.30000000000000004 Why do these... more

06/01/19

What is tail recursion?

While learning lisp, I've come across the term *tail-recursive*. What does it mean exactly?

05/20/19

What does Exclusive in XOR really mean?

Maybe this is just obvious to everyone but can someone explain where XOR (or Exclusive-OR) got its name from? What does the word ***Exclusive*** really mean? Not that it matters, but its just stuck... more

Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.