I'm loving node JS and, coming from a Java background, am interested in even trying it out for some projects where node may seem a bit of a stretch, such as a search engine project.
One thing I've been a bit confused by is it seems JavaScript is lacking traditional data structures, for example a set, which has a precise definition extending even beyond computer science as it has been used in mathematics before computers existed (basically a list that doesn't allow duplicates). It seems when using node JS there is no library like Java.util that has these basic data types that I have grown accustomed to, I realize I could create them myself but this just adds more overhead to the project.
Are there any libs for node (or JavaScript in general) that address this? I think node has a lot of potential to replace the use of a language like Java for a lot of projects as it has so many advantages in terms of development speed, but having to recreate data structures that are taken for granted in a more mature platform could be too much overhead for a small project.
I apologize if there are other questions like this, however I spent some time searching and didn't come up with much.
it seems JavaScript is lacking traditional data structures...
Yes, this is javascript, the very concept and implementation of data structure is done quite differently from languages like Java.
I'm not sure that you're really going to find what you're looking for with Javascript. Howver, there are some libraries like underscore
that should make it easier to build the type of structures that you want.
As a lighter and faster alternative to Underscore.js, Lo-Dash (http://lodash.com/) is getting traction those days... But this is not Java.util! :-)
Have you looked into Underscore.js? http://underscorejs.org/
It's not a one to one with java.util but it provides a bunch of commonly needed utility functions.
Collections.js has Lists, Maps, Queues, Sets, and Heaps, all with consistent interfaces. Github.
Something like this: https://github.com/PeterScott/simplesets-nodejs, but with other datastructures?
Have a look at this one: https://github.com/chenglou/data-structures
I think it fits what you are looking for.
I understand that this thread is old but wanted to chime in for future reference and for folks arriving here via web search. I have been building a Node.js library precisely to address non-availability of standard data structures in JavaScript, similar to Java collections. Its available here - https://github.com/monmohan/dsjslib .
contributors are welcome :)
Its no longer true that node.js doesn't have Set
and Map
objects among other things. node.js has had them since at latest v12.
But of course, if you want libraries like java has, check npm or github. You're not limited to what comes standard in node.js.