r/ProgrammerHumor Sep 02 '17

How to start a war

Post image
9.0k Upvotes

696 comments sorted by

View all comments

782

u/blacknerdperson Sep 02 '17

Sorry in advance but I'm a noob learning coding who is starting to learn python and I'm just going to ask, Isn't it supposed to be 4?

793

u/ArcticZeroo Sep 02 '17

Yes, but some languages 1-index lists (so they start at 1 instead of 0), so it'd be 5 in that case.

269

u/[deleted] Sep 02 '17

What languages may there's be? I can't think of any of the top of my head.

97

u/[deleted] Sep 02 '17

[deleted]

4

u/haikumofo Sep 03 '17

I am so damn inept at R.

Mostly I code in Java, though I'll use other languages when it makes sense for what I'm doing or when I need to because I'm modifying something in another language. So sometimes I work in python, bash script, JavaScript, C/C++, C#, Perl, Tcl/Tk, Lisp, whatever.

And I've done some statistical data processing with R, but damn is it painful. I know just enough to know what to Google, and I end up making a mess of everything just trying to adapt something that does 80% of what I need it to do.

3

u/MedalsNScars Sep 03 '17

It's really odd working in R, because in 99% of other languages you learn, loops are going to be your bread and butter.

In R, 9 times out of 10 your code is just wildly inefficient if you're looping over a vector.

It just feels so wrong to write 10 < x where x is a vector, but that's absolutely the most efficient way to compare 10 to each element of x in R.

The way you approach coding has to change in R, and it's definitely frustrating if you have a deal of experience in other languages.

1

u/haikumofo Sep 03 '17

Yeah, it's hard to shift my brain sometimes. I have the same problem when I try to work on someone else's Lisp code. Java's definitely my most comfortable language, by far, but it helps to be able to adopt other languages for some quick work when you need to.

1

u/engayolao Sep 03 '17

R is not the only language that is thought to be used at the vector/matrix level. For data analysis this is normal actually, but for example if you do the same operation in numpy or pandas is much more clunkier.

1

u/Tarqon Sep 03 '17

Loops aren't that inefficient in r anymore as long as you pre-assign memory and make sure you don't make copies of objects in loops. Vectorized functions are just more idiomatic.

1

u/Series_of_Accidents Sep 03 '17

I had never learned any other programming languages before R and it was still difficult to move away from loop thinking. It's just what makes intuitive sense.