2
rox79
3y

hey there,

I just wanna ask is JS good for Data Structure?

Comments
  • 6
    Fuck you, that’s my answer
  • 3
  • 1
    Probably the best choice kappa
  • 1
    Most certainly...
    not
  • 1
    If you mean data structured as in typing the long answer is JavaScript is so untyped someone made a language called typescript that compiles into JavaScript to enforce its very primitive types which are basically number object and string. Am I missing a bunch guys ?
  • 1
    @MadMadMadMrMim yes.
  • 1
    @demoralizeddev what other types other than interfaces ? Oh and functions
  • 1
    @MadMadMadMrMim js is great for ad hoc tagging and anonymous types though 😁
  • 2
    @MadMadMadMrMim it’s more that types and data structures aren’t the same thing. of course you could write implementations of data structures like linked lists, binary trees, DAGs, etc in JavaScript despite the lack of strict typing and there are even cases where this is good design. I was being a little silly with my answer. If OP is trying to study algorithms and data structures, JS probably isn’t the best language to choose. Think of a language like java. In the collections API, List is an interface implemented by ArrayList, LinkList, and others. List, ArrayList, and LinkedList can all be considered types (albeit not primitive ones). ArrayList and LinkedList are types backed by different data structures. Arrays and linked lists as concepts are data structures.
  • 1
    @demoralizeddev I was referring more to object structure and design I always considered what you’re talking about collections unless you mentioned binary trees in there for example .
    Oh I remember this 😋
  • 1
    @demoralizeddev correct me if I’m wrong but alit of your examples relate to inheritance more than data structures and polymorphism or the same enabling concepts and code entities
  • 1
    @MadMadMadMrMim my point is exactly that: inheritance and other OOP principles as well as strict typing are different concepts than data structures. I was using the java collections api as an example of how even classes named after data structures that implement those data structures are not themselves data structures. Probably could’ve worded it better to avoid the confusion
  • 1
    @demoralizeddev tis alright
    My answer was a bit vague as well
  • 4
    tl;dr: No.

    JS’s ease of control over JSON is simply amazing. It makes reading and manipulating data so easy it’s honestly really enjoyable.

    However, JavaScript is practically untyped and does automatic and often ridiculous casting, so your data is more ... data painted in watercolors. One wrong brush stroke and everything starts changing.

    Also, it’s single-threaded with high overhead so the performance is crap.
  • 1
    @Root my name is Loki the great and I approve this message
  • 2
    If you need simple JSON parsing , look into jq

    However if you need to have demonic magical powers and lots of data transformation and manipulation, check out https://nifi.apache.org
  • 0
  • 0
    @Root will take a look on Java
  • 0
  • 3
    Short answer , no.
    Long answer , noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo.
Add Comment