Coding effiency is about 5-10x.Interesting. Someone quantized the coding efficiency. Where do you get the numbers from? Are you quoting a paper? Or did you make them up?
One fundamental roadblock to good Perl is mis-understanding of Perl listsAnd the most fundamental part of it is not grasping the difference between a list and an array. Which you don't seem to do if I read your post.
There is no need for a "linked list" in Perl! A Perl list does what a C linked list can do and more!There's no "need" for a linked list in C either. Anything done with a linked list can be done in another way in C as well.
Having said that, one of the attractive things of a linked list is it's O(1) removal of a element (assuming you have a pointer to it). Sure you can delete an element from an Perl array (I think you meant Perl array where you wrote Perl list) - but splicing out an element from an array in Perl takes time linear to the distance of the element to an end of the array (so, linear worst case). Also, adding to a linked list (whether in the middle or the end) is always O(1). But not with Perl arrays (not even when adding at the end - it often can be done in O(1), but if perl needs to realloc the space used for the array, it takes a linear amount of time).
Considering that people already have take a huge speed and memory hit when picking Perl over C, and that computers nowadays are much faster and have more memory than 30 years ago, and typically write deletion statements that need to scan the array anyway (@arr = grep {...} @arr), you don't see many linked lists in Perl.
So you should think of a Perl list more like a C linked list.I think that's a very bad advice. It doesn't do justice to Perl arrays (nor lists), and Perl arrays/lists don't deliver the good features linked lists have.
In reply to Re^2: Perl vs C
by JavaFan
in thread Perl vs C
by santhosh_89
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |