20 Answered Questions for the topic language agnostic

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

Understanding "randomness"?

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

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

What is an idempotent operation?

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

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

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?

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

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

Prefer composition over inheritance?

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

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

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

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

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

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

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

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

What is tail recursion?

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

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.

Ask a question for free

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


Find an Online Tutor Now

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