What does *real* routing looks/works like?



  • Recently, while waiting to get access rights i need to do my job (oh, this company, such a collection of WTFery, but that's for later, maybe), I have been re-reading this PHP rant. What caught my eye this time was the part saying that apache's mod_rewrite is not a proper routing mechanism, so I thought I could ask how exactly does any example of a proper routing mechanism works.


    If anyone is as bored as me, you're welcome to explain ;)



  • If your URLs can't be represented as a regular expression, you have bigger problems



  • I think he's meaning something more like what MVC frameworks allow you to set up, although many PHP frameworks do let you set up "real" routing, and it's not like mod_rewrite is really a part of PHP at all.

    That entire essay is basically moronic. Don't get me wrong, PHP has some fucked up features, but the author rarely seems to know what he's talking about. It seems like it was custom-designed to be clickbait for dumb-dumb sites like Hacker News!.



  • I think the main thing to take away is that there are better languages to run server side that are available than PHP. The rant is good for pissing off some of the new developers when they go about how good Drupal or some other shit is.

    Better is subjective anyway. PHP is an adequate tool that had it original featureset designed around what people wanted to do back in late 90s with regards to server-side scripting, the reason that it is a mess these days is because they had to keep backwards compatibility while adding new features that people wanted. Even .NET has lots of existing legacy bollox from version 1.0 that is still prominent in the framework.

    If you are going to do web development you might as well learn it because sooner or later you will probably using it in some capacity.



  • @lucas said:

    I think the main thing to take away is that there are better languages to run server side that are available than PHP.

    On Unix? Maybe Java, but that's like a race between a hobbled hare and a thick turtle.



  • I wasn't talking specifically about *nix stuff. But there are options on *nix like mono, python, and node.js.

    I've been working with Node.js recently and while it is a bit bare-bones by itself, there are plenty of libraries available that fill in the gaps. I haven't done much with Python but it looks like a pretty decent scripting language but I heard it can be slow.

    I work primarily as ASP.NET/C#/VB.NET developer so I tend to stick with the ASP.NET MVC + SQL SERVER based solutions when doing my own projects.

    I don't like PHP, but it is out there with pretty much most cheap hosting options



  • @lucas said:

    mono

    I honestly wouldn't use some reverse-engineered version of .NET for anything serious. Just develop on Windows instead.

    @lucas said:

    python

    I never really saw the appeal. It's an okay language, but hardly a big improvement compared to PHP.

    @lucas said:

    node.js

    Node is fun for testing JS on the command line. I wouldn't use it for anything serious. It's all single-threaded for one, although I read some extensions were trying to shoehorn threads into it, which seems like a very, very bad idea. It's far less mature than PHP or Java, so fewer tools, less stability and fewer libraries. And I say this being someone who really likes Javascript, but I realize that Node is hardly a great idea.



  • @morbiuswilters said:

    @lucas said:
    I think the main thing to take away is that there are better languages to run server side that are available than PHP.

    On Unix? Maybe Java, but that's like a race between a hobbled hare and a thick turtle.

    On Linux? Maybe Go, but I'm mainly saying that because I want to inject Go into this thread.



  • @Ben L. said:

    @morbiuswilters said:
    @lucas said:
    I think the main thing to take away is that there are better languages to run server side that are available than PHP.

    On Unix? Maybe Java, but that's like a race between a hobbled hare and a thick turtle.

    On Linux? Maybe Go, but I'm mainly saying that because I want to inject Go into this thread.

    Ben, you owe me a new pair of pants.



  • @morbiuswilters said:

    I honestly wouldn't use some reverse-engineered version of .NET for anything serious. Just develop on Windows instead.

    It is pretty mature, supported and Xamarin have been profitable since the beginning. I believe Stack Overflow runs on mono.

    @lucas said:

    I never really saw the appeal. It's an okay language, but hardly a big improvement compared to PHP.

    The syntax on its own is miles better, also most of the framework encourage TDD development and creating everything modular.

    @lucas said:

    Node is fun for testing JS on the command line. I wouldn't use it for anything serious. It's all single-threaded for one, although I read some extensions were trying to shoehorn threads into it, which seems like a very, very bad idea. It's far less mature than PHP or Java, so fewer tools, less stability and fewer libraries. And I say this being someone who really likes Javascript, but I realize that Node is hardly a great idea.
     

    I dunno how you say it is less stable all the core framework has features that are clearly marked stable in the API and it been going for a good few years now.

    Node is being used for quite a few serious websites. Trello for one is built using node and it is fucking awesome and so is the new MySpace. People are using it now for high performance web apps.



  • @lucas said:

    I believe Stack Overflow runs on mono.

    Does not inspire confidence. Besides, one of the benefits of .NET is being able to run something other than Unix.

    @lucas said:

    The syntax on its own is miles better...

    I'm less in love with it. I prefer PHP's C-style syntax.

    @lucas said:

    I dunno how you say it is less stable all the core framework has features that are clearly marked stable in the API and it been going for a good few years now.

    Everything has bugs. They can call it stable all they want, until it's being used by a million medium-to-large sites, I wouldn't trust it.

    @lucas said:

    Trello for one is built using node and it is fucking awesome and so is the new MySpace.

    I don't know what Trello is and I haven't looked at MySpace since 2005 or so.

    @lucas said:

    People are using it now for high performance web apps.

    We'll see. MySpace hasn't proven itself very wise in the past, so I have no reason to think they aren't just digging their own graves with Node.

    Really, it's all kind of pointless seeming. There are more mature languages out there, with actual decent tools like debuggers and IDEs. And threads. If your plan is "Let's use a server-side language without threads!" I have to wonder where the hell things went off the rails. Especially with modern servers having about a bazillion cores.



  • @morbiuswilters said:

    Does not inspire confidence. Besides, one of the benefits of .NET is being able to run something other than Unix.

    What, Stack overflow is pretty solid application considering the traffic it gets. The whole point about .NET code is similar to Java you can run it in the same runtime and it should work.

    Mono is now 10 years old now and runs on many platforms and is well tested, I think Mono is cool because I can write C# /.NET (yes I have to keep to a subset of the .NET libraries) and it can run on anything from Windows 8, an iPhone, to a bloody watch these days.

    @morbiuswilters said:

    I'm less in love with it. I prefer PHP's C-style syntax.

    Matter of personal opinion then. I prefer the cleaner python syntax but as I learn more about it I might change my mind. I loved the Jasmine templating engine at first until I worked with it in some circumstances.

    @morbiuswilters said:

    Everything has bugs. They can call it stable all they want, until it's being used by a million medium-to-large sites, I wouldn't trust it.

    Well I am sure you could use that argument against Java with all the security problems at the moment, but we all know that is considered "Enterprisey" and stable.

    Node is being used by large sites, while it might not be perfect it is working well. It is mature enough IMHO, though that is down to how conservative you are, I would consider the .NET 2.0 release as the coming of age version of .NET even though it did have some glaring bugs in some circumstance, but it was a pretty solid release that fixed everything with the 1.0 and 1.1 release. Node IMHO is at the .NET 2.0 release now, it isn't perfect but it is more than good enough.

    @morbiuswilters said:

    I don't know what Trello is and I haven't looked at MySpace since 2005 or so.

    Well the new MySpace redesign is pretty good and focusing on music and Trello is pretty sweet and I suggest you check it out. They are proof IMO that node is ready.

    @morbiuswilters said:

    We'll see. MySpace hasn't proven itself very wise in the past, so I have no reason to think they aren't just digging their own graves with Node.

    Well I think the "new" MySpace is pretty solid web app and it knows it core audience (post facebook) was music and went in that direction. I don't think you like it but it appears to be very well built and is using node and is serving a few million people at least.

    @morbiuswilters said:

    Really, it's all kind of pointless seeming. There are more mature languages out there, with actual decent tools like debuggers and IDEs. And threads. If your plan is "Let's use a server-side language without threads!" I have to wonder where the hell things went off the rails. Especially with modern servers having about a bazillion cores.
     

    But you can run out of threads quite easily, these things are event based and nginx have already proved that it is better memory wise. I been writing handlers that dealt with threading with IIS for years and TBH node works fine. There are plenty of case studies where node is providing the same number of users with lesser harware behind it.

    Look I don't know enough about large scale stuff but I know enough to avoid the major pitfalls. There are obviously going to be cases where node.js works and where it doesn't ... like a lot of things. Dismissing it outright because of this and that you may have heard isn't "engineering" IMHO.

    It comes down to the best tool for the job, like I said before ... I think PHP is perfectly fine for a lot of things, but maybe the wrong choice for some projects.



  • @lucas said:

    Mono is now 10 years old now and runs on many platforms and is well tested

    Every time I ever tried to use Mono, it has failed miserably. But I was running GUI apps.

    @lucas said:

    Well I am sure you could use that argument against Java with all the security problems at the moment, but we all know that is considered "Enterprisey" and stable.

    Well, for server-side Java's okay enough. If anything, the problems with Java highlight just how much of an uphill battle Node has going for it.

    @lucas said:

    Node is being used by large sites, while it might not be perfect it is working well.

    Big sites do lots of stupid stuff. I don't see that as a reason to emulate them. What's more, I can't help but think Node won't be around in 5 years. I mean, it will be around, but the fad will have passed.

    @lucas said:

    They are proof IMO that node is ready.

    Being able to toss together a site isn't that hard. Let's see them scale and support this for years on-end.

    @lucas said:

    But you can run out of threads quite easily

    Not if you configure things properly and actually plan for growth.

    @lucas said:

    these things are event based and nginx have already proved that it is better memory wise.

    Those are two totally different use-cases. nginx is just serving up static files (and it still has a thread pool). Node is supposed to be for writing applications, but it doesn't even let you use more than one core. That's bad.

    @lucas said:

    There are plenty of case studies where node is providing the same number of users with lesser harware behind it.

    They were probably mis-configuring things or primarily serving static files or something equally dumb. Only being able to utilize a single core on a modern, server-side language is a big, big downside. (Yes, you can run multiple Node daemons in parallel and try to get it to use more cores and just load balance across those, but that's pretty hacky.)



  •  I am not going to quote all that but a lot of that is "what if" scenarios and "it might be badly written" and "it didn't work out for me when I did this"

     Mono is pretty mature and does work, it isn't as easy as .NET but it does work ... no question about that. 

     As for node:

     I looked at a few sites and I know the coding style that it encourages and "tossing it together" doesn't work with the work flow when developing web-apps. TDD is very much present throughout the community. Anything that has any traction as a library has a good case of unit tests.

    Also considering jQuery is using Grunt which is relies on node, I think it is must be pretty decent; The jQuery team are pretty solid as JS developers

     Node is working quite well with quite a few sites that have a few million users and I think it will be around in a few years because at the moment especially in the UK there is demand for it and working with it is actually quite refreshing for a lot of developers.

     I think we will have to agree to dis-agree. I understand where you are coming from for the most part and I was quite skeptical until I was asked to get upto speed with it.

     I am sold on it. I would like to benchmark it vs say ASP.NET / C# on similar tasks to find out for sure though.


Log in to reply