1

I came across this question while reading my course "Programming Languages" and found it intriguing. I want others' opinions on this:

Some language definitions specify a particular representation for data types in memory, while others specify only the semantic behavior of those types.

For languages in the latter class, some implementations guarantee a particular representation, while others reserve the right to choose different representations in different circumstances. Which approach do you think is better and Why?

My opinion is, the latter approach is better because we can define our own custom data types and use them in different ways in different places and situations. What do you think?

1
  • 1
    This has nothing to do with custom data types; it's about how loose the spec is.
    – SLaks
    Oct 20, 2013 at 19:29

2 Answers 2

1

Judging from the explanation portion of your answer, it looks like you have completely misunderstood the question.

Programming language standards require a particular representation of data types from implementations of the language, i.e. the language compilers, interpreters, or virtual machines. It is the designers of these compilers, interpreters, and virtual machines who may be given a choice in deciding the representation, not programmers in the corresponding language.

The "Which approach do you think is better and Why?" part of the question requires you to analyze the process of designing a language from two different points of view - that of programmers who builds the language, and that of programmers who writes programs in that language. What may be good for one group of programmers may not be good for the other group. Moreover, what one group may think is good may actually create an ongoing maintenance problem.

For example, if the specification says that integers must be represented as 32 bits that use two's complement representation for negatives, designers of programming languages who port the language to hardware with sign+value representation may have a lot more work to do. On the other hand, programmers writing in a language that does not specify the representation and assuming that the representation would be the same on all platforms may create completely non-portable programs.

0

I depends what are you going to implement.

Some languages such as C represents the data directly to the memory but Java represents the data to Java Virtual Machine.

The question may be more accurate if you ask how close to real machine you want to manipulate your data.

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