Skip to main content

Questions tagged [standard-library]

For questions relating to designing and implementing standard library features

Filter by
Sorted by
Tagged with
2 votes
1 answer
225 views

Is it practical to use binary trees as a sequential container?

Contiguous arrays do not mix with lazy evaluation. That's why Haskell doesn't have contiguous arrays as a primitive type, and why even GHC has a poor API for them. As such, I sought for a workaround. ...
Dannyu NDos's user avatar
3 votes
3 answers
567 views

Why does C++'s unordered_map::erase fully invalidate iterators, not even supporting advancing?

The documentation on C++'s unordered_map::erase states: Removes specified elements from the container. The order of the remaining elements is preserved. (This ...
Luatic's user avatar
  • 330
11 votes
0 answers
281 views

Where does Go's datetime formatting pattern come from? And why was it chosen?

Go's time formatting strings are uniquely idiosyncratic, and I have not seen any other language use this sort of system: It is based on the exact timestamp for ...
bigyihsuan's user avatar
  • 1,821
12 votes
9 answers
5k views

Should bytes be signed?

I’m trying to decide whether my language should provide signed or unsigned bytes, but I’m struggling to find a good reason to choose either side. Popular languages vary in their decision. For example, ...
feldentm's user avatar
  • 1,779
14 votes
12 answers
7k views

Can sine converge to zero at infinity?

In common languages, sine produces an error, NaN, or exception when evaluated at infinity. For example, in Python: ...
Corbin's user avatar
  • 851
5 votes
3 answers
303 views

Reading Floating Point, perhaps without libc/msvcrt

Given a new language, how best should we convert decimal to binary floating point? And please don't just say "use strtod(3)": The venerable C function supports a baroque variety of weird ...
Ian's user avatar
  • 153
4 votes
2 answers
429 views

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

C includes 2 methods for saving the position of a stream and setting it later. Using fseek() and ftell(): ...
CPlus's user avatar
  • 8,301
14 votes
2 answers
2k views

How do languages support executing untrusted user code at runtime?

Many dynamic languages such as Javascript, PHP and Python have a built-in eval function for executing code from a string. It's well known that such functions are ...
kaya3's user avatar
  • 19.4k
11 votes
4 answers
307 views

Approaches to enforcing contracts for standard user-definable traits

Many languages have some user-definable traits, interfaces or protocols with special status in the language's semantics or standard library, for which there is some kind of "contract" ...
kaya3's user avatar
  • 19.4k
8 votes
5 answers
959 views

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

As of C17 there are no built-in constants. To use true false NULL or similar one must ...
CPlus's user avatar
  • 8,301
5 votes
2 answers
307 views

Why would Short String Optimization not apply to dynamic arrays?

Short string optimization is the optimization that sufficiently short strings have their data stored inline rather than an external buffer, so the string type ends up being a union. Swift does this, ...
Bbrk24's user avatar
  • 9,007
4 votes
3 answers
276 views

What limitations are there to adding timing functions to a standard library?

Most programming languages such as Python and C++ but only after 2011 have some way of initiating a time delay for a fixed amount of real time. C lacks any of such facilities and C++ lacked them until ...
CPlus's user avatar
  • 8,301
7 votes
2 answers
539 views

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

In C to create a UI one must use a 3rd party toolkit such as GTK. However I read about Swing and AWT in Java which appears to be different implementations of UI toolkits built-in to the Java language. ...
CPlus's user avatar
  • 8,301
20 votes
5 answers
4k views

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

Most languages seem to only have sin cos and tan. While the other 3 are just ...
CPlus's user avatar
  • 8,301
9 votes
1 answer
2k views

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

I can't help but to notice that not all str* functions have mem* counterparts, even when having them would make logical sense. ...
user1345541's user avatar
10 votes
3 answers
509 views

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

Java has the @Override annotation. This annotation, when applied on a method, basically says that this method is intended to be an override of a superclass method. ...
Seggan's user avatar
  • 2,683
8 votes
3 answers
394 views

When is ABI stability “worth it”?

ABI stands for application binary interface, and it represents how different precompiled components of a program interact. This can be a program calling out to an OS function or part of the language ...
Bbrk24's user avatar
  • 9,007
1 vote
1 answer
237 views

How to avoid hidden performance problems in functional interfaces?

Swift has a protocol Sequence<Element>, which is used to support for-in loops. It has ...
Bbrk24's user avatar
  • 9,007
2 votes
1 answer
343 views

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

I want to learn from how some existing, well-known, well-established languages define their standard libraries. As a first step- before getting in to the deeper "why" questions, I want to ...
starball's user avatar
  • 1,652
5 votes
2 answers
122 views

Language Feature vs Standard Library [closed]

What are some factors that determine what features get built into the language itself and which ones get implemented in the standard library?
CaseyB's user avatar
  • 175
6 votes
5 answers
247 views

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

Say I have a list class which has a sort method. ...
lyxal's user avatar
  • 1,775
3 votes
1 answer
116 views

What are options for implementing a standard queue type?

As some examples of standard queue types: C++ has deque (queue is just a wrapper around it), which is typically implemented as ...
Bbrk24's user avatar
  • 9,007