Skip to main content
Share Your Experience: Take the 2024 Developer Survey
119 votes
Accepted

How can lossless compression ever exist?

There can be no algorithm that losslessly compresses all inputs. But there are many algorithms that losslessly compress many inputs. And it turns out that most of the strings we like to operate on ...
Kilian Foth's user avatar
106 votes

Are events only used for GUI programming?

Nope. They're really handy for implementing Observers and making sure that classes are closed to modification. Let's say we have a method that registers new users. public void Register(user) { ...
RubberDuck's user avatar
  • 8,961
62 votes

What's the difference between a subclass and a subtype?

Subtyping is a form of type polymorphism in which a subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program elements, ...
Robert Harvey's user avatar
53 votes

Are events only used for GUI programming?

Nope. A classic example of events being used in non-GUI logic are database triggers. Triggers are code that gets executed when a given event happen (INSERT,DELETE, etc). Seems like an event to me. ...
Tulains Córdova's user avatar
43 votes
Accepted

Ninety-ninety rule in practice

Imagine it like this: When you start working on software you can write huge amounts of code in relatively short time. This new code can add huge amount of new functionality. The problem is that, often,...
Euphoric's user avatar
  • 37.5k
35 votes

How can lossless compression ever exist?

Compression works by making more likely patterns shorter at the cost of less likely patterns Suppose we have a data format which is a string of 4 possible values, we could represent it with 2 bits ...
mousetail's user avatar
  • 458
34 votes

What's the difference between a subclass and a subtype?

A type, in the context that we are talking about here, is essentially a set of behavioral guarantees. A contract, if you will. Or, borrowing terminology from Smalltalk, a protocol. A class is a ...
Jörg W Mittag's user avatar
29 votes
Accepted

Should I build a fully featured application or a bare bones one and then slowly add features?

Experience definitely leads toward building something small and simple, and getting it to the users as early as possible. Add features and capabilities as they're requested by the users. Chances are ...
Jerry Coffin's user avatar
  • 44.5k
27 votes

Are events only used for GUI programming?

Event-based programming is actually also used for highly performant server programming. At a typical server workload, much of the time processing a result actually comes from I/O. For example, ...
ArTs's user avatar
  • 730
22 votes

Ninety-ninety rule in practice

It is a reference to a common scenario, that sadly still occurs today: The team is asked to estimate (ie guess) the amount of work needed to write all the code, The project proceeds with numerous ...
David Arno's user avatar
  • 39.3k
20 votes
Accepted

Why does recursion return the first call in the stack and not the last?

The key here is stack frames. Lets take a look at your first example: public static int incrementI(int i) { if (i == 5){ return i; } else { incrementI(i + 1); ...
Nathan Merrill's user avatar
20 votes

What is the meaning of the 90/10 rule of program optimization?

This isn't a law of nature, but a rule of thumb born out by wide experience. It is also known as the 80/20 rule, and is only ever a rough approximation. Loops, Branches and other flow control. Each ...
Caleth's user avatar
  • 11.4k
19 votes

Is colon in python blocks technically necesary?

The colon is not really necessary grammatically, had Python been designed in a different world, it's quite conceivable that the language designer might not decide to require the colon. And indeed ...
Lie Ryan's user avatar
  • 12.4k
19 votes

How can lossless compression ever exist?

I recommend learning about Shannon entropy, but the simple answer is: lossless compression can't compress all inputs, but it can compress some inputs, and in practice that is enough. To demonstrate I'...
Jasmijn's user avatar
  • 1,849
18 votes
Accepted

Why do we need stacks and queues?

Stacks and queues are ways of working with contiguous memory. Linked lists are not. Now sure, any problem that you can solve with one structure you could solve with another and slap enough ...
candied_orange's user avatar
17 votes

What is the logic in the order of operator precedence?

The designers of the Fortress Programming Language did extensive reviews of scientific literature to see how operators are used and what relative precedence they have. Based on those observations, ...
Jörg W Mittag's user avatar
17 votes
Accepted

What is an immutable object anyway?

I think the core issue here is that the term "immutability" is often not a uniquely and strictly defined term in the mathematical sense. Different people can have different kind of degrees ...
Doc Brown's user avatar
  • 209k
16 votes

What is the meaning of the 90/10 rule of program optimization?

Loops. I'm tempted to stop there! :-) Consider this program 1. do_something 2. loop 10 times 3. do_another_thing 4. loop 5 times 5. do_more_stuff Line 1 is executed once whilst ...
Nick Keighley's user avatar
13 votes

Is colon in python blocks technically necesary?

It is not necessary for the computer, but for humans. Guido van Rossum (creator of Python) had a Python history blog for a while. The colon was introduced in ABC, the source of many of Python's ...
RemcoGerlich's user avatar
  • 3,310
12 votes
Accepted

Is colon in python blocks technically necesary?

Yes, the colon is required to disambiguate certain constructs. Consider, for example, if x - y < z: pass. Without the colon we cannot decide how to parse this without knowing the context of what x, ...
Phoshi's user avatar
  • 1,633
12 votes

How can lossless compression ever exist?

For example, if you had a file with 16 bit audio, you can obviously represent it with 16 bit per sample. However, a simple lossless compressor will have an algorithm that predicts the next sample, and ...
gnasher729's user avatar
  • 45.7k
11 votes
Accepted

Is Program Running Time Affected by File Size?

In theory, yes file size can affect the running time of a program. However, the affect it has is probably so insignificant you should never have to worry about it. There are a few reasons for this: ...
Jesse Good's user avatar
10 votes

Are events only used for GUI programming?

Events are also heavily used in network programming (e.g. Nginx) to avoid expensive busy-wait loops and instead provide a clean interface to know exactly when a certain operation is available(I/O, ...
edmz's user avatar
  • 201
10 votes

What is the logic in the order of operator precedence?

There isn't some grand logical scheme, especially in C and the derivatives that kept its order. It's basically a combination of "this feels right" and historical accident. Obviously, you want to keep ...
Sebastian Redl's user avatar
8 votes

What is an immutable object anyway?

I've always thought of immutability in terms of the assignment operator: =. If all instance variables are marked final (or readonly, or const — whichever word the language uses) then they can only be ...
Greg Burghardt's user avatar
7 votes

Why does recursion return the first call in the stack and not the last?

Nathan Merrill's answer is correct, and this is the standard way of describing the situation. Another way to describe the situation is to imagine that every time a function is called, a copy of the ...
Eric Lippert's user avatar
  • 46.2k
7 votes

Ninety-ninety rule in practice

I have heard a different version of this (also called "90-90 rule") that goes like this: After I have implemented 90% of the functionality, I still have to implement the other 90%. Both versions ...
utnapistim's user avatar
  • 5,285
7 votes

How can lossless compression ever exist?

If our data was sequences of random values, and longer sequences were less likely than shorter ones, then lossless compression would on-average be worse than useless. But our data is far from random ...
Peter Green's user avatar
  • 2,251

Only top scored, non community-wiki answers of a minimum length are eligible