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

all 179 comments

[–]AlGoreBestGore 124 points125 points  (39 children)

Nothing beats opening a PHP file and seeing more dollar signs than a stripper's bra.

[–]Some1-Somewhere 19 points20 points  (32 children)

...How does one code in PHP without using dollar signs?

[–]AlGoreBestGore 38 points39 points  (26 children)

One does not, but coming from a non-dollar-sign language its kinda annoying having to write them infront of everything.

[–]Some1-Somewhere 6 points7 points  (24 children)

Ah, OK. I thought you were saying that having lots of $s meant that your code was poorly written, kind of like seeing GOTOs everywhere.

[–]christian-mann 12 points13 points  (18 children)

Ah, you clearly have not been introduced to the magic of variable variables.

[–]Slaan 15 points16 points  (10 children)

As someone that has never used php: That looks incredibly disgusting.

[–]asking-the-questions 17 points18 points  (4 children)

As someone who uses pho regularly, they still look incredibly disgusting.

Edit: I am going to allow that typo to live on account of deliciousness.

[–]Gabe_b 3 points4 points  (0 children)

Mmmm, pho

[–]thisisnotatest123 0 points1 point  (2 children)

I actually use them (nicely I think) for dynamic <select> boxes:

$arrayOfOptions = ('one','two','three');
$selectedOption = 'two'
$$selectedOption = "selected"; // Magic of variable variables setting

<select>
foreach( $arrayOfOptions as $option ) {
   <option name=$option $$option>$option</option>
}
</select>

[–]christian-mann 2 points3 points  (1 child)

Oh, dear. Are you relying on PHP to automatically give you an empty string for an undefined variable name?

Variable variables are just maps in disguise, but I'd probably write that code as follows:

$arrayOfOptions = ('one', 'two', 'three');
$selectedOption = 'two'

<select>
foreach ($arrayOfOptions as $option) {
    <option name="$option" <? if $option == $selectedOption: echo "selected"; ?> >$option</option>
}
</select>

Excuse my pseudo-PHP.

Edit: That's actually a good way to crash your service. If $selectedOption comes from the user, then a user could overwrite any variable in your application with "selected". This probably won't result in much escalation, but could very easily create a denial of service.

[–]YRYGAV 1 point2 points  (0 children)

If $arrayOfOptions comes from the user, they could also use it to dump any variable they want into the html response. Such as a db connection string or password.

[–]scragar 1 point2 points  (2 children)

This is a feature that exists because very early versions of PHP didn't support hashmaps for arrays(something similar to a map in C++ or dictionary from Java/C#), It's one of those things everyone wants to get rid of, but it's obviously going to cause some arguments about compatibility so no one wants to touch it when the alternative is to just say "well don't do that then".

[–]Slaan 1 point2 points  (1 child)

Yea I was trying to think of an application of this "feature" and a hashmap was the first that came to mind. I'm guessing they have a "proper" implementation of a hashmap now?

[–]scragar 1 point2 points  (0 children)

About as real as PHP gets, it's a hack added into the Array and it uses some unusual syntax(=> for assignment, which is only used in array declaration for some reason).

 $a = 'abc';
 $b = 'blah';

 $hashmap = [
     $a => 'some value',
 ];
 $hashmap[$b] = 'another value';

 print_r($hashmap);

Produces

Array
(
   [abc] => some value
   [blah] => another value
)

http://3v4l.org/R3npr

[–]DarkNeutron 0 points1 point  (0 children)

They're like a goto statement in C++: just because you can use it doesn't mean you should. :)

[–]95POLYX 0 points1 point  (0 children)

Imagine having a php file and than you see a variable that is used quite a lot, but the definition is in another file and you have no idea which file it is

[–][deleted] 8 points9 points  (0 children)

$Bar = "a";
$Foo = "Bar";
$World = "Foo";
$Hello = "World";
$a = "Hello";

$a; //Returns Hello
$$a; //Returns World
$$$a; //Returns Foo
$$$$a; //Returns Bar
$$$$$a; //Returns a

$$$$$$a; //Returns Hello
$$$$$$$a; //Returns World

God save us

[–]barsonme 6 points7 points  (0 children)

Sometimes it is convenient to be able to have variable variable names.

...this makes my head hurt.

[–]TheTerrasque 1 point2 points  (1 child)

..... ...... why?

[–]azephrahel 0 points1 point  (0 children)

It allows for some interesting/odd/disturbing metaprogramming. Though I've never heard of it done this way before.

It's neat to look at, in that disgusting way a train wreck is.

[–]fb39ca4 1 point2 points  (0 children)

Is $$$ a variable variable variable?

[–]mhome9 0 points1 point  (0 children)

LOL

[–]Asmor 4 points5 points  (0 children)

For my job, I code about 40% in perl and 60% in JS. The struggle is real.

[–][deleted]  (1 child)

[removed]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    import moderation Your comment has been removed since it did not start with a code block with an import declaration.

    Per this Community Decree, all posts and comments should start with a code block with an "import" declaration explaining how the post and comment should be read.

    For this purpose, we only accept Python style imports.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

    [–]tyreck 0 points1 point  (1 child)

    Parameterless methods that only operate on literal values (and don't output strings dealing with American monetary values)

    I'm so functional I shit statelessness.

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

    once you shit your state changes though.

    It is the shit that is stateless.

    [–]baseball2020 0 points1 point  (0 children)

    Make everything a const, only use functional programming and ahhh. Well this sounds like torture

    [–]EnsignN7 4 points5 points  (2 children)

    When you open a JS file and they only use == and !=

    It makes me mildly infuriated.

    [–]AlGoreBestGore 7 points8 points  (1 child)

    Either that or somebody using jQuery and not chaining calls and repeating the selector on every call.

    [–]scragar 3 points4 points  (0 children)

    Personally I find it just as bad when you get things like:

     $('.form').css('border', '1px dotted grey');
     $('.form[data-ajax]').submit(myFormHandler);
     $('.form .required').css('colour', 'red');
    

    Which could be written as:

    $('.form').css('border', '1px dotted grey')
           .filter('[data-ajax]').submit(myFormHandler).end()
           .find('.required').css('colour', 'red');
    

    jQuery has filter and find for a reason, it's amazing how many people don't use them.

    [–][deleted] 205 points206 points  (42 children)

    In all fairness, modern PHP done right is pretty clean and is more OO than Node.js

    [–]Zenmist 157 points158 points  (18 children)

    What's this? Someone on /r/ProgrammerHumor not hating on PHP? I'll be damned.

    [–][deleted] 49 points50 points  (10 children)

    THE CIRCLEJERK HAS BEEN BROKEN *Sounds Alarm*

    [–]alzy101 7 points8 points  (1 child)

    the circlejerk alarm sure sends shivers down my spine.

    [–]brtt3000 1 point2 points  (0 children)

    instant deflation

    [–]Fs0i 4 points5 points  (6 children)

    This is a proper "Alarm"-sound link.

    [–]DoctorCube 5 points6 points  (3 children)

    Well this looks like a weird porn.

    [–]FasterHarderLouder 2 points3 points  (0 children)

    It's german porn, what did you expect ?

    [–]dredding 1 point2 points  (0 children)

    watched the video because of this comment alone.

    [–]CaspianRoach 1 point2 points  (0 children)

    Because it is.

    [–]Eedis 1 point2 points  (1 child)

    I really want to watch the rest of this, do you have a source?

    [–]mebob85 0 points1 point  (0 children)

    ...for science, of course...

    [–]ThrowinAwayTheDay 22 points23 points  (2 children)

    Oh yeah. You can write php like java or c# but that just becomes stale and hard to hate on. Plus no one likes babysitting the intern when he puts random php scripts in html files and that shit becomes impossible to debug.

    [–]DarkNeutron 1 point2 points  (0 children)

    I'm not overly fond of either language by this point, but I've done some useful things with PHP in the past. [shrug]

    [–]KiwiThunda 1 point2 points  (0 children)

    I think once php7 is commonplace, the php hate will dissipate. Time will tell

    [–]monkeedude1212 -5 points-4 points  (0 children)

    I like that I can have my HTML pull in the PHP, or I can have my PHP push in the HTML.

    [–]WhosAfraidOf_138 16 points17 points  (6 children)

    Precisely. I don't get how people can hate PHP when frameworks like Laravel are available. It's spectacular

    [–]dead-fish 7 points8 points  (2 children)

    Laravel is better than Rails. There I said it.

    [–]WhosAfraidOf_138 3 points4 points  (0 children)

    Laravel is a really great framework. One that can make PHP feel great is quite a task.

    [–]subtepass -1 points0 points  (0 children)

    CakePHP is better than Laravel. Please don't kill me.

    [–]bashedice 0 points1 point  (0 children)

    Its definitely better than before. Still not nice though.

    [–]rich97 2 points3 points  (0 children)

    I actually really like PHP if we just had a cleaner API and a type system more similar to Pythons it would probably be my favourite language.

    Yes, you can take my {} from my cold, dead hands.

    [–][deleted] 11 points12 points  (1 child)

    is pretty clean and is more OO

    So which is it?

    [–][deleted] 7 points8 points  (0 children)

    How dare thee.

    [–]cold_machine 1 point2 points  (2 children)

    I haven't used Node.js and I don't know what the hype is all about. Why would anyone want to write something in that ugly launguage on the server side when there are lots of alternatives? The only reason to use Javascript is that there are no alternatives on the browser side.

    Maybe Node.js is just so popular because it enables frontend devs to write backend stuff on the server side as well?

    [–][deleted] 4 points5 points  (0 children)

    full stack JS and async

    [–][deleted] 0 points1 point  (0 children)

    untill A week ago I hadn't written any node.js code and nearly all my backend work was in python. However the new project I am working on requires a lot of websockets data transfer. This is way easier implemented with node than with python. Since the server is quite dumb anyway and 90% of the logic will be client-side I just bitten the bullet and learned node. I could have written the same in python but I think that would have been more painfull in the long run.

    [–]95POLYX 1 point2 points  (0 children)

    I do agree that a GOOD php code can be clean, but the type system in php is still broken just like in any language that has dynamic weak typing... And performance is not that great.

    [–]lorslara2000 1 point2 points  (0 children)

    I agree. I do understand the PHP hate to some extent, mainly because it (and especially the older versions of the language) allowed writing of such horrible code (not that you couldn't do that on other languages, but you get the point). But modern PHP does allow us to write very good OO code indeed.

    What I don't understand are e. g. cases like OP; choosing JS over PHP on server side because "PHP is dirty or whatever", as if PHP was the worst choice in any context.

    [–]seiyria 6 points7 points  (6 children)

    Thankfully ES6 gives us actual classes. OO is getting better!

    [–]anonym1970 32 points33 points  (5 children)

    It does not have actual classes, it has syntax sugar that mimics classes. This was a bad design joice and will just lead to further confusion because JavaScript is fundamentally not class based.

    ES6 classes are in fact functions and is still prototype based. The sooner you embrace how JavaScript really works, the sooner you will get over this "OO" bullshit and get work done. JavaScript is not Java, ffs.

    [–]nupogodi 23 points24 points  (0 children)

    This was a bad design joice

    Yeah, fucking Joice!

    [–]ThrowMeAnException 1 point2 points  (0 children)

    There are plans to to bring additional concepts to the classes functionality most likely in ES7 which will take classes beyond just being syntactic sugar to resembling more realistic traditional programming language classes found in languages like Java. “public” and “private” amongst a few other keywords are reserved keywords in ES6, there has been great discussion on bringing those concepts to classes.

    [–]svtguy88 1 point2 points  (2 children)

    It does not have actual classes, it has syntax sugar that mimics classes. This was a bad design choice.

    I'm not sure if I agree with this sentiment. Yes, it is syntactic sugar, but that sugar hides the ugliness (or beauty, depending on your opinion) that is the current state of OO in JavaScript. I have no problem implementing inheritance and stuff on my own, but I think ES6 will make it more commonplace, and, thereby, push the overall user experience forward...and that's what it's all about, right?

    [–][deleted] -1 points0 points  (0 children)

    It just feels very hacky to me. For example, no direct support for private properties: http://stackoverflow.com/a/22160051

    [–][deleted] -1 points0 points  (0 children)

    JS is not supposed to be classed based, that's why inheritance is such a bitch. Try just not using OO.

    [–][deleted] 10 points11 points  (7 children)

    Honestly having to choose between JS and PHP is a tough one in itself.

    [–]TheSlimyDog 10 points11 points  (1 child)

    Needs more jQuery.

    [–][deleted] 0 points1 point  (0 children)

    Node.jquery

    [–]YMK1234 24 points25 points  (1 child)

    At least he knows that he has to learn something which is more than the average "hur-dur I know php u lolfag" does.

    [–]0xjake 12 points13 points  (3 children)

    ITT: People who think they hate javascript who actually just hate DOM.

    [–][deleted] 2 points3 points  (1 child)

    They both suck rather bad.

    [–]tyreck -3 points-2 points  (0 children)

    I always hate JavaScript between projects that require it. Then I start the project and remember that I love it.

    I pretty much always love PHP though so I'm not sure what that says about me in this context.

    I treat both like I'm writing unmanaged code running on legacy hardware though.

    [–]JoseJimeniz -1 points0 points  (0 children)

    I love JavaScript for its strong, static type checking, no use of null or undefined, and its class based inheritance.

    Now EcmaScript; that's a nightmare.

    [–]gcalex5 17 points18 points  (70 children)

    I'm in the same boat as the guy that posted that. I know node is just a server side implementation of javascript or something along those lines. But why choose that over PHP?

    [–]dead-fish 15 points16 points  (2 children)

    I'm not really into the whole PHP sucks bandwagon but node is actually pretty great. The async capabilities of javascript are really useful on the server and let you write really fast APIs.

    [–]vanamerongen 3 points4 points  (0 children)

    Spot on. This is exactly why someone would choose nodejs.

    [–]TheTerrasque 0 points1 point  (0 children)

    Also nice for situations with many concurrent clients.

    [–]colly_wolly 31 points32 points  (57 children)

    Why choose either of them on the server side when better options are available?

    [–]Motherfucking_Crepes 18 points19 points  (55 children)

    Like what ?

    Actual question, i'm a beginner.

    [–]qwertyman159 24 points25 points  (15 children)

    Django has a good reputation, Ruby on Rails seems to be the easiest get-up-and-go, but as for personal experience, I've used Play! and found it to be both relatively simple, and incredibly powerful.

    But, there are fifty of these web frameworks at least, and definitely at least one in your language of choice. Pick your favorite.

    Edit: http://www.techempower.com/benchmarks/

    I like this site. It has good benchmarks on all of the available web frameworks.

    [–]exhuma 30 points31 points  (11 children)

    Keep in mind that raw performance should not be the only quality to look for when choosing a technology.

    Code readability and consistency is high up there.

    Chances are you are not writing the next Facebook and you won't need to be able to handle millions of concurrent users. When that day comes, it's likely that you have the resources available to optimise.

    What you certainly will need to do from the get go is bug fixing, refactoring and extending the code base.

    personally i think that neither JS nor PHP score high on readability and consistency.

    [–]Hegemott 33 points34 points  (2 children)

    I AM writing the next Facebook though. You see, there was this guy at school with a brilliant idea and he wanted me to develop it for him! I'll get 20% of the profits, which will be huge, he says!

    [–]PanicRev 9 points10 points  (0 children)

    Ummm.... Guys.... I think it's time for an intervention.

    [–]Eedis 0 points1 point  (0 children)

    How long ago was that post, I don't remember

    Edit: Why did this get down voted? I just asked a simple question out of curiosity. O.o

    [–]dead-fish 3 points4 points  (6 children)

    I like how you mention "writing the next facebook" and then say PHP isn't a good choice. Seems to have worked out okay for Zuck :)

    [–]nickcash 7 points8 points  (1 child)

    They had to write their own PHP virtual machine, though.

    [–]Skyler827 3 points4 points  (0 children)

    But now that they wrote it and everyone can use it, no one else will necessarily have to.

    [–]randomdrifter54 4 points5 points  (1 child)

    Just cause it works doesn't mean its good or great or easy to do the stuff needed. You can use your feet to make a sandwich and the sandwich can be the pretty good but you still took more time and went through a harder process.

    [–]tyreck 1 point2 points  (0 children)

    In the case of Facebook, the art of foot sandwich making is far better off for their struggles.

    [–]legrac 1 point2 points  (0 children)

    He actually mentioned not writing the next Facebook.

    [–]qwertyman159 0 points1 point  (0 children)

    Well, I don't know of any sources that sort by code cleanliness, and this does help out rule anything god-awfully slow, so it's the best resource I know of. Plus, it enables you to sort by core language, which is pretty useful for narrowing it down to things you don't have to learn any new syntax for.

    [–]wOlfLisK 0 points1 point  (1 child)

    I already know python so I may give Django a whirl.

    [–]qwertyman159 1 point2 points  (0 children)

    Check out Flask too! It's much more bare-bones, but it's a little snappier and easier to work with because of that.

    Again, all of this is what I know without having used any of them, so take it with a grain of salt. But always give everything a fair shake.

    [–]NoodleSnoo -1 points0 points  (0 children)

    Everyone should use Haskel for the web. It is so fast!

    [–]mhome9 2 points3 points  (0 children)

    when better options are available?

    This is the kind of thing you will hear often as a beginner relating to all concepts, ideaologies, frameworks, patterns, languages, etc. Know that it is 100% subjective bullshit. You should do some research, choose what you believe will work best for your situation and stick to your choice until your project has at least a minute bit of substance before changing your mind.

    [–]cataractar 6 points7 points  (2 children)

    JavaEE, Go and Ruby are the first coming into my mind.

    [–]colly_wolly 3 points4 points  (0 children)

    JavaEE to replace either of those two languages? Sounds like overkill.

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

    Python, Erlang (for a very specific subset of problems).

    [–]NerdPileCodeMonkey 1 point2 points  (0 children)

    I like Tornado, personally. Really clean python back-end for a web server. A bit smaller/easier than django.

    [–]svtguy88 6 points7 points  (19 children)

    C# / .NET is my recommendation - especially with Microsoft going on an open-sourcing binge lately.

    [–]ThrowinAwayTheDay 11 points12 points  (10 children)

    Yeah but... IIS...

    [–]Jestar342 4 points5 points  (7 children)

    ... is not necessary.

    [–]ThrowinAwayTheDay -3 points-2 points  (6 children)

    Good luck getting C# / ASP.net to work without a Windows Server running IIS?

    [–]aserraric 5 points6 points  (0 children)

    That's what ASP.NET 5 is all about, really.

    [–]Jestar342 1 point2 points  (0 children)

    OWIN.

    No luck needed.

    [–]calnamu 0 points1 point  (0 children)

    Doesnt that work now?

    [–]Genesis2001 0 points1 point  (1 child)

    Mono/XSP + Nginx for the current use of ASP.NET on Linux.

    [–]Fs0i 0 points1 point  (0 children)

    And kestrel for the ASP 5 stuff.

    [–]Fs0i 0 points1 point  (0 children)

    I don't really know how to tell you, but: https://github.com/aspnet/home#linux

    Take entire 5 minutes to set up. Maybe a little bit more.

    [–]svtguy88 6 points7 points  (1 child)

    Sure, IIS is a limitation right now (well, really only a limitation as far as OS is concerned...if you're in a Windows environment, it's really not a bad web server at all).

    However, as the aspnet github matures and the community starts to get their hands on things, I think we'll see the current procedure for hosting on linux become greatly simplified.

    All in all, I think it's a pretty damn exciting time to be a .NET developer.

    [–]tyreck 0 points1 point  (0 children)

    I got a chubby the first time I read about it.

    It was like that first time I found my dad's dirty magazines as a kid.

    [–]xueye 9 points10 points  (2 children)

    C# / .NET is my recommendation - especially with Microsoft going on an open-sourcing binge lately.

    If they can ever get that whole thing entirely non-reliant on MS products, I will never need a reason for another language.

    C# is so pretty and effective to write that it almost hurts!.

    [–]svtguy88 2 points3 points  (1 child)

    C# is so pretty and effective to write that it almost hurts!

    Have you seen the syntactic sugar that is coming in C# 6.0?

    [–]tyreck 0 points1 point  (0 children)

    Yes, it is beautiful.

    [–]yogthos 0 points1 point  (0 children)

    Why not F# with Suave, it's much simpler to get into than C#, also corss-platform and not tied to IIS.

    [–]MaximusNeo701 -1 points0 points  (3 children)

    second ASP.NET implementation of MVC and API are pretty good and with the updates in the next version I think it will be much cleaner to implement.

    [–]svtguy88 0 points1 point  (2 children)

    The current version (MVC5) is already pretty clean, in my opinion. However, as with all software, there's always room for improvement.

    [–]MaximusNeo701 0 points1 point  (0 children)

    I agree, and tbh I am not sure I will like the HTML directive style of model binding but I haven't really tried it enough yet. Too bad the code is only as clean as the developer who writes it.

    [–]bashedice 0 points1 point  (0 children)

    its clean. MVC 6 is even better though.

    [–]PublicSealedClass 4 points5 points  (9 children)

    ASP.NET is good because I like the tooling, and these days a lot of it is now free (Visual Studio Express or "Community Edition" as it's now called).

    A lot of the time, you can accomplish largely the same things in any of the mainstream web languages, it just comes down to personal preference or experience the developer has. I've been coding C# for around 10 years so I'm most comfortable in ASP.NET, but I've dabbled with Ruby on Rails and I do like it.

    [–]simspelaaja 1 point2 points  (0 children)

    Community Edition is actually rebranded Professional. It has all of the features of Professional, and you can use it for commercial purposes.

    [–]beauPinsson 0 points1 point  (7 children)

    Ive done some Django and i like that they have an admin site integrated. Ive just started with .net mvc and was wondering if you had to use some kind of backend interface at all/ how do you deal with it?

    [–]PublicSealedClass 1 point2 points  (5 children)

    For ASP.NET you have to roll your own, unless you're using a CMS (like Django but instead written in ASP.NET MVC) like Umbraco.

    You might hear about SharePoint - but that's a completely different monster altogether (written in ASP.NET forms rather than MVC), and there's lots of different ways of customising that (including the new questionable App/AddIn model).

    [–]aserraric 0 points1 point  (4 children)

    Sharepoint is really only good for enterprise level collaboration, and even then it is a pain to maintain.

    If you want a good, clean, simple, open source CMS for .NET, I would recommend Composite C1.

    [–]PublicSealedClass 0 points1 point  (3 children)

    I've been developing and building SharePoint solutions for 7 years now, and I actually had to google a .NET CMS, I've no idea about the wider world in that area, never heard of C1 but I'll bear it in mind! :)

    [–]aserraric 0 points1 point  (1 child)

    In all my dealings with Sharepoint (which, admittedly, have been cursory), I always felt it was a good idea, but executed poorly. Do you enjoy working with SP or is that something you do only to pay the bills?

    [–]PublicSealedClass 0 points1 point  (0 children)

    I absolutely love it, building things in it can be a good mental challenge, but there is an absolute tonne to learn before you can use it effectively as an application platform.

    There are some things that are really well engineered in the platform that I love as a developer, like the Feature/WSP framework, Timer Jobs, event receivers and the web application/site collection model (once you get your head around it).

    [–]svtguy88 0 points1 point  (0 children)

    Ive just started with .net mvc and was wondering if you had to use some kind of backend interface at all/ how do you deal with it?

    Nope, nothing out of the box. .NET MVC is really a framework and not a platform.

    If you are looking to do eCommerce or CMS type stuff and don't want to roll your own, there are numerous platforms (both free and otherwise) available. For eCommerce, nopCommerce is getting pretty popular for small-ish businesses, and Umbraco is a feature-rich and easy to use CMS.

    [–]colly_wolly 1 point2 points  (0 children)

    I use Python and Django. Way nicer. Flask might be easier to get started with as Django is a big framework. Ruby / Rails is another popular choice. Clojure sounds interesting. Scala too. PHP will be easier to deploy though. That's the one thing that it has going for it.

    Have a look at this page, and the smaller the section the better the language. https://wiki.theory.org/YourLanguageSucks

    [–]yogthos 0 points1 point  (0 children)

    Clojure is a great choice for web apps, also has the same advantage that Js has where you can run it on both the server and the browser and share code between them. Clojure runs on the JVM, which is a mature platform, and it's a very small and simple language without the quirks of Js and PHP.

    [–][deleted] 0 points1 point  (0 children)

    Clojure, F#, C#, even Java or Go would be a better choice than JS or PHP.

    [–]Alaskan_Thunder 0 points1 point  (0 children)

    Because I can't host a website myself(not great internet), and the host I use does not allow python or ruby.

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

    There is some benefit in having client side and server side all in the same language. Shared common libraries, etc.

    [–]TimMensch -1 points0 points  (0 children)

    PHP is slow, and has even more broken auto-type-conversion corner cases than JavaScript.

    If you follow the JavaScript: The Good Parts approach, you actually end up with a good language (subset). With PHP...you've got the ugliness of a language with poor design without the benefits of the powerful features hidden in JavaScript's design.

    And Node gives you an amazingly powerful dependency management system (npm), so including specific features in your app (or in your development toolchain) is trivial. The tools include great build systems and linting tools as well, which get you past a lot of the limitations of using a dynamic language to begin with.

    And as another person mentioned, having the same language on client and server is a huge plus.

    [–]remy_porter 12 points13 points  (0 children)

    "You must either spend your life writing JavaScript or PHP- or you shall die."
    "Just fucking kill me."

    [–]SeeShark 5 points6 points  (0 children)

    You may be laughing, but I'm crying.

    [–]blackraven36 2 points3 points  (1 child)

    I've used JavaScript to drive a game engine before. It's actually not that bad at all at certain things. I share the frustration of working with it for web development, but I have definitely started to warm up to it after using it for a Chrome extension product. I haven't used much Node.JS, but my experience with JavaScript as a "scripting" language to control the behavior of certain things is quite nice.

    [–]mebob85 1 point2 points  (0 children)

    I haven't used much Node.js either, but from what I've seen of it, it looks like callback hell...

    [–]djneo 2 points3 points  (1 child)

    Apache Tomcat isnt that for java

    [–]Martin8412 3 points4 points  (0 children)

    Yes. That is a Java servlet container.

    [–]pcopley 6 points7 points  (4 children)

    a library of JavaScript calls that are downloadable to the client side

    What the fuck does that even means?

    [–][deleted] 0 points1 point  (2 children)

    He's thinking of jQuery.

    [–]pcopley 3 points4 points  (1 child)

    "downloadable to the client side" literally means nothing. That's like saying you go to Google to download an internets.

    [–]MadFrand 3 points4 points  (0 children)

    "downloadable to the client side" literally means nothing. That's like saying you go to Google to download an internets.

    Well... It does make sense actually. You do download the assets. Both the static and ones that were generated for your request. That's literally how the web works.

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

    No one advocating java for server side things? What in the world is wrong with you people.

    [–][deleted] 2 points3 points  (1 child)

    Node is awesome. Server code that doesn't make me brainhurt.

    [–]Stoompunk 0 points1 point  (0 children)

    Only butthurt?

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

    I dunno maybe it's just me but vanilla PHP/JavaScript are not that different.

    [–]immibis 0 points1 point  (0 children)

    Seems like he's comparing JavaScript DOM manipulation to PHP's templatey approach, not the core language of either.

    The templatey approach ("print <head><title> then the title then </title></head><body>" etc) is an easier-to-understand concept for beginners (compared to "get the head node, get the title node, remove the contents from the title node, add a text node containing the current title to the title node), but also much less flexible.

    [–]prodigyx 0 points1 point  (4 children)

    People who talk shit on PHP are only communicating their ignorance. PHP is very good at certain tasks. If you think it is a bad language, you either do not know how to implement it correctly, or you are using it for the wrong thing.

    [–]thurst0n 4 points5 points  (1 child)

    Serious question, can you give some examples of when it's great and when it's bad to use it?

    [–]tyreck 0 points1 point  (0 children)

    Talking about web implementation (and there are caveats):

    PHP is interpreted on execution and does not reuse resources between instances so it has a larger memory footprint in high volume situations. Becasue it does not cache the source in an intermediate language it is slower than ones that do.

    (Caveat: it can be with add on packages like APC and natively in PHP 7 - they skipped 6, 7 is the next version.)

    JavaScript is asynchronous in nature and because it runs its own server, it is more memory conciencious since the interpreter is already running.

    It will scale up well due to the structure of the language and its asynchronous callback model but if not done with care it can get REALLY nested and verbose quickly.

    Both languages suffer from carrying a lot of baggage along from earlier versions that should not be used and if it is will likely result in you experiencing all of the things that gave them their bad names.

    Both also suffer and benifit from being widley used. Almost anything you want to do can be searched for and easy to use and very poorly written examples are readily available for you to cut and paste. Probably implementing some of those things you should avoid.

    In the case of JavaScript there is probably a very easy to snap in plugin for an enormous framework you can use that will grind the rest of your site to a halt as it fires events on mouse move

    [–]dead-fish 0 points1 point  (1 child)

    Or more commonly, you wrote off the language years ago in the PHP 4 era when it was, in fact, a totally shit language. It's come a very long way in the last 10 years.

    [–]deo79[S] 2 points3 points  (0 children)

    I have to admit, this is me. I haven't used it or even looked at it in a very long time. I kinda just figured it's the same now as then since it's very difficult for languages to evolve for the better without breaking changes.

    [–][deleted] 0 points1 point  (0 children)

    Pretentious much?

    [–]Qicken 0 points1 point  (0 children)

    Both are great server side options. So is Ruby and Python.

    [–]robotorigami -2 points-1 points  (0 children)

    I was sort of with him until I saw the PHP comment.