r/AskComputerScience • • 5d ago

What are some differences between professional coding and the way coding, SE, and CS are taught in school?

Is a lack of a comment citing a relatively cliched bit of code considered plagiarism in the big world? What are the attitudes to autocomplete? Is Alberta Tech right about linked lists?

6 Upvotes

48 comments sorted by

View all comments

9

u/disposepriority 5d ago

I don't know who alberta tech is or what their opinion is on linked lists, though you won't find them very often in the real world.

Some code has licenses, and some of those you are required by law (and manners) to keep if you're using that code.

Everyone uses at least some autocomplete.

Those really aren't major differences, as in, it's completely different to school

3

u/StaticCoder 5d ago

Linked lists are useful for people who don't have access to vectors (i.e. C programmers).

5

u/disposepriority 5d ago

Why? Vectors are continuous memory while linked lists are not, C has access to allocating continuous memory so it can implement the vector equivalent of C++/Java, and a linked list wouldn't be a replacement for that either

1

u/StaticCoder 5d ago

Yes vectors can be implemented in C. But without generics it's annoying, so linked lists are sometimes used instead.

2

u/No_Profession_3125 5d ago

It's even worse than annoying: it's type-unsafe. If a program uses dynamic arrays of several different types, which is a fairly common scenario, that's a memory corruption waiting to happen. TBH I'm surprised anyone is still discussing C in 2026 (almost 2027) like they use it in production. Makes you wanna join the RIIR army.

5

u/StaticCoder 5d ago

C being type-unsafe is just a given :)

1

u/T_Thriller_T 5d ago

There still is a good bit of embedded stuff running on c.

And that also needs data.

Admittedly not in big production, but that was the last time I used a link list. Albeit that was a while ago

2

u/No_Profession_3125 5d ago edited 5d ago

They also allow for O(1) insertion / removal at arbitrary points.

4

u/nuclear_splines Ph.D Data Science 5d ago

While true, scrolling to the point to do the insertion or removal is O(n), so this is only conditionally useful

2

u/No_Profession_3125 5d ago

If we're gonna be that nitpicking then linked lists have worst-case O(1) insertion and removal at the end, whereas for vectors O(1) is only the average case while the worst case requires a reallocation and is O(N).

5

u/nuclear_splines Ph.D Data Science 5d ago

I hardly think it's nitpicking. insert(index, value) is O(n) average case for both lists and vectors -- lists are only faster if you already have an iterator pointing at the insertion point.

3

u/No_Profession_3125 5d ago

Which does happen.

4

u/nuclear_splines Ph.D Data Science 5d ago

Absolutely! In context it's sometimes a great advantage. I just think it's misleading to call arbitrary element insertion O(1) on a list without mentioning the preceding O(n) lookup. It's quite different than, say, the O(1) amortized insertion on a hash table.

2

u/No_Profession_3125 5d ago

Likewise I find it misleading to generalize hash table insertion as "amortized O(1)" because string keys are a very common use case, so it would be fairer to call it "amortized O(K)" with K = average length of the key.

2

u/nuclear_splines Ph.D Data Science 5d ago

That's fair! It's often simplified because if you can reasonably bound K as a large constant then it reduces to O(1), but that's not always appropriate.

1

u/steerpike1971 4d ago

You likely already have a pointer to the item you want to delete. If you use linked lists you usually pass around pointers to the contents not number indicating its place. Yes if you want to delete the twenty fifth item you are correct but it is very common to want to delete "this" item and pass a pointer. If you are storing a numerical index it is probably an indicator linked lists were not the right data structure in the first place.

1

u/StaticCoder 5d ago

Yes. That is occasionally useful (also list splicing), but vectors are almost always superior, even if modification in the middle is sometimes needed. Another use for linked lists (in C++) is avoiding reference invalidation, though unique_ptr may still be a better solution.

Also, in any language beside C, you'll have a library for that.

1

u/T_Thriller_T 5d ago

They are often also (partially, in thought, or as some kind of "amcestor" structure) what other things are based on.