Questions tagged [standard-library]

For questions relating to designing and implementing standard library features

Filter by
Sorted by
Tagged with
11 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,749
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
  • 724
5 votes
3 answers
292 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
3 votes
2 answers
382 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(): ...
user16217248's user avatar
  • 7,535
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
  • 17.3k
11 votes
4 answers
299 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
  • 17.3k
8 votes
5 answers
923 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 ...
user16217248's user avatar
  • 7,535
5 votes
2 answers
252 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
  • 8,857
4 votes
3 answers
271 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 ...
user16217248's user avatar
  • 7,535
7 votes
2 answers
527 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. ...
user16217248's user avatar
  • 7,535
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 ...
user16217248's user avatar
  • 7,535
8 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
477 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,603
8 votes
3 answers
315 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
  • 8,857
1 vote
1 answer
228 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
  • 8,857
2 votes
1 answer
319 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,642
5 votes
2 answers
111 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
226 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
109 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
  • 8,857