It is done, the fastest pure Javascript XML parser is ready.

For a new UI framework that I develop I needed an XML-DOM parser. The new framework tReeact, was highly inspired by react.js but want to to render the UI using a templating language of your choice. The Framework will then update the DOM elements in the Browser, in the fastest possible way and with a minimal amount of direct DOM operations.

But the first step is the XML parser. Usually people make a different of two kinds of XML parser. StreamReader and DOM-Parser. Stream Reader are great to read very large files that are even bigger then a few GB. While parsing they trigger Events discribing what was found on the xml-stream. A DOM-Parser on the other hand takes an xmlString and returns an object that represents the structure and data of that XML. Because that object and the entire XML-String have to be in memory while parsing, the size of the parsed xml is limited. There for your programm that is using the DOM-Object can be written in a procedural way, not event-driven, what makes it much easier to reason, debug and develop.

The new framwork tReeact is meaned to handle a webapps UI. And the HTML of an app seldom bigger then 5MB. Thats why tXML became a domParser. The development took serval steps. First I made a basic version that can give nodes, attributes and text content. Then I used this tool to parse different sources. OpenStreetMap, serval websites, there RSS-feeds. I also compared the speed with other projects, like XML2JSON and sax and browsers native XML parser. In the end I was about 5-10% slower in Chrome then native. But the object that I had in the end was a “plane old javascript object”. So accessing the data is much faster then using the DOM API in a browser. That will specially make the tReeact faster, what has to traverse the entire Object to compare.

In other situations the difference will be much more significant. In a direct comparisson with sax vs tXML parsing the Github website and a bigchunk of OSM-Data the advantage was 5 to 10 times in termes of speed. When reading that, please keep in mind that this is a comparisson of a streamReader vs DOM-parser.

Motivated by seeing this advantage, I analysed the tXML parser again. And thought how I can improve the speed and usability for most common cases. A gread win for usabilify was to “simplify” the dom-Object. for that I oriented on PHP’s simpleXML. With a simplify method I return the same object as if it was parsed by simpeXML. This let you access the data very comfortable.

Providing the functions “getElementsByClassName” and “getElementById” the usability as well as the speed is increased. and the speed advantage can be enormouse. because you will use this functions direct on your XML-string. In that way tXML parses only the nessasary Elements, not the entire XML. These methods make tXML the perfect tool, for parsing Data from any website, that not officially provides an API. So, have fun Hacking the Web.

If you are now interested to use the fastest XML parser, for the best user experience in your application, get started and install the tXML parser with “npm install txml”. or download the standalone version for the browser on github. At NPM as well as on Github, you find the documentation.

A short opinion to the end: if you can chose, use JSON in stat of XML to persist and transfer data, this is much easier to access in all programming languages and also very fast in JS.

The short answer is Javascript. When you want to learn to program, you should learn Javascript. With Javascript you can do almost anything. And today it is getting more and more popular, flexible and useful. It started as a small extention to HTML. But today you can do almost anything with it. It is for sure a great technology to get started with.

If you don’t know now what to program, JS is perfect. If you want to do websites, it is perfect, you want to make iOS, Android or desktop applications, it is perfect. You want to do Server applications, it is perfect. You want to do some script to do some tasks, it is perfect. You want to do some game in 2D or 3d, it is very good. You want to do some Internet of Things (IoT), it is great. You need to handle big data it is great.

My tip, do not try to do class-based programming in JS (for details read object oriented programming is bad)

As soon as you know some javascript. you learned

  • flow control: if, switch, do, while, for
  • variables: var, Array [], Object {}
  • async programming: callback, anonymous function

Often I ask myself why many people can not program. Often I even see developer and think, you can not program right? But actually, I see, that it is not an issue of not being able to code, it is not want to code. And this is reasonable. When people start learning to code, there are some simple and logic examples. Learn variables, loops, conditions, classes, structures, lists but how do I build a GUI? I think this is two totally different things. When you are able to make cool UIs with great smooth effects and a good structure. you learned to make UI and how to use the GUI framework. But using a gui framework has nothing to do with programming, even thou, UI developer are considered as programmer and developer.

But what about algorithms, data structures, software, architecture, communications,…? most of thous things are not necessary when programming today. So, to make a cool app, it is not necessary to know what is a double-linked-list, a B-tree or bubblesort. As a JS developer today you just take array and done. And I think this is good!

But what is it, how to be a programmer? what do you need to say “I can code.”

Actually, I think to say that, one of the above skills is enough. To be able to code is every day a new decision, I want to solve that problem. That problem can be in the UI, Database, in some algorithm. To be able to program it is important that you are motivated and patient to analyse a problem and work out a solution step by step.

Not necessarily and by that I do not judge about opensource. Often when people want to describe opensource and how it is created. It seems the developer program all the fancy stuff from the goodness of there heart and if they don’t they don’t even share there stuff not from the goodness of there heart. The most software that I am using today is opensource and most of it was developed and shared because of try and hard business-interests. And do I think that is good? Yes, of course. And there are a bunch of reasons why people create openSource software.

quality

As an individual I already developed and published a bunch of frameworks, libraries and tools in javascript. Did anyone use that stuff? mostly not. For that there are many reasons. One is that nobody know me. But much more important nobody trust me. And actually, they are right. when I published the tObservable framework, I thought it is much more powerful then Angular. More easy to use, also powerful templates. But still, when google is setting a team on a webframework they have much greater resources to ensure the quality. ensure it is bug-free and follows common best practices. When I look back at my now 4 year old framework, I still think it is very cool. When I developed tObservableJS it was my goal, to make it easyer to learn then other frameworks. But because of the many bugs , wrong behaviors and browser incompatibilities it was still difficult to use. And while debugging I often had to debug the framework again. So companies can put more resources on a single project to improve it and to prove its productivity.

support

When you build a company internal tool, it will propably only get developed as far as nessasary to fulfill the current needs. Even it the tool would have a much greater potential. In your company it will left behind, it will do its job and as soon as you need some additional functionality someone has to analyse the code and impement it. When you publish it as opensource. The company can later be lucky. Maybe someone else needed that new functionality together with that tool too. So he impemented it and you just need to pull the changes. That will have saved money and time in both of your pockets.

innovation

Not just that, when a company is going to opensource some code. The company what that tool to have a good image and transport that image back to the company. So before publishing code in the name of the company, they will take some actions to improve the quality. In that process, it is very likely that they not just improve the quality of the existing functionality but also add some close related functionality that is easy to implement and valueable to the project.

business

In business, the most expensive thing is time. When the developer you are going to hire need a week or two to learn your tools, the company actually pay that guy or girl to study. For the company it would be more interesting to hire someone who already knows how to work with the own software. That is motivating the company also to improve the documentation. write it down once, many next developer can learn and that is a great deal for anyone.

And here you got it, with the hard facts of business, you see, how great software is getting developed as opensource, even in companies that just think for there own advantage.

Software development is a broad field and even web-development is a field that can not get covered by a single person. I am taking, discussing, reading, learning about web-development very much, since many years. But still it happen, that I talk with someone who just started programming, and then is able to tell be something I don’t know, but actually is very interesting, good to know and even has impact on how and what I program next.

On the other hand, I have many thoughts, that I share with people. Sometimes they are stupid, sometimes they are just opinions, but sometimes someone else is telling be a great Idea and thought, that I even had long time ago. But I didn’t follow those thought. Because they are not worth, it is not to important, or I have just no time. And next time, I want to tell the guy “you are right, I even wrote a post on my blog about it. check it out at tnickel.de.”

So, in this blog I will also post some development Ideas, that I have no time to implement jet, but I would love to use as a software. means, keep reading, maybe your next business idea is somewhere hidden in my thoughts.