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.

Quoting from Wikipedia

The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents.

and from wc3

In order to provide a precise, language-independent specification of the DOM interfaces, we have chosen to define the specifications in OMG IDL

Now I have been programming in Java, C# and PHP and in all these languages the keyword interface is provided, but how do you implement a language-independent interface?

How come you can write an interface without a programming language? Moreover how can you interact with the DOM using any programming language?

If someone invented a new programming language, what are the steps he needs to do to be able to interact with the DOM?

share|improve this question
    
Well, you just said it - you have been using the DOM in Java, C# and PHP. So, they all implemented the interface. Making it... language independent. –  Oded Dec 5 '12 at 12:27
    
@Oded sorry, but what I meant that the keyword interface is provided by the language not the DOM interfaces itself. –  Songo Dec 5 '12 at 12:30
    
The word interface is rather loaded with different meanings. In this case it means the description of the DOM API, to be implemented by different languages, each in its own way. –  Oded Dec 5 '12 at 12:36

1 Answer 1

up vote 5 down vote accepted

How come you can write an interface without a programming language?

You use an interface description language. Those are not programming language because you can't implement anything in them. Of course you could also use a programming language to define the interface (many low-level interfaces are basically defined in C), but this risks tying it too closely to that language through implicit assumptions and features that are not universally supported. IDLs usually represent a smallest common denominator.

Moreover how can you interact with the DOM using any programming language?

Typically by translating the IDL definition to an interface in your language. For many popular IDL/language combinations, there are tools that do this automatically.

If someone invented a new programming language, what are the steps he needs to do to be able to interact with the DOM?

Translate the IDL to his language, either manually or by first writing a converter, then persuade a browser developer to expose the DOM in that language, or write an adapter between existing DOM interfaces and the new language.

share|improve this answer
2  
Or write an XML parser that then builds a DOM in that language. It's just objects, after all. :-) –  Martijn Pieters Dec 5 '12 at 12:33

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.