DOM – How Is It Language Independent?

domjavascriptprogramming-languageswebweb-development

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?

Best Answer

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.

Related Topic