# Is it possible to have 2 languages with different syntax but the same semantics? [closed]

I have two questions

Is it possible to have 2 languages with different syntax but the same semantics? If not why not else give an example of 2 languages .

Is it possible to have 2 languages with same syntax but different semantics? If not why not else give an example of 2 languages .

I understand that the syntax is the external visible representation of a program and the semantics is the meaning of a program can some one please help answer these questions thank you.

Sorry if I wasn't clear but I was looking for examples of languages for example for the first question i have C# and VB.NET does that seem appropriate?

## closed as unclear what you're asking by Luke Mathieson, Shaull, Alexey Romanov, D.W.♦, Raphael♦Feb 26 '14 at 7:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• This is a dump of an exercise problem, not a question. If you have a specific question regarding the wording of the problem or concrete steps in your own attempts at solving the problem, feel free to edit accordingly and we can reopen the question. See also here for our homework policy, and here for a relevant discussion. You may also want to check out our reference questions. If you are uncertain how to improve your question, why not ask around in Computer Science Chat? – Raphael Feb 26 '14 at 7:00
• @Raphael It does not look to me as a problem dump (but you may have a reference to back your assessment), and it is also a pretty good question. Though the exiting answer gives fairly trivial examples somewhat built for the sake of answering, and not very convincing, there are many good examples taken from practical systems. It is really a pity to have closed that question. It may be trivial for experienced computer scientists, but I am not sure it is for less experienced people. And there are both theoretical and practical angles. – babou Jun 2 '15 at 12:30
• @Raphael I can hold that view even when we restrict the question to programming languages, and provide specific examples. It is however not too interesting when trying to compare two distinct programming languages as the OP seems to be doing (which leads me to believe it is not a problem dump ... ) – babou Jun 2 '15 at 12:41
• @babou It's been a long time, and it's unlikely the OP will return. Paragraphs two and three read like dumps to me, the rest I don't know about. – Raphael Jun 2 '15 at 13:22
• @Raphael You are right ... it is the style of a dump, and it explains the answer, which is probably what was expected. What a waste on a nice topic. – babou Jun 2 '15 at 13:40

Sure. I think it may be hard to answer the question using production languages since you are unlikely to find two "real" languages with identical semantics or identical syntax.

Let's consider a simpler example to illustrate the concepts. Take JSON (which I suppose isn't a programming language, per se, but the idea carries over). Now, change it so that instead of separating key-value pairs with colons we use equals signs and instead of separating items with commas we use semi-colons. Now it looks like this:

{
"name" = "Bob";
"age" = 23;
"titles" = [ "Mr."; "Dr."; "Sir" ]
}


This is clearly semantically the same as the following, syntactically different string:

{
"name" : "Bob",
"age" : 23,
"titles" : [ "Mr.", "Dr.", "Sir" ]
}


A bit of a simple example, but it should illustrate the point.

As far as the other direction is concerned, that is also true. For example, consider the standard for loop found in many languages:

for (int i = 0; i < 10; i++) {
// do something...
}


This loop runs the initialization step once at the beginning, tests the condition before each iteration of the body, then runs the update step at the end of each iteration. But I could define a language with the same syntax but where the condition is evaluated at the end of the iteration and the update occurs at the beginning. The standard version is semantically the same as:

int i = 0;
while (i < 10) {
// do something
i++;
}


whereas my new definition is equivalent to

int i = 0;
do {
i++;
// do something
} while (i < 10);


which is clearly different.

• Please consider not to encourage undesirable posting behaviour. – Raphael Feb 26 '14 at 7:01
• I'm sorry, I didn't consider this question undesirable when I answered it. But I tend to be more flexible on that than many others. – Jeremy West Feb 26 '14 at 7:02
• If you follow my link you'll find posts that detail why we (as in, the core community or many high-reps) think that problem dumps are no good for the site. If you think the question is no dump, please raise the issue in Computer Science Chat or on Computer Science Meta. You can also flag for moderator attention (see links beneath the question). Once you have enough reputation, you can vote for reopeneing.) – Raphael Feb 26 '14 at 7:07
• I did read the link. I'm not objecting to closing the question -- I don't have a dog in the race, so to say. – Jeremy West Feb 26 '14 at 7:08
• Okay, just wanted to make sure you know all the tools you have available to make your voice heard. :) Sometimes, questions do get closed even if they should not, and sometimes a good edit can save them. – Raphael Feb 26 '14 at 7:09