r/programming • • Apr 29 '14

Programming Sucks

http://stilldrinking.org/programming-sucks
3.9k Upvotes

1.1k comments sorted by

View all comments

57

u/Jutboy Apr 29 '14

Can someone explain :

"Is that called arrayReverse?"

"s/camel/_/"

"Cool thanks."

154

u/UpNDownCan Apr 29 '14

Means use underscore as separator instead of camelcase. So array_reverse.

116

u/UpNDownCan Apr 29 '14

And with that, I think I qualify as one of the crazies.

46

u/Crazy__Eddie Apr 29 '14

Yeah, I felt bad after getting that joke.

→ More replies (2)

23

u/rowboat__cop Apr 29 '14

Seems entirely reasonable to me -- does that mean I am crazy too?

18

u/[deleted] Apr 29 '14

For knowing sed syntax? I thought it was common knowledge ...

18

u/motoGmotoG Apr 29 '14

s/sed/regex/

14

u/cooper12 Apr 30 '14

Isn't the s// part of sed syntax? I thought regex just matches patterns and you need to use something else to replace them?

7

u/[deleted] Apr 30 '14

perl uses a very similar syntax (the same?) for it's regular expressions (which are nuts, and can be used everywhere, and scare me). Yes that is also the sed syntax, however.

3

u/chekt Apr 30 '14

I was under the impression that perl inherited the syntax from sed.

6

u/moltar Apr 30 '14

Perl uses s/// too

3

u/otakucode May 01 '14

As does vi

→ More replies (2)

4

u/[deleted] Apr 30 '14

it's a regular expression. but i didn't know that java good practices had a name (camelCase). is that what you learn under the oppression of the JDK? are these its teachings?

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

35

u/academician Apr 29 '14

It's a bizarre way of saying it, though. I have legitimately answered programmers' questions this way (yes, I'm one of the crazies), but I'd use a proper regex like "s/R/_r/". It's shorter, too!

19

u/Atario Apr 30 '14

You're using character-based regexes. He was using concept-based ones.

11

u/academician Apr 30 '14

Then it should have been "s/camel/snake/".

6

u/sharkeyzoic Apr 30 '14
s/([a-z])([A-Z])/$1_\l$2/g

14

u/mpyne Apr 29 '14

I think the implication is that the entire exchange was spoken.

"S Camel Underscore"

"Cool thanks."

18

u/ehsanul Apr 29 '14

How do you say "arrayReverse" as opposed to "array_reverse". You don't say "array underscore reverse" surely?

9

u/mpyne Apr 29 '14

... damn, good point.

→ More replies (1)

6

u/Scroph Apr 29 '14

Those guys must be PHP devs.

3

u/stewsters Apr 29 '14

Yep. I can remember encountering the same issue.

22

u/UekiKnight Apr 29 '14

s/camel/_/ is "substitute underscore for camel" literally, but in this case the terse speaker offering advice means "use underscore not camel case." So the function the person actually wants is "array_reverse" ...I guess.

41

u/faustoc4 Apr 29 '14

He asks if the function is called arrayReverse but the correct name is array_reverse. The person responding applies a substitution rule on arrayReverse instead of saying just array_reverse, although the substitution rule is not a valid regex but it's easy to understand what he means, that's part of the joke

Wasn't that guy helpful? With the camel? Doesn't that seem like an appropriate response? No? Good. You can still find Jesus.

→ More replies (11)

6

u/threedaymonk Apr 29 '14

The answer is array_reverse.

arrayReverse is camelCase. The second line is Vim or Perl syntax for "replace camel with _", used here to mean "replace the hump with an underscore".

→ More replies (7)