5

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?

Songo
  • 6,548
  • 4
  • 48
  • 89
  • 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 05 '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 05 '12 at 12:30
  • 1
    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 05 '12 at 12:36

1 Answers1

8

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.

Michael Borgwardt
  • 51,037
  • 13
  • 124
  • 176
  • 2
    Or write an XML parser that then builds a DOM in that language. It's just objects, after all. :-) – Martijn Pieters Dec 05 '12 at 12:33
  • @MartijnPieters +1. Little before I posted question around similar confusion [here](https://softwareengineering.stackexchange.com/questions/381288/browser-internals-is-document-java-script-object) and then I came across this answer. I feel some part of my question been answered here but would you mind taking look at that. – rahulaga-msft Nov 10 '18 at 11:02