Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've seen this now in a number of places and a number of contexts, for example in SQL.

I cannot define the meaning of a "Hint" which it seems clear has some application as or part of a larger design pattern/technique.

What exactly is a Hint when used in software engineering?

share|improve this question
9  
Context please. –  Yannis Rizos May 12 '12 at 21:32
2  
A couple of examples would make this question clearer. –  s d May 12 '12 at 21:33
    
The only time I've seen the term is when providing an initial search path for includes/libraries/etc. It provides a 'hint' to whatever is doing the search so that it (maybe) doesn't need to search the entire filesystem for something. –  Telastyn May 12 '12 at 21:35
1  
I'm aware of numerous things called "hints", and all of them match the (primary) meaning of the English noun (and verb) "hint": A (small) piece of information, a clue (or in the case of a verb: giving precisely that to someone). Except that the topic on which one hints is usually pretty narrow and technical. –  delnan May 12 '12 at 21:57
1  
Another example is font hinting: en.wikipedia.org/wiki/Font_hinting –  James Youngman May 12 '12 at 22:26

3 Answers 3

The notion of hints is a particular way to express a specific API contract, or maybe more precisely, lack thereof. Basic idea is that application developer passes some information to the underlying system / library without any guarantees that it will be taken into account.

I personally like the way how this is described in OpenGL API docs for glHint:

specify implementation-specific hints... a symbolic constant indicating the desired behavior.

  • Note word desired - that's the point. Application developer expresses a desire for implementation to behave in a particular way. Desire is not a mandatory requirement, can be ignored.

Wikipedia article on SQL hints mentions:

Oracle implements hints by using specially-crafted comments in the query that begin with a + symbol, thus not affecting SQL compatibility.

  • Note above means practically the same "permission to ignore" since a database not supporting Oracle-specific hints will execute SQL statement without these.
share|improve this answer

In SQL you do not specify how to do things (in contrary to languages like Java, C#, VB); instead you specify what the result should be. Example, "I want all students with grade A"

SELECT * FROM students WHERE grade = 'A'

This is a very simple situation; however in complex queries the database engine often does not know what the best way to perform the query would be. If you know, for instance, that a certain index would speed up the query much better than another one, you can give a hint, and tell the database engine to use this index.

This is not a standard way of writing SQL statements. It is an advanced technique for tuning slow queries. If you are new to SQL programming, you can safely ignore these hints to begin with.


UPDATE

A completely different example is the rendering of vector based fonts (like TrueType fonts). Rendering involves converting the vector based description of the shape of a character to a pixel pattern. A problem might occur if you render an "m" for instance. Depending on the resulting size, the two arcs of the "m" could get a different width, because of rounding effects. If the resulting width of the "m" has an even number of pixels, the two arcs cannot have the same width. Therefore the description of the "m" has a HINT, which tells the renderer to make the left and the right arc the same with. If the calculated width would measure 8 pixels, for instance, the renderer decides to make it either 7 or 9 pixels wide.

Three "m"s with 8, 9 and 7 pixels width

0·00·00·    0·00··00·    000·00·
00··0··0    00··00··0    0··0··0
0···0··0    0···0···0    0··0··0
share|improve this answer

It means the same thing that it means in English: a hint is a clue. For example, some processors improve their performance by predicting whether or not a given branch will be taken. If the processor guesses wrong, it has to back up and refill the instruction pipeline; if it guesses correctly, the code runs quickly because there are no pauses in the pipeline. The programmer or compiler can often tell whether a branch is likely or not, and can provide a hint to the processor to improve the accuracy of its guess and therefore improve performance. So, the processor will end up with the right result with or without the hint, and it'll even get the right result if its branch prediction is incorrect 100% of the time. But accurate branch prediction speeds things up, and providing a good hint can increase that accuracy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.