Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
It's a myth that Perl has more complex datastructures than other languages. It doesn't. In fact, Perl doesn't even have complex datastructures build in the language. All it has are scalars, arrays, hashes, and references. That's it.

It's a mistake to consider $foo [$bar] {$baz {$quux}} to be a complex datastructure. It ain't. It's still arrays and hashes. One does the same thing in C, except that one is more likely to use a struct instead of a hash. But in C, that still isn't complex. Now, a five dimensional partition tree using epsilon nets, with associated k-d trees in the nodes, that's a complex datastructure.

The only thing "complex" about $foo [$bar] {$baz {$quux}} is the long single expression to get an element out of it. But you have your data, and you need to store you data somewhere. Preferably in a way to retrieve your elements. And regardless whether you use arrays, hashes, or objects, you have two options. Either you nest, or you don't. And if you nest, you either use long single expressions to get to the data, or many short expressions. (Note that this is independent of the language you are working in). If you don't nest, I doubt your datastructure becomes any clearer.

BTW, I don't agree with Rob Pikes claim which FoxtrotUniform brings up. Nor do I agree with Wirth's "Algoritms + Datastructures = Programs". I believe that datastructures imply the algorithms. One cannot choice a datastructure and afterwards come up with the algorithm. The algorithm has to follow the rigids of the datastructure.

Abigail


In reply to Re: Nested data structures... nasty? by Abigail-II
in thread Nested data structures... nasty? by vladb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-28 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found