The tag has no wiki summary.

learn more… | top users | synonyms

14
votes
5answers
5k views

Should a string constant be defined if it's only going to be used once?

We're implementing an adapter for Jaxen (an XPath library for Java) that allows us to use XPath to access the data model of our application. This is done by implementing classes which map strings ...
1
vote
4answers
139 views

Possible applications of algorithm devised for differentiating between structured vs random text

I have written a program that can rapidly (within 5 sec on a 2GB RAM desktop, 2.33 Ghz CPU) differentiate between structured text (e.g English text) and random alphanumeric strings. It can also ...
9
votes
2answers
649 views

Why are Python strings allocated on the stack?

According to this Python code visualizer, Python strings are allocated on the stack and not on the heap. Why is this? I thought they would be similar to Java where Strings are allocated on the heap.
8
votes
5answers
3k views

How can I extract words from a sentence and determine what part of speech each is? [closed]

I want to write something that takes a sentence and identifies each word it contains and defines what part of speech each word is. For example Hello World, I am a sentence would return this ...
5
votes
6answers
8k views

string.format with variables vs inline variables

What are the pros/cons (if any) to using string output; int i = 10; output = string.Format("the int is {0}", i); versus string output; int i = 10; output = "the int is " + i; I have always ...
4
votes
5answers
2k views

Alternate string formatting options in C++?

I'm looking at optimizing some string formatting code that's hit a lot in our code. We had been using ostringstream, and I converted the code to use sprintf (actually Microsoft's more secure ...
6
votes
3answers
2k views

What performance can we expect from std::string's c_str()? Always constant time?

I've been doing some needed optimizations lately. One thing I've been doing is changing some ostringstreams -> sprintfs. I'm sprintf'ing a bunch of std::strings to a c style array, ala char foo[500]; ...
0
votes
2answers
6k views

Best practice Java - String array constant and indexing it

For string constants its usual to use a class with final String values. But whats the best practice for storing string array. I want to store different categories in a constant array and everytime a ...
11
votes
2answers
325 views

How to select a most probable option from the list based on user text Input

I am working over a OCR Application where I need to select a option based on user text input. Ex: Available Options: ["python", "ruby", "java", "clojure", "haskell"] Input: kava Output: java Input: ...
10
votes
6answers
860 views

What are the pros and cons of having a CaseInsensitiveString type in Java?

I'm tempted to create a final class CaseInsensitiveString implements CharSequence. This would allow us to define variables and fields of this type, instead of using a regular String. We can also have ...
2
votes
3answers
807 views

Why do people put '\n' at the beginning of strings?

Very often I get into C code where printf format strings start with \n: printf( "\nHello" ); This in my opinion is an annoying thing that offers no advantages (rather many disadvantages!) with ...
1
vote
3answers
916 views

Search for a sub-string in a given array of strings

I have an array of n strings. I want to select all the elements of the array that starts with the given string. Sorry if that is not clear. I'll give an example. input = "as" array = ["abas", ...
9
votes
4answers
673 views

How defensive should we be?

We've been running Pex over some code, and it has been showing some good things (well bad things, but showing them before it gets to production!). However, one of the nice things about Pex is that it ...
4
votes
3answers
449 views

What should I consider when converting from ASCII to Unicode?

For instance if I had only ASCII characters and then switched to Unicode now I have to consider special characters, and bigger strings or chars. What else along these lines should I be considering? ...
2
votes
3answers
4k views

Why does Java's String class not implement a more efficient indexOf()?

Following the below question on Stack Overflow http://stackoverflow.com/questions/5564610/fast-alernative-for-stringindexofstring-str I got to wondering why it is that java (6 at least) not use a ...
2
votes
1answer
456 views

Types of quotes for an HTML templating language

I'm developing a templating language, and now I'm trying to decide on what I should do with quotes. I'm thinking about having 3 different types of quotes which are all handled differently: ...
6
votes
11answers
521 views

What should I call the process of converting an object to a string?

We are having a game of 'semantic football' in the office over this matter: I am writing a method for an object which will represent the object as a string. That string should be such that when typed ...
32
votes
4answers
1k views

Etymology of “String”

So it's obvious that a string of things is a sequence of things, and so a sequence of characters/bytes/etc. might as well be called a string. But who first called them strings? And when? And in what ...
38
votes
11answers
32k views

SQL: empty string vs NULL value

I know this subject is a bit controversial and there are a lot of various articles/opinions floating around the internet. Unfortunatelly, most of them assume the person doesn't know what the ...
5
votes
1answer
212 views

String class based on graphemes?

I'm wondering why we don't have some string classes that represent a string of Unicode grapheme clusters instead of code points or characters. It seems to me that in most applications it would be ...
20
votes
5answers
2k views

Why are strings so slow?

Ever since my very first programming class in high school, I've been hearing that string operations are slower — i.e. more costly — than the mythical "average operation." Why makes them so ...