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

How does integer comparison work internally?

All the way down the rabbit hole, eh? OK I'll give it a try. Step 1. From C to machine language The C compiler transforms your comparison to opcodes stored in machine language. Machine language is ...
John Wu's user avatar
  • 26.6k
20 votes
Accepted

How does sleeping a thread work?

There is much more involved in running a program than just the code within that program. Any program that runs in a multi-process OS is under the control of the OS's scheduler, and the scheduler does ...
Kilian Foth's user avatar
19 votes
Accepted

Why did Ruby creator chose to use the concept of Symbols?

The creator of Ruby, Yukihiro "Matz" Matsumoto, posted an explanation about how Ruby was influenced by Lisp, Smalltalk, Perl (and Wikipedia says Ada and Eiffel too): Ruby is a language ...
coredump's user avatar
  • 5,965
18 votes

How does sleeping a thread work?

As Doc Brown mentioned in a comment, interrupts are the key, and not just for sleeping. An interrupt is a hardware signal that the processor should stop what it's doing and run a piece of code. ...
kdgregory's user avatar
  • 5,250
12 votes

Why did Ruby creator chose to use the concept of Symbols?

So, why did Ruby creators had to use the concept of symbols in the language? Well, they didn't strictly "have to", they chose to. Also, note that strictly speaking Symbols are not part of the ...
Jörg W Mittag's user avatar
10 votes

How did heavy software in the early days managed to run on 4MB RAM computer?

How did heavy software in the early days managed to run on 4MB RAM computer? It wasn't heavy. That's it. There is no magic to it. Your question is based on a false premise. I remember that my mom ...
Jörg W Mittag's user avatar
9 votes

can every program still be written without recursion or cyclic calls?

I think it is clear we are talking about a programming language environment where all code is organized inside functions with some local scope, all functions exist at compile time and the executing ...
Doc Brown's user avatar
  • 209k
8 votes
Accepted

constraints in developing software

Yes, but it's not as hard of a constraint like physical constraints in other engineering disciplines. Memory usage, processor power, hard disk space, network speed, and more are constraints. However, ...
Thomas Owens's user avatar
  • 82.8k
8 votes
Accepted

Correct terminology for if-blocks

To my best knowledge, control structures is the term used for if statements, loops, try-catch-finally, switch tables and gotos in C-like languages.
marstato's user avatar
  • 4,608
8 votes

Is it possible to programmatically evaluate safety for arbitrary code?

What we're ultimately talking about here is compile time vs runtime. Compile time errors, if you think about it, ultimately amount to the compiler being able to determine what problems you have in ...
Neil's user avatar
  • 22.7k
8 votes
Accepted

Can more than one memory address be accessed at one time?

The answer to this question depends a lot on what part of the computer you're looking at and what exactly you mean by “simultaneously”. From the perspective of the programmer, yes, reads and writes to ...
amon's user avatar
  • 134k
8 votes

can every program still be written without recursion or cyclic calls?

The strict hierarchy of tasks that are computable under one theoretical model of computation vs. another really only exists "in the limit", i.e. when you allow unlimited resources. There are ...
Kilian Foth's user avatar
7 votes

Is it faster to make a dedicated variable instead of calling deeply nested object several times?

Well, on the most basic level, val has fewer characters in it than myObject.someProp.someOtherProp.anotherOne.yetAnother.myValue so, simply parsing it will be (trivially) faster. On the specification ...
James Curran's user avatar
  • 1,809
7 votes
Accepted

What is the general term for [function] names of which the value is fully known at compile time?

You're looking for “static”, as in “statically linked”, “statically dispatched”, or “statically resolved”. The term static just means that something can be done at compile time, in contrast to run ...
amon's user avatar
  • 134k
7 votes

What is the difference between code reuse and software product line engineering?

A simple google search turns up this definition: The characteristic that distinguishes software product lines from previous efforts is predictive versus opportunistic software reuse. Rather than put ...
candied_orange's user avatar
7 votes
Accepted

Am I allowed to simplify terms while calculating Big O?

Not only can you, it is in very definition of O-complexity. The O-complexity is not really as simple as most laymen programmers understand it. Simply said, the O is defined asymptotically. That ...
Euphoric's user avatar
  • 37.5k
7 votes

Big O Complexity when iterating in 3 dimensions

Personally I would put it as O(bx*by*bz). The reason being I assume that the parameters can all change arbitrarily to one another, for example you could get the following input: bx=30000, by=30, bz=40....
Sahil Tara's user avatar
7 votes
Accepted

Object immutability and persistence

tl;dr summary: every persistent data structure is immutable, i.e. persistence is a subset of immutability, but not the other way around. Note: the Wikipedia article is about the more general concept ...
Jörg W Mittag's user avatar
6 votes
Accepted

Is it faster to make a dedicated variable instead of calling deeply nested object several times?

The optimization you are performing by hand is called common subexpression elimination. According to this article, Chrome's V8 has performed this operation since at least 2011; Webkit's JIT also does ...
Jules's user avatar
  • 17.8k
6 votes

What is the true meaning of "natural ordering"?

The term of “natural order” is very artificial, because the natural state of things is chaos and not order. It appears that some (early) artificial concepts relate to physical things in the nature. ...
Christophe's user avatar
  • 77.9k
6 votes

Writing a growing simulation that scales

If you simulate individual actors and resources, your code will probably have O(n log n) runtime complexity, i.e. to scale for arbitrary growth you'll need to utilize an ever growing amount of CPU ...
Hans-Martin Mosner's user avatar
6 votes
Accepted

How do we define a "step" when calculating big O notation in an algorithm?

A step is anything that takes time, memory, or whatever you are measuring behind the label of "complexity". A step can be any size, as long as it is roughly the same size each time it gets ...
Jacob is on Codidact's user avatar
5 votes
Accepted

How to Create a Parser that Operates in Reverse

Parsing in reverse is code generation. Think of a compiler as a translator: first, it parses usually to an intermediate data structure (often a tree), then it walks that intermediate data structure ...
Erik Eidt's user avatar
  • 34.1k
5 votes
Accepted

Is there a name for infered strong typing?

I'd like to avoid the terms “strong typing”, “weak typing”, or “loose typing”, since they have no generally agreed-upon definition. Instead, let's talk about static typing. A language is statically ...
amon's user avatar
  • 134k
5 votes

How did heavy software in the early days managed to run on 4MB RAM computer?

Microsoft Word for Windows was by today's standard a very small program. Its size is 13.07 MB on installer disks (1.44 MB each), which you can download to check for yourself. Microsoft Word 6.0 for ...
Benny Skogberg's user avatar
5 votes

is python(cpython) code represented as c code by the interpreter?

For all practical purposes, bytecode is just a data structure that is convenient for an interpreter to use. The interpreter looks at each instruction in the byte code and immediately performs that ...
amon's user avatar
  • 134k
5 votes
Accepted

How to deal with forward references in a compiler?

We need to separate the nature of the source language. If cyclic references are forbidden, you can use a topological sort to bring your AST into an order that can be processed without encountering ...
marstato's user avatar
  • 4,608
5 votes

Prove that an expression can create duplicate

The minimum value of your expression is 0, when i % 1000000 = 0 and ms = 0. The maximum value of your expression is 999999999, when i % 1000000 = 999999 and ms = 999. Therefore via the pigeonhole ...
Philip Kendall's user avatar
5 votes

Object immutability and persistence

Persistence means something very different to most imperative programmers, so there might be some confusion if you're searching the term. The simplest persistent data structure in the functional/...
Karl Bielefeldt's user avatar
4 votes

Why are strings so slow?

Strings are often no more expensive than other data types of similar complexity. Indeed they may be cheaper, because the creators of programming environments often put a lot of effort into optimising ...
Peter Green's user avatar
  • 2,251

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