Skip to main content
48 votes
Accepted

Should bytes be signed?

Frame Challenge: Bytes should not be integers. Bytes are bytes, a fixed-size sequence of bits, typically 8 on modern computers. Should an array of bits be signed or unsigned? Neither, the question is ...
Matthieu M.'s user avatar
  • 3,038
35 votes

Can sine converge to zero at infinity?

The most obvious breakage, to me, would be the constraint that $\sin^2+\cos^2$ should be approximately one -- and related higher order constraints, like a rotation matrix being orthogonal. I think ...
Alex K's user avatar
  • 451
22 votes
Accepted

How do languages support executing untrusted user code at runtime?

Without a clear threat model, this is borderline too broad, but there are several attested approaches that attempt to provide some general level of safety. It's also worth noting here that most of the ...
Michael Homer's user avatar
  • 13k
21 votes
Accepted

Is there any particular reason to only include 3 out of the 6 trigonometry functions?

This does just roll the barrel slightly lower on the hill (or whatever the saying is), but: The IEEE 754 floating point standard includes the following trig-related operations as "recommended&...
RubenVerg's user avatar
  • 1,632
20 votes

Should bytes be signed?

Bytes should be unsigned There are a few reasons most languages have unsigned bytes by default: A more useful range. Bytes can only represent 256 different numbers so using them effectively is extra ...
mousetail's user avatar
  • 8,349
18 votes

Can sine converge to zero at infinity?

Asking for sin(1e300) in floating-point context is not even wrong. Way before 1e300, one gets into troubles with aliasing, π inaccuracies and other bad things arising from the floating-point ...
fraxinus's user avatar
  • 281
13 votes

Can sine converge to zero at infinity?

Well, the IEEE-754 standard breaks, for a start. The standard specifies that, if supported, the domain of the $\sin$ operation is $\left( -\infty,\infty \right)$. The standard does not impose explicit ...
Pseudonym's user avatar
  • 4,726
12 votes

Should the method to sort a list modify it in-place or return a new object?

Why not both? Swift has a mutating method .sort(), and a method that returns a copy .sorted(). The former is only implemented ...
Bbrk24's user avatar
  • 9,067
12 votes

Is there any particular reason to only include 3 out of the 6 trigonometry functions?

One possible reason is that it is quite difficult to implement these functions with high accuracy. For + - * / the IEEE standard requires that the error is at most 1/2 of the least significant bit (0....
gnasher729's user avatar
11 votes

Are there any reasons not to have built-in constants?

Some constants (true, false, null, maybe some others in specific languages) are so important ...
kaya3's user avatar
  • 19.7k
11 votes

What are the implications of including a UI toolkit in a standard library?

Creating a good, cross-platform user interface toolkit is extraordinarily challenging, and what constitutes a good user interface is a moving target, so most GUI libraries go through significant ...
Alexis King's user avatar
  • 8,721
11 votes

Is there any particular reason to only include 3 out of the 6 trigonometry functions?

Older processors had instructions to compute the sine, cosine and tangent of floating-point numbers, but not the secant, cosecant or cotangent. So the reason could just be that especially for older ...
kaya3's user avatar
  • 19.7k
11 votes

How do language designers determine what feature flags are part of the standard library and what are part of syntax?

In Java, the @Override annotation was introduced when the language had already been in use for a while, so they had to maintain backwards compatibility (i.e. keep ...
abel1502's user avatar
  • 2,527
11 votes

Why doesn't C's standard library have functions for searching memory like strings?

I have no particular insight into decisions made by the designers of the C standard library, but I can offer some informed speculation. A C string is a (null-terminated) array of characters. That is, ...
kaya3's user avatar
  • 19.7k
10 votes

Is there any particular reason to only include 3 out of the 6 trigonometry functions?

Frequency of use The main three are vastly more commonly used than the other three.
Adám's user avatar
  • 3,156
10 votes

Is there any particular reason to only include 3 out of the 6 trigonometry functions?

A very huge system library with functions for trivial, easy to derive features is more difficult to remember. The code using them may easily be less readable. Imagine you see: ...
Audrius Meškauskas's user avatar
10 votes

How do language designers determine what feature flags are part of the standard library and what are part of syntax?

I'll answer from my perspective as a language designer. tl;dr: it is impossible to generalize design decisions. Generalizing Design Decisions In the mind of every language designer, and indeed, ...
Gavin D. Howard's user avatar
10 votes

Should bytes be signed?

Signed bytes make bit-packing difficult, because when a signed byte is converted to a wider integer type, sign extension means that the wider integer might use more than just the low 8 bits. Consider ...
kaya3's user avatar
  • 19.7k
9 votes

How do languages support executing untrusted user code at runtime?

Safe TCL TCL supports this as safe TCL In TCL all control structures are implemented as commands and any command can be replaced. In TCL you can create a new interpreter from within TCL itself which ...
Bruce Adams's user avatar
  • 2,843
8 votes

Can sine converge to zero at infinity?

This simply directly contradicts the mathematical (and sensible) notion of "converges," which we usually interpret as the value at a limit. The limit $\lim_{x \to \infty} \sin x$ doesn't ...
DanielN's user avatar
  • 129
8 votes

Should bytes be signed?

This still boils down to "what do you intend to do with them?" As others have noted, sign extension is a nuisance when deserializing a wider integer, which suggests that unsigned is more ...
Martin Kealey's user avatar
7 votes
Accepted

Why would Short String Optimization not apply to dynamic arrays?

Because the number of elements that could be stored in a small vector optimisation is rarely worth it, and the small vector optimisation is not free. Strings are allocated from single bytes which ...
Jack Aidley's user avatar
7 votes

Why would Short String Optimization not apply to dynamic arrays?

I suspect the difference is that strings are typically immutable, whereas dynamic arrays are mutable. Even if a list is short enough to apply this optimisation, it might soon get long enough that it ...
kaya3's user avatar
  • 19.7k
7 votes
Accepted

When is ABI stability “worth it”?

This is far from a comphrehensive answer but When you need hot reloading Some systems try to be always on. An upgrade requires that a new function or datastructure replaces another in place without ...
Bruce Adams's user avatar
  • 2,843
7 votes

Approaches to enforcing contracts for standard user-definable traits

Contracts! You may already be aware of this, but contracts have a formal meaning as requirements which are checked at runtime. For example, a function in a language like C or Java which throws an ...
tarzh's user avatar
  • 3,924
7 votes
Accepted

Why does the C library include fgetpos()/fsetpos() if the same functionality can be achieved with ftell()/fseek()?

They exist for historical reasons. Originally there was just ftell() and fseek(). This was fine for Unix-like systems, since ...
Barmar's user avatar
  • 1,901
7 votes

Can sine converge to zero at infinity?

It is unclear which properties of sine and cosine are most important to retain as we start to deal with roundoff. The preferred set of properties would certainly be application specific. A compromise ...
Cort Ammon's user avatar
7 votes

Can sine converge to zero at infinity?

What breaks or has counterintuitive behavior as a result? Well, if you define $\sin(\infty) = 0$, then by the same reasoning you'd have to define $\cos(\infty) = 0$ as well, which breaks the ...
dan04's user avatar
  • 1,959
5 votes

Should the method to sort a list modify it in-place or return a new object?

Returning a copy is more flexible. This JavaScript implementation of a List class has both: ...
JMP's user avatar
  • 151
5 votes
Accepted

How does the C++ Committee generally decide what does or doesn't go in its standard library?

Bryce Adelstein Lelbach spoke on this in the CppCon 2020 Standards Committee Fireside Chat at t=17:16 (Bryce is the chair of the Standard C++ Library Evolution group at the time of this writing and ...
starball's user avatar
  • 1,652

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