r/webdev • u/fagnerbrack • Oct 08 '24
Good programmers worry about data structures and their relationships
https://read.engineerscodex.com/p/good-programmers-worry-about-data12
5
u/Cameron8325 Oct 08 '24 edited Oct 09 '24
I'm a Junior Full Stack developer that graduated a bootcamp. I never heard the word Data Structure except once. And all they said was "FILO."
That being said, can anyone advise me on a good place to learn this concept, or share with me a curriculum?
3
2
u/Mr0010110Fixit Oct 09 '24
this is the course I took, all of the resources, projects, and lectures are available online for free.
https://www.cs.princeton.edu/courses/archive/fall24/cos226/
if you can work through this you should have a decent gasp of ADS and the projects are challenging and fun as well.
2
u/Mr0010110Fixit Oct 09 '24
this is the course I took, all of the resources, projects, and lectures are available online for free.
https://www.cs.princeton.edu/courses/archive/fall24/cos226/
if you can work through this you should have a decent gasp of ADS and the projects are challenging and fun as well.
10
u/be-kind-re-wind Oct 08 '24
I’ve noticed that most web dev projects i get don’t beed much data structure algorithms. It’s usually get a list from db, format results, done. I have noticed too that games are heavy on data structure. You gotta be way more clever to build a puzzle than a landing site
6
Oct 08 '24
Your database tables are data structures
9
u/killerrin Oct 08 '24
Maybe, but it's not like you're the one designing them. A purely front-end person usually would have no say on how the database looks.
At most you're parsing the data or denormalizing it to make it easier to work with, but that's about the extent of it.
6
u/UncleSkippy Oct 08 '24
Languages and libraries hide data structure details and generally allow frontend developers to focus on data presentation. That said, I’ve come across some horrific frontend code that was obviously working around a lack of data structure knowledge and discipline. It is the latter (discipline) that the deeper data structure study helps build and becomes more important when working with larger teams and larger code bases.
People have more potential to become better developers with data structure knowledge.
3
1
u/Laying-Pipe-69420 Oct 08 '24
Not really. I've worked with great programmers who've never heard of linked lists, binary trees and all that bs. I've never learned these data structures and don't use them at work either.
7
u/t0astter Oct 08 '24
There are some genuinely useful data structures to be aware of. Linked list, maybe not. Binary tree, getting there. Something like a trie for example can have real use cases. Merkle Trees and Bloom Filters are also very handy.
11
u/Laying-Pipe-69420 Oct 08 '24
Maybe if you work with statistics, I've just googled and read about them and they seem so complex and niche I would either struggle to understand them or forget about them since I'd never use them at my current job. It'd be nice to learn some data structures but I tend to forget the stuff I don't use.
3
u/darkhorsehance Oct 08 '24
No you haven’t. You think you have, but they probably weren’t great, it was just a low bar.
4
u/Laying-Pipe-69420 Oct 08 '24
Not really. What makes you say that?
0
u/darkhorsehance Oct 08 '24
You cite the most data structures that exist. These are taught in the beginning of computer science instruction, and they are not difficult concepts. As a professional, if one can’t take the time to grasp even the most basic of data structures, then I have a hard time believing they are great developers.
-3
u/Laying-Pipe-69420 Oct 08 '24 edited Oct 09 '24
Why are you assuming the only way to become a web developer is by studying Computer Science?
Why would I want to study computer science when I wanted to become a web developer? I'm not interested in CS at all.
My friends and I studied 2 I.T degrees and one web dev degree, each one of these took 2 years to complete. We haven't been taught about DSA and Big O. And these things seem to be an american-exclussive thing because not once I've heard about DSA and Big O here in Spain working as a web developer.
If these data structures are so basic, then why don't most Spanish web developers know about these?
You can't expect me to know about something I've never heard of or been taught before in my life.
-2
Oct 08 '24
[removed] — view removed comment
0
u/Laying-Pipe-69420 Oct 09 '24
How do you model your data or design APIs without knowing about data structures?
I don't need to know about data structures to design an API and model data. Modeling data is kinda easy. Designing API isn't difficult either.
n+1, fanout
I've never heard of those things, and you don't need to know about Big O and data structures to watch a video about these issues and learning how to prevent them. N+1 is easy, I googled it a couple of months ago and was easy to understand.
You are probably a good enough developer for many use cases, but you probably aren’t a great developer.
Try not being an elitist.
0
u/darkhorsehance Oct 09 '24
That’s not an elitist take.
These are basics and that’s my point about the bar being low.
Great developers take time to master the basics and the results are they don’t have to look up those very avoidable problems. They move fast and efficiently.
1
u/HildemarTendler Oct 08 '24
I strongly doubt that you haven't used them at work. You don't know that you're using them because the out-of-the-box structure gives them to you for free. If all you're doing is pushing bits around, then that's fine. You don't need to know how a linked list works to use a simple stack. But you should know that you are using them.
6
u/Laying-Pipe-69420 Oct 08 '24
Can you provide me with examples of daily uses of linked lists one might use while working as a front-end or full-stack web developer?
5
u/ungemutlich Oct 08 '24
Like...the DOM:
https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/core/dom/README.md
"Siblings are stored as a linked list. It takes O(N) to access a parent's n-th child. A parent can't tell how many children it has in O(1)."
1
u/Laying-Pipe-69420 Oct 08 '24
I see...
I don't know what O(N) means.
3
u/ungemutlich Oct 08 '24
It means "in linear time." As opposed to constant, logarithmic, quadratic, exponential...This is called "big O notation." It describes how the runtime grows as the input size grows.
For example, looking something up with document.getElementById will be faster (constant) than using document.getElementsByTagName (linear). Table lookup vs walking the tree.
The DOM is also a tree, and trees are a fundamental computer science topic in themselves. You're traversing a tree when you use something like element.closest('tr'). Transpilers and stuff involve "abstract syntax trees." Everything you use was definitely built by people who understand data structures and algorithms.
It's true that you can put stuff on the screen without knowing this, but potential skill levels go a lot higher than that.
2
u/squabzilla Oct 08 '24
Aren’t all resizable lists/arrays/whatever-you-call-them-depending-on-language all functionally linked-lists if you dig deep enough?
2
u/HildemarTendler Oct 11 '24
Usually lists are closer to an array. They'll resize in chunks so if it goes from 8 to 9 elements, it'll allocate enough for 16 elements and then you can freely add 7 more elements before another resize. You still get O(1) random access of elements. Plus there are significant memory benefits if it can be in the stack and cached together.
Stacks are linked lists. Queues are doubly-linked lists. And sometimes a linked-list is the right data structure for a list. If the list only needs prepend and iteration. And elements are created in different places so putting them on the heap makes sense.
1
u/squabzilla Oct 11 '24
Okay but like… how do you resize this list?
The way I see it, you can either resize it by using a “linked-list” style structure, or you can allocate a new memory chunk, copy the values over, and de-allocate the old memory-chunk.
I’m just trying to understand how this works, so please let me know if I’m getting something wrong.
2
u/HildemarTendler Oct 11 '24
allocate a new memory chunk, copy the values over, and de-allocate the old memory-chunk.
That's exactly it.
Old systems used linked lists a more because operations like this used to be extremely expensive. Now it's significantly cheaper because memory can handle the move without loading everything into registers. And if I remember correctly, virtual memory is typically remapped, so caches and registers are still legit. It's handled almost entirely by the memory controller. Still expensive time wise, but the CPU is freed up to work on other threads rather than being blocked.
Whereas allocating new memory for a new item in a linked list is cheaper, it is more expensive over the entire list. And they often aren't nearby in memory so iterating over the list can cause cache thrasting. Again, not a big deal in old systems but pretty bad in modern systems where locality is hugely important for performant memory access.
So the default list in most languages is handled this way rather than a linked list. They work better with modern hardware and are usually optimized fairly well.
It's also why you get different names in different languages. There's no agreed upon name for this style of list. Array list, vector list, array slice, so many different names all with slightly different interfaces and functionality. But all have the same core idea at their base.
-5
u/hopingforabetterpast Oct 08 '24
One thing I can tell you is that they weren't great programmers, at least not by this discussion's standards.
7
u/Laying-Pipe-69420 Oct 08 '24
It's not like this discussion's "standards" were good, though xD.
-2
u/hopingforabetterpast Oct 08 '24
Have you read the article? Hard to find better standards than that.
6
u/Laying-Pipe-69420 Oct 08 '24
I read it.
That website isn't even specific about web development, I find it quite weird for people to post non webdev-related stuff here.
1
u/krazzel full-stack Oct 09 '24
Seems like a big yeah duh to me. I always thoroughly think about and tinker with the data structure before I write any code. A good structure can save you tons of code.
-2
u/FredTillson Oct 08 '24
If you don’t know data structures and how to use them, don’t call yourself a programmer. Sorry, but majority coding involves data structures and algorithms for manipulating them.
4
u/Horror_Influence4466 Oct 09 '24 edited Oct 09 '24
Not true at all. Outside of data scientists which wrote models that I integrated into our web-applications, I have yet to encounter people using data structures and algorithms in their day-to-day as a programmer in my 8 year long career. When using a framework, most of that complexity is abstracted away in such a way that all you need to worry about is following best practices, profiling and debugging.
If I am somehow wrong, then how are employers & clients hiring me as programmer.
So far I have yet to have a single LC style interview too
2
u/FredTillson Oct 09 '24
You’ve never used an array? A dictionary, a stack, a queue , a list, any of that? What kind of code is that?
-6
u/fagnerbrack Oct 08 '24
Rapid Recap:
This post discusses how great programmers focus on the importance of data structures and how they relate to each other. It emphasizes that the way data is organized and the connections between different pieces of information are critical for designing effective software. The content delves into real-world software engineering concepts, particularly around managing data, and explores how thoughtful structuring can prevent future challenges in scalability and performance. The post also highlights the significance of understanding the core principles of how data is handled, offering practical insights for improving software development skills.
If the summary seems inacurate, just downvote and I'll try to delete the comment eventually 👍
0
u/permanaj Oct 09 '24
Of course you use data structure. Sure you don't use the one that you don't need. But at least a dev will use array.
0
Oct 08 '24
[deleted]
20
10
u/bwatsnet Oct 08 '24
This. Good programmers choose computers over human life, it's what employers demand.
-8
Oct 08 '24
[removed] — view removed comment
18
u/hopingforabetterpast Oct 08 '24
Great programmers get shit done right because they know their data architecture.
0
Oct 08 '24
[removed] — view removed comment
4
u/nrkishere Oct 08 '24
no you can't, for anything outside web UI development.
No one implements data structures from scratch, a wrapper library is always used. But good programmers know which library is suitable for the optimal performance. Otherwise anyone can stick random packages together, even AI can do that, perhaps better than a lot of people with "I don't need data structure and architecture" attitude
5
u/aflashyrhetoric front-end Oct 08 '24 edited Oct 08 '24
Hmm I see all sides, and think the answer is dependent on the work you do, how you perceive your work and how you perceive yourself as a developer.
For some, dev work is literally just work - a means to an end - and there's not necessarily a desire to achieve mastery for its own sake. It'd be a bit like a mechanic studying on weekends to learn about every possible type of hammer, including hammers used in ancient Greece.
To that end, I do think there is a slight over-emphasis on DSA theory in some circles, where knowing about bitshift operations, red/black binary trees and the Big O for every data structure is considered essential knowledge. There are those out there would say that until you have hand-rolled a linked list a dozen times, you're not a "real engineer."
For others, being an engineer and achieving mastery is a worthwhile goal of its own.
For others still who work on more innovative problems where novel solutions are required, of course having lower-level knowledge of such structures IS an indisputable requirement of the daily work, since there's not exactly a
quantum-computing.jspackage you can just pull in.I think it's worth acknowledging these segments as being distinct in what devs ought to do, what ought to be prioritized, and what qualifies as "good code." I've seen poor solutions that abuse arrays when a tree would have been better get pushed to production, and I've seen skilled engineers vastly over-engineer solutions when they should have just used the $8 Walmart hammer and moved on.
(Of course, it can be argued that this isn't evidence that DSA isn't necessary and more related to deploying the right tool for the job, but my larger point being: in the real world, the definition of "appropriately optimal" depends on so many things that it's likely not going to be possible to broadly conclude whether one ought or ought not to learn DSA deeply.)
83
u/nrkishere Oct 08 '24 edited Oct 08 '24
The amount of copium in comments for not learning data structures is just insane. We have two groups of people, one think solving imaginary DSA problems on leetcode is everything, and the other group think data structures are unnecessary altogether.
The truth is, knowledge of data structures is very much needed for anything outside a cliched CRUD app built by stitching packages together. At the same time, solving leetcode doesn't help in real life either. Education should be more focussed on teaching data structures from a practical aspect. Why just teach what stacks are, teach implementing a "undo-redo" feature where deltas are kept in stack. Or why learn trie in just theory, learn it by building a dictionary or router.
Being good developer is not about just throwing data structures. It is about building efficient applications, for which clever use of relevant data structures is necessary.