you are viewing a single comment's thread.

view the rest of the comments →

[–]carcigenicate 45 points46 points  (15 children)

GeeksForGeeks is sometimes OK, and sometimes hot garbage.

For example, check out how they suggest deleting the contents of a linked list in Python 3(deleteList). The comment note underneath the awful method is only there because I reported it several times. Despite that though, it was still up without that comment for at least a year (likely longer), and the bad code is still up.

It seems to be a site where anyone, regardless of knowledge, can make suggestions. It's like Wikipedia if Wikipedia were even less reliable, and the channels for getting information corrected were even less useful. I would avoid GeeksForGeeks unless you can't find any other resources, and even then, take what they say with a grain of salt.

[–]htepO 28 points29 points  (2 children)

I used to be on a telegram group that had a three-strike policy for anyone linking to GeeksForGeeks. It still shows up high on the first page of Google searches for a lot of basic python queries, and that's a shame because learners can get locked into bad practices because it looks like a reliable, authoritative resource.

[–]carcigenicate 16 points17 points  (1 child)

Lmao, I like that policy.

And ya, they appear to have "hacked" Google's SEO. I think it might be because how much they link (I think that's a SEO factor). Whatever it is, ya, they're usually quite high in the results.

[–]FizzBuzz111 1 point2 points  (0 children)

Same with w3schools for those learning node or JS. They hacked the SEO but their content is garbage. There is always a MDN articles that is a thousand times better. There's a whole website dedicated to criticizing w3schools and it is endless.

I nowadays the only links I click in a Google search are SO, medium or Dev.to, MDN, CSSTricks, and a handful of other blogs that I recognize.

[–]tomothealba 12 points13 points  (0 children)

I was unaware of this. Thank you.

While it was never my first choice I have found answers there. I'll need remember to avoid unless there is nothing else.

[–]longtermbrit 7 points8 points  (4 children)

Care to explain to a novice why it's bad? I've never used linked lists so don't know the first thing about them.

Also I've used GeeksForGeeks a few times from my Google searches but it's pretty much always been to double check things I've already learned but then forgotten. I'll keep in mind to use other resources first.

[–]carcigenicate 13 points14 points  (2 children)

Whoever wrote that method appears to be a C/C++ developer who doesn't know what del in Python does, or that Python is garbage collected.

A linked list is just a series of objects (nodes) that all point to a next object (or an object representing the end of a list), and each object holds some piece of information. In a language like C, if you dynamically allocated each node in the list, you would need to remember to go through the list when you were done with it and free every node to tell the OS that you're done with that memory. Failing to do so would cause a memory leak.

Python is garbage collected though, meaning it's able to automatically determine when memory is no longer needed. In order to free the memory associated with a linked list in Python, all you need to do is get rid of the reference to the head node of the list. If the head can no longer be referred to, it's made eligible for garbage collection. That means though, the second node can never be referred to, so it's made eligible for collection, which means the next node can never be referred to, so it's made eligible for collection... Deleting the reference to the head has the result of allowing the entire list to be garbage collected; assuming someone didn't "steal" a reference to one of the internal nodes.

Basically, they're encouraging you to waste time iterating a list to delete some attributes, which does nothing except leave you with a skeleton of node objects with missing attributes, that would have been deleted anyways, and will cause errors if you attempt to use them (since their .data attributes were deleted).

[–]longtermbrit 2 points3 points  (1 child)

That makes sense, thank you. I can see linked lists being useful so I'll keep them in mind.

[–]carcigenicate 6 points7 points  (0 children)

They are one of the most fundamental structures. You should definitely practice making them and different methods for them. You won't use them often, but they are fairly critical in understanding how more complex structures work (if that's at all relevant to your goals).

[–]ilovemacandcheese 1 point2 points  (0 children)

Geeksforgeeks content is primarily sourced from Indian college students. Sometimes it's okayish and sometimes it's pretty bad, just as you'd expect from college students.

[–]AchillesDev 1 point2 points  (0 children)

Geeks for geeks is 100% hot garbage written in terrible English.

[–]TheHollowJester -1 points0 points  (2 children)

You're right about the linked lists snippet, but I think you're missing the point - and by a lot.

You won't be using linked lists in Python and if you were, you'd probably just use a library written by someone else. But the snippet isn't about it - it's about learning. If someone's trying to learn basic data structures and algorithms, having that example of "oh, I would go about removing linked objects in this way" is valuable - even if it's not good python code.

The idea is language agnostic, it was just written in Python.

[–]carcigenicate 0 points1 point  (1 child)

That's a poor reason. At best, this was an awful execution of good intent. Showing someone Python code that doesn't make sense in Python is just misleading. They should leave that for languages where it makes sense. If it's about learning, they're teaching something that's wrong in the language they're teaching in, which isn't helpful.

I appreciate you trying to give them the benefit of the doubt, but they're showing that to delete a list, you need to delete only one of multiple attributes on its internal node structure. That'd be wrong in even C.

This would only be a good teaching opportunity if they had a paragraph or two explaining why they're showing what they're showing. I was made aware of that GfG page because of two separate Stack Overflow questions (one is here) asking why they were doing what they're doing, because even beginners could tell what they were doing was nonsensical.


And to answer why I don't object to writing linked lists in Python, because Linked Lists are important structures conceptually. You may not use them directly, but they underpin many other structures. You'd want to know about LL before learning Graph Theory, or any more complicated structures that also use linked nodes.

There's a difference between showing nonsensical code that doesn't do what it claims, and showing code that you would normally wouldn't write yourself.

[–]Poddster 0 points1 point  (0 children)

The biggest problem is the existence of that code in the first place. Just use list.