Cheap and Secure Web Hosting Provider : See Now

How does literals in compiled languages differ from literals in interpreted languages?

, , No Comments
Problem Detail: 

A literal is a piece of data which gets its value at compile time.

Means: Becomes set at compile time and afterward the value is fixed incorporated into the machine code as a code consisting out of 0s and 1s.

What are literals in interpreted languages like for example JavaScript?

As far as I know the code within JavaScript functions aren't touched by the interpreter until it becomes executed.

Can one say that literals exists in these languages? regarding my definition of a literal (first paragraph).

Asked By : mizech
Answered By : David Richerby

A literal is a piece of data which gets its value at compile time.

I don't think that's a good definition of literals. A literal is a source-code token that represents a fixed value of some type. For example, in almost all programming languages, 23 is a literal representing the integer twenty-three. These aren't pieces of data that get their value at compile-time: rather, they are representations of the values themselves. For example if, in Java, you write

static final int magic = 23; 

then magic is a constant (a variable whose value cannot be changed) that is set at compile-time to have the value twenty-three, which is the meaning of the literal 23.

This is no different between compiled and interpreted languages.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/66558

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback