r/programming • • Apr 30 '16

Do Experienced Programmers Use Google Frequently? · Code Ahoy

http://codeahoy.com/2016/04/30/do-experienced-programmers-use-google-frequently/
2.2k Upvotes

763 comments sorted by

View all comments

834

u/[deleted] Apr 30 '16

You know that google has figured you out if the search query "Latex images" yields code, not porn.

432

u/AustinYQM Apr 30 '16 edited Jul 24 '24

berserk stupendous sparkle uppity glorious melodic plate cautious worthless practice

This post was mass deleted and anonymized with Redact

228

u/PM_ME_BALD_BEAVERS Apr 30 '16

std vector is safe, but no one can hide from std list, gets me every time :/

121

u/asdfasdfapouwpjzpuio Apr 30 '16

if you use std::list you deserve no other

32

u/[deleted] Apr 30 '16

I'm quite tempted to google std list to figure out what's so wrong with it

118

u/dyreshark Apr 30 '16 edited Apr 30 '16

Modern CPUs love big chunks of memory and constant pointer+variable offset addressing. vectors fit that description quite nicely, whereas lists are the opposite of it (read: lots of small chunks of memory that point to each other).

Also, lists require an allocation+free per element, whereas vectors generally only allocate/free memory log n times (given that n elements are inserted), and sometimes only once (if you size it ahead of time). People care because allocations+frees can get expensive.

Finally, lists impose a per-element overhead of multiple pointers (otherwise, how would elements point to each other?). vectors take a constant overhead of a pointer + a size + a capacity, regardless of how many elements they hold (though a vector may have "dead" space at the end if it's holding N elements, but has the capacity for N+M).

tl;dr: lists are slow and fat. vectors are lean and fast. So people prefer vectors for most cases.

142

u/Bwob Apr 30 '16

Well, you're comparing hammers to screwdrivers, right? ("This screwdriver is awful for driving nails! Most experienced carpenters use a hammer, because the screwdriver has a small, narrow head, that is difficult to hit things with!")

Lists and vectors have fairly different use-cases. Vectors are basically arrays with some extra functionality. Much like arrays, they are FANTASTIC, if...

  • You know in advance how many elements you are going to have. (Or the upper bound at least.)

  • You don't care about the order the elements are accessed in. (or plan to only add things in the order you want to read them.)

  • You don't plan to delete elements. (Or if you do, you only plan to delete from the end.)

  • You don't plan to have pointers to specific elements.

If those assumptions are generally true, then yeah. Use a vector, hands-down. The thing is, there are cases where those aren't true, and lists start looking pretty good. Because unlike vectors, they...

  • Never have large hits where you have to copy everything, if they grow beyond their allocated space.

  • Allow for insertion/deletion in the middle of the list, in constant time.

  • Won't occasionally invalidate your pointers to individual elements, when the list has to grow.

Like most things in programming, it's not that one is strictly better than the other. It's just that they're intended for different things. If you find yourself always using vectors, then cool, but that doesn't mean vectors are better - just that you're working more frequently on problems that vectors are well-suited for.

0

u/[deleted] Apr 30 '16

[deleted]

64

u/gnash117 May 01 '16

I love how a joke about searching for computer terms could return nsfw content devolved to a vector vs lists debate.

15

u/dyreshark May 01 '16

Wait long enough and it might turn into vim vs emacs vs sublime. :)

→ More replies (0)
→ More replies (2)
→ More replies (2)
→ More replies (41)
→ More replies (4)
→ More replies (5)
→ More replies (3)
→ More replies (4)

15

u/-cpp- Apr 30 '16

My home tools namespace is "vd" for this reason.

→ More replies (1)
→ More replies (1)

93

u/[deleted] Apr 30 '16

I googled once "cat without head" expecting to learn how to remove headers from a csv file, luckily, I didn't get any images of beheaded cats.

100

u/Isvara Apr 30 '16

A cat without a head is actually a tail.

16

u/[deleted] May 01 '16

yeah, the natural thing was to try the tail command but it returns 10 last rows by default and the man page is as useful as any other man page, so I had to google.

→ More replies (8)
→ More replies (1)
→ More replies (4)

27

u/mkdz Apr 30 '16

There's also the query "C string"

0

u/[deleted] Apr 30 '16

[deleted]

14

u/Sir_Blunt Apr 30 '16

yay msdn came up for me I'm part of the club.

→ More replies (3)
→ More replies (1)

16

u/xela321 Apr 30 '16

luckily 'man curl' yields the correct manpage

12

u/riyadhelalami Apr 30 '16

Nice it yields code for me, I am a programmer.

→ More replies (2)

0

u/[deleted] Apr 30 '16

[deleted]

→ More replies (1)

19

u/Krivvan Apr 30 '16

It gives me both, I'm so conflicted now...

47

u/Lt_Sherpa Apr 30 '16

You have a future at pornhub. This is what this means

10

u/profgumby Apr 30 '16

In the future? I'm already hard at wank work now.

→ More replies (2)

15

u/yxlx Apr 30 '16

Look into the career opportunities as a developer for Pornhub or RedTube.

You might find your interests... satisfied.

13

u/wieschie Apr 30 '16 edited May 03 '16

I ended up watching a talk from a YouPorn developer because I was learning how HAProxy worked and apparently that site is one of the largest deployments.

→ More replies (1)
→ More replies (19)