Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 15

For questions about the implementation or design of strings within a programming language.

15 votes

Why do programming languages use delimiters (quotes) for strings?

The feature you're asking about is known as barewords, and they're common in markup languages such as HTML and (La)TeX, where the "strings" indicate text to be displayed, and data languages such as YAML … Ruby and JS can support barewords -- by defining a particular method_missing or using with + a Proxy respectively -- but this is rare in practice, since it makes it difficult to tell apart unquoted strings
Bbrk24's user avatar
  • 9,407
11 votes

What are the advantages/disadvantages of null-terminated strings vs length-prefixed strings?

over-allocation | capacity length This is particularly useful for languages with mutable strings, as it allows append operations to be amortized O(1). …
Bbrk24's user avatar
  • 9,407
6 votes

What are some different approaches to raw string syntax, and what are their pros and cons?

Swift: Raw strings with interpolation Swift, like Rust, uses hash signs for raw strings. … However, you can also interpolate into raw strings by adding the hashes to the interpolation marker: "Regular string interpolation \(x)" #"Raw string with "quotes" in it"# #"Raw string with interpolation …
Bbrk24's user avatar
  • 9,407
12 votes

Should my language distinguish between single- and double-quoted literals?

Avoid escaping nested quotes This is what I do when programming in JavaScript: let foo = "This doesn't need to be escaped"; let bar = 'Neither does "this"'; Is it a deal-breaker to not have this? Abs …
Bbrk24's user avatar
  • 9,407
20 votes

What are the advantages of strings and character arrays being different?

Different definitions of “character” In Swift, the Character type isn’t a single Unicode codepoint (that’s UnicodeScalar), nor is it a single byte (that’s CChar). Instead, it represents an “extended g …
Bbrk24's user avatar
  • 9,407
26 votes

How have modern language designs dealt with Unicode strings?

Swift Swift strings are complicated. … Ordering String equality is relatively straightforward: do the strings represent the same text? However, Strings can also be compared for order: str1 < str2 is legal. …
Bbrk24's user avatar
  • 9,407
3 votes
Accepted

Implementing a number to string semantics efficiently in a C-style language?

Some languages have direct syntactic means to achieve this: let x = 10; let str = "x: \(x)" However that syntax does not allow one to specify radix or minimum digits or similar conversion options I …
Bbrk24's user avatar
  • 9,407