3 ms·
I don't understand this: "Why have a graph library when you can just embed the graph naturally in the data?" Why do you need a graph library in Java? Why cann
by nadam 16y ago
I don't understand this:
"Why have a graph library when you can just embed the graph naturally in the data?"
Why do you need a graph library in Java? Why cannot you embed the graph into the data in Java?
class Node { List<Node> pointsTo; }
Java is a bit verbose, but it is not something from the devil. Also some of this verbosity is because of strong typing, which is self documentation, provides for nice tool support and for compile-time detected errors.
Of course you might need a graph library to use pre-packaged notrivial graph algorithms, but it is independent of the language used.
- jpr 16y agoIn Common Lisp you can embed arbitrary data structures in to your code because the reader can build them at read-time, and it can also evaluate arbitrary code at read time (you can turn this feature off for safety). So "embedding a graph" means something totally different in CL. The CL reader can also basically read both persistent pointers (symbols) and ephemeral pointers (the #N= #N# notation with which you can even read self-recursive structures). Contrast this to Java, where there are no literal datastructures, no reader, and all your data structures must be explicitly built from constructor up. I really wish these things would be something that people would be thaught at universities, but thanks to Java-schools, they aren't.
- ww520 16y agoThat's a good feature in Lisp. How would that negate the need of a graph library? I once needed to do topological sort on a graph. Sure I can code it myself but I ended up calling the Boost library for it.
- rikthevik 16y agoI think he's referring to defining existing graphs in the code. Because of the relationship between code and data in lisp, you don't need to define graph objects and connect them all at run-time, which you'd have to in Java. It's like who in Python you could say mydict = { "a":1, "b":2 } as opposed to HashMap d = new HashMap(); d.put("a", 1); d.put("b", 2);
- ww520 16y agoIf that's the case, why does one need to use a graph library to construct simple graph data structure? It looks like JGraphIt is used as a strawman argument to exaggerate the difference. BTW, Java does support some notion of literal construction using array. e.g. new Object[] {"abc", "xyz", 1, 2, 3, new Integer[] {4, 5, 6}, new Node(2)};