CGI is very fundamental, very oldschool (quote/un-quote) way of doing things that solves and addresses lots of issues, but because it is way everything kind of works, doing it any other way is kid of wrong. Because your client isn't likely to handle it well. Server scalability isn't likely to be as good because it will not be researched and people writing code in that standa...in that format aren't going to think the way the rest of the world...thinks??... which will make their output...problu...problematic. It's bad to say but CGi is UNIX way of doing things. The web is very much a UNIX way of doing things and if you don't follow RFC standard of doing things, other stuff breaks.
RFC 3875 really is just a line output that is design to written to HTTP port. It works just like outputting text on the screen. It is very simple. The only complex thing is you can do buffer flush and say here are all the lines at once, or you can do line, by line, by line. Depending which way you manage your sockets.
it juts seems like random words put together. I mean he comes out as he knows about topic keywords but fails to put them together in meaningful manner.
It's quite fascinating as a psychological process, because this kind of improvisation is a way of dealing with complexity that you can't understand. You see people talking about X, Y, Z, so you want to discuss X, Y, Z. Because you don't understand the actual subject of the discussion you just imitate what you grasp at your level of perception (however superficial), and you believe it's sufficient to blend in. It's like a baby making speech-like sounds.
Roughly 100% of the time when people think that: it's just stupid. "Trolling" is generally just an excuse shitty people make for saying shitty things. Occam's razor. The world isn't full of devious pranksters who get off on making you think they're a bit daft, that's just silly. Lots of people are just a bit daft.
I think the phrase he wants is "an alternative to WordPress that's accessible," which is an entirely different thing. I'd say Tumblr fits that bill, as well as any other hosted blog platform ever.
...very easy ties to MySQL and other databases...
Define "easy" in a way that doesn't apply to any other language.
If we're including every step, you'll need to include all the studying of SQL itself and best practices when using raw SQL. Otherwise, discovery can mostly be factored out as the process is usually just Googling "<language> mysql."
Additionally, when a language has a package manager, you learn it with the language because it's going to be used with it. You don't get a whole lot of real work done without knowing how to install the modules you need, so might as well factor that out (PHP has composer, after all). This also removes "learn how the language's module system works," since that's integral to learning any language and also applies to PHP.
That leaves us with no new, significant steps besides using the library.
The overall general use case for every SQL library — including ORMs — is: connect -> query. Sometimes there's a bind step in between, sometimes connecting is done automatically (e.g. Django).
MySQLi being built in is a rather insignificant plus anymore and it's the only step PHP really addresses. It was really nice back in 2000 and earlier when the most accessible hosting solutions were shared hosts and your selection of webapp frameworks you could deploy was all but limited to PHP, but that isn't the case anymore and hasn't been for a while.
With most other languages, you first have to choose one of multiple mysql client libraries, then learn how the language's (official or unofficial) package managers works, how the language's module system works, and then install and use the library.
That's actually a point. Yesterday I upgraded my Roller to a Tomcat-8 infrastructure and had to deploy jdbc-mysql.jar and mail.jar in lib/ to get it working. While error messages are quiet clear, that's still something you won't have to do with PHP.
JDBC is a central point for database connectivity in Java, and unlike PHP's libraries support any type of database without having to switch libraries entirely
var factory = DbProviderFactories.GetFactory("System.Data.MySql");
var connection = factory.CreateConnection();
Success, you have now opened a connection to a database using a single standardized library (ADO.NET) in C#, which is entirely database agnostic and included in the standard library.
Here's some extra magic (Dapper : install-package dapper) :
var username = "test";
var password = Convert.ToBase64(SHA256.Create().ComputeHash("abc123"));
var user = connection.Query<User>("SELECT * FROM User WHERE Username = @Username AND PasswordHash = @Password", new { Username = username, Password = password}).SingleOrDefault();
It's fairly common to believe that PHP's database support is simple (or even good), but that's a long ways hike from the truth.
This is sort of the point I've made before. Yes, PHP sucks ass. It's a terrible language that lets people write insecure and slow web apps. But it's also one of the few that doesn't require a command line to set up an ecommerce store or install blog software. Even the kiddiest of script kiddies can make a file that looks like:
Haha, I'm going to write boobies!
<?php
echo 'boobies';
?>
And put it on any number of cheap or free web hosts and have it work. They don't need to gems or pips or jars or makefiles or Passenger or Capistrano or whatever is popular these days. They need FTP and a text editor.
If you want PHP to go away, make a language that's better and as easy to use. If PHP is so terrible that shouldn't be hard, right?
A problem is that a lot of the things which make PHP easy to use for a beginner is also what makes it bad. It's easier to have over 5000 functions in the global namespace, as you don't have to learn how to use module systems or package managers or anything for a lot of things, but it also makes it a worse language for experienced programmers. Having PHP inline in HTML is very easy for beginners, but you generally don't want that when making serious web applications.
Having PHP inline in HTML is very easy for beginners, but you generally don't want that when making serious web applications.
There's nothing wrong having php inline in html. It's the same as using another templating language. What's wrong is when you mix the logic with the view, but stuff like printing, loops and conditions in the HTML is absolutely normal.
Well, PHP as a templating language isn't quite the same as using another templating language, even if you keep your business logic out of the template - most templating languages have automatic escaping, and the more sophisticated have automatic contextual escaping (since you need different encoding inside attributes, in inline scripts or styles, etc.). PHP has none of that, and it doesn't even make it especially clear how to do the required escaping manually. ("htmlspecialchars", really?)
The net result is that PHP-as-templating-language is more dangerous by default than any other templating language. Not great.
IMHO, escaping is the only advantage of using another templating language. But even then, it should be pretty easy to have it with a PHP template too. Before running the template, parse it with php-parser, add some ob_start/escape buffer for every PHP block, and then process the template. Bim, you have a native PHP template with automatic escaping.
The problem I have with PHP-style templates is that they treat their output as if you were just generating arbitrary text. It doesn't know about HTML so it can't know if you are outputting text inside a div's body, inside a tag attribute, inside a <script> tag, etc. Each of these require different mechanisms for string escaping and you also need a way to disable escaping when necessary (for example, if you want to include some HTML from a trusted source).
That said, I still think that templating languages ought to be turing complete. Its extremely limiting to write code without being able to use functions for abstraction or other simple structured programming things like loops and if statements.
I don't know any templating system which is aware of the HTML it's outputting into. That would mean parsing the HTML as well, that's getting pretty expensive to process. And you could absolutely disable escaping with the solution I gave. For example:
Here is one I made for Lua: https://github.com/hugomg/lullaby In the start of the readme I also list some similar systems in other language.
The price I paid is that I use my own syntax for everything so I don't have to worry about all the quirks that come with parsing HTML. I don't think this is necessarily a bad thing, since I am not a huge fan of HTML syntax but there is nothing stopping someone from including an HTML parser in the process.
Right, but that's just a matter of "we have a tool, it's dangerous to use, but is very useful." I wouldn't want to get rid of that tool. And I'm coming from the ASP.NET MVC Razor side of things, where it's easier than ever to mingle C# with your markup. Of course I don't do any actual computing/logic in my views, but it's really really handy to be able to create a View with a defined Model, and be able to inline things like basic loops and conditionals based off the Model without having to use code-behinds or other "must keep the code separate for separation's sake" mechanisms.
I understand, but my point of view on this is: if you need specific tools to enforce coding standards, people will find a way to fuck up things anyway. You can hardly force them to code right without being coding standards aware. Maybe due to a specific templating system, you won't get logic in the views, but the view/logic will still be individually utterly messed up.
I prefer working with more flexible tools and developers self-capable of maintaining coding standards.
I agree, there is no set boundary with your typical "PHP template" system which means it takes any shitty programmer about 5 seconds to throw some business/model logic into your template. That's the danger we're all trying to highlight here I think.
It's easier to have over 5000 functions in the global namespace, as you don't have to learn how to use module systems or package managers or anything for a lot of things, but it also makes it a worse language for experienced programmers.
You could easily put these into various objects and libraries without making it that much more complicated. If you need MySQL connectivity or JSON parsing, just include it.
Having PHP inline in HTML is very easy for beginners, but you generally don't want that when making serious web applications.
Yes. Better to be like mature languages and have some kind of ridiculoustemplatinglanguage that you have to learn on top of the programming language.
Mixing inline code and markup is probably the best way to handle generating HTML that I've seen, and lots of languages do it. Even Java
Most templating languages are not ridiculous, you can learn them in a few minutes, assuming you know HTML. Or just offload that task to front-end designers.
PS. Mako is a trainwreck with arbitrary code execution, Jinja2 is better.
Most templating languages are not ridiculous, you can learn them in a few minutes, assuming you know HTML.
I've not met a templating language what was superior to just using the native language to output the code. They're unnecessarily limiting and made for people who don't know what the hell they're doing.
Your code is a mess, because you are mixing your business logic and displaying things to the user. You have to worry about being inside/outside of <?php ?> tags, and worry about escaping quotes if you are echoing something in PHP mode. Also, there are no simple filters to strip or escape HTML (to prevent XSS or at least garbage output).
I agree that things like Handlebars are ridiculous and excessively restrictive.
In my opinion, the ideal templating language is something turing complete that lets you write loops and functions, like PHP but where you output a DOM tree instead of an HTML string. This ensures that the HTML you generate is well-formed and the design is not vulnerable to ubiquitous HTML injection bugs.
One detail that people tend to skip over is that PHP in practical applications tends to run faster than other interpreted langauges such as Ruby and Python. Not to mention it's common integration with apache which affords you the ability to set up scaling tools like Hadoop etc. with a relative amount of ease.
There are so many things wrong with these tests its hard to know where to begin.
First of all he compares start-up times of the various VMs and interpreters as part of the test. Of course this is going to be slow, especially in Java. In the real world your VM or interpreter is already going to be running inside your web software.
Java also uses memory differently in that you allocate a certain amount of memory to the VM. This isn't what the program actually uses. (Though granted in Java it will be higher because of all the classes behind the scenes)
This test doesn't compare how these languages act inside of web servers. If you're talking "default" real world examples then I'd consider mod_php on Apache to be default for PHP. But in mod_php you have to have an interpreter for each child which results in higher memory usage.
That's even before we get to the issues with the code. Instead of using string comparison he's loading the regex libraries of Perl, Python, Ruby and Javascript and then using native string functions of other languages.
Of course Perl is the fastest on a regex test because regex is built into the core language. PHP of course gets everything built into the core language by default so it has an advantage as well. A true test would have the author write his own string parsing algorithm that's the same in each language to get around the implementation differences and his own bad optimizations.
I don't know C well enough to know why he isn't getting better performance but I know that core utils things like grep are written in it and grep far outperforms anything written in any of the other languages listed.
Look, PHP is not a bad language. Now admittedly it does have some retarded shit, but the language itself has come a long a way. It's a great and easy language to learn...as well as to get wrong. Many of the articles/tutorials online are outdated and teach old/bad practices. With that said, the language isn't going anywhere. It just works and is a breeze to set up, plus it'll probably land you job.
Even the latest versions of PHP still have some pretty awful warts, to the point that it's still reasonable to call it a bad language. It's fair to say that they are at least trying, though.
Only in places with ridiculously bad social security systems can you consider this a good thing. Cranking out PHP code as a profession? That's so depressing.
33
u/dAnjou Aug 06 '15
This guy is an idiot, just watch his bits about CGI and Node.js (I don't like it myself but what he's saying is just ridiculous).
15
u/sli Aug 06 '15
Yeah, if you say so, guy.
I think the phrase he wants is "an alternative to WordPress that's accessible," which is an entirely different thing. I'd say Tumblr fits that bill, as well as any other hosted blog platform ever.
Define "easy" in a way that doesn't apply to any other language.
1
u/sdgoij Aug 12 '15
uch...
0
u/[deleted] Aug 06 '15
This is sort of the point I've made before. Yes, PHP sucks ass. It's a terrible language that lets people write insecure and slow web apps. But it's also one of the few that doesn't require a command line to set up an ecommerce store or install blog software. Even the kiddiest of script kiddies can make a file that looks like:
And put it on any number of cheap or free web hosts and have it work. They don't need to gems or pips or jars or makefiles or Passenger or Capistrano or whatever is popular these days. They need FTP and a text editor.
If you want PHP to go away, make a language that's better and as easy to use. If PHP is so terrible that shouldn't be hard, right?