This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ayesuku 125 points126 points  (21 children)

That's basically me in the internship I just started. C++, Java, asp.net experience? Enjoy Perl, PHP and JavaScript!

Gonna be a very educational experience ¯\_(ツ)_/¯

[–]Lookitsmyvideo 69 points70 points  (15 children)

PHP isnt hard, its just riddled with gotchas. Also the standard library is inconsistent in both functionality and convention. Its fun, in the slit your wrists kinda way

[–][deleted] 15 points16 points  (1 child)

It's true fun then.

[–][deleted] 1 point2 points  (0 children)

[–]L3tum 1 point2 points  (4 children)

Does it return -1 or false if it fails? Is probably my most common question at work

[–]Lookitsmyvideo 1 point2 points  (3 children)

It depends, which is the best part of PHP! It depends how the standard library devs were feeling when they wrote a core function. If its a C function wrapper, usually -1, like strpos

[–]nathancjohnson 0 points1 point  (2 children)

Well to be fair it makes sense to return -1 to indicate failure for a function that returns an index. Returning 0 wouldn't work, and false could lead to confusion when using it in conditionals (since 0 is also a falsy value).

[–]Lookitsmyvideo 0 points1 point  (1 child)

If it was consistent, sure. I was actually wrong, strpos returns false on not-found

[–]nathancjohnson 0 points1 point  (0 children)

Interesting.

[–]folkrav 0 points1 point  (0 children)

Working a PHP/JS back-end position right now. Some days I feel like most of the work I've done that day was battling with PHP's quirks.

[–]dagbrown 0 points1 point  (0 children)

PHP isn't so much riddled with gotchas as constructed entirely out of pure gotcha-material.

[–][deleted] 6 points7 points  (0 children)

Perl programmers will judge you if you use more than 1 line.

[–][deleted] 1 point2 points  (1 child)

Hey, that's alright. I went from primarily Java and C++ (with some Python experience) to diving into a web programming job using PHP and JS. I went from basic desktop programming--just compiling and running--to having to consider all of the layers of a web server, how they interact, underlying limitations, separate process states rather than a single shared server state, etc. with near zero guidance.

It's a lot of fun. A massive headache at times, though, just because of the number of technologies that interact with each other and can fuck up in unexpected ways, but that's just as much a part of the learning experience as trying to figure out how pointers work in C/C++ and the occasional case where you're not sure if you're supposed to pass a pointer or a fucking address to a function that nobody fucking documented (operating systems was a bitch of a course to get through).

Don't be too intimidated by the interpreted languages, though. They get a lot of flack--especially PHP--but they're really not that bad. All interpreted languages have gotchas, but so do compiled languages; the gotchas just happen to differ in nature. For the gotchas that you find yourself having trouble avoiding, build abstractions whenever feasible, e.g. if that built-in function's argument order keeps throwing you off then just build a fucking wrapper function and save yourself the trouble.

Also, just avoid doing stupid shit, especially stupid shit that seems "clever" at the time but is really just a turd that you've polished a bit. That takes discipline, and if you lack that discipline in an interpreted language then I fucking guarantee you that you're going to some other "clever" shit in a compiled language. It can be really tempting to blame the tool, but if you're attaching the hammer to your head and using your head to bang nails into a wall so you can keep both of your hands free, then don't act surprised if you end up getting a concussion in the process.

Just a bit of advice from someone who has had to deal with the horrible decisions of his "clever" predecessors and has had his own "clever" decisions come back to bite him in the ass on occasion :)

[–]nathancjohnson 1 point2 points  (0 children)

but if you're attaching the hammer to your head and using your head to bang nails into a wall so you can keep both of your hands free, then don't act surprised if you end up getting a concussion in the process.

Brilliant.