Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 657 658 [659] 660 661 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 890653 times)

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9870 on: August 08, 2016, 07:26:51 pm »

Although there are reasons for PHP's market dominance, and a lot of those reasons are the same things language purists don't like about it:
http://www.startuplessonslearned.com/2009/01/why-php-won.html

Even the simplest possible web app with Python looks like you need a lot more boilerplate than building something with php. Correct me if I'm wrong.
« Last Edit: August 08, 2016, 07:33:12 pm by Reelya »
Logged

MagmaMcFry

  • Bay Watcher
  • [EXISTS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9871 on: August 08, 2016, 07:35:12 pm »

PHP? Javascript? Get yourself a real high-level scripting language, like Perl.
pythonmasterrace
Don't you even dare think that Python is even close to the level of raw scripting convenience Perl has. >:(

<suddenly web apps>
Changey subject you shall not.
Logged

Antsan

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9872 on: August 08, 2016, 07:37:54 pm »

Although there are reasons for PHP's market dominance, and a lot of those reasons are the same things language purists don't like about it:
http://www.startuplessonslearned.com/2009/01/why-php-won.html

Even the simplest possible web app with Python looks like you need a lot more boilerplate than building something with php. Correct me if I'm wrong.
Quote
For them, PHP is an ideal language precisely because it gets out of their way
Every time I talked to anyone who uses PHP they told me the exact opposite: That they had to work miles around the language only to get the second-simplest of stuff done.
Logged
Taste my Paci-Fist

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9873 on: August 08, 2016, 07:48:30 pm »

<suddenly web apps>
Changey subject you shall not.

That doesn't make any sense. PHP/JavaScript only make sense in the context of building web apps. If you're advocating a replacement for those, that replacement's suitability for building web apps is the core discussion.

People used to use Perl for this stuff. But they stopped doing that en masse. There were reasons for that.
« Last Edit: August 08, 2016, 07:58:40 pm by Reelya »
Logged

Orange Wizard

  • Bay Watcher
  • mou ii yo
    • View Profile
    • S M U G
Re: if self.isCoder(): post() #Programming Thread
« Reply #9874 on: August 08, 2016, 08:33:21 pm »

Every time I talked to anyone who uses PHP they told me the exact opposite: That they had to work miles around the language only to get the second-simplest of stuff done.
I dunno, from what I've seen PHP is pretty convenient for web stuff. The main issue is web stuff, which makes everything 40% more complicated just by being web

Don't you even dare think that Python is even close to the level of raw scripting convenience Perl has. >:(
My only contribution to this thread is shilling Python, don't take that away from me
Logged
Please don't shitpost, it lowers the quality of discourse
Hard science is like a sword, and soft science is like fear. You can use both to equally powerful results, but even if your opponent disbelieve your stabs, they will still die.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9875 on: August 08, 2016, 08:58:20 pm »

Even the simplest possible web app with Python looks like you need a lot more boilerplate than building something with php. Correct me if I'm wrong.

Even simpler.

And now for some PHP - search for example #3.

Where is your god now?
Logged

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9876 on: August 08, 2016, 09:08:09 pm »

PHP is ugly and inconsistent, but it's pretty powerful.  Despite liking JavaScript a lot more in general now, I'm still more productive in PHP for a lot of things, including shell scripts.  JavaScript's weakness there is that it's frequently used in an asynchronous manner, especially with NodeJS and its libraries.  That makes it harder to write neat and simple to understand code for scripts that just need to do things in order, but on the other hand it's much better for scripts where long running things should happen in parallel.  PHP really sucks for that.

One big difference between PHP and JavaScript is libraries.  PHP has a ton of functionality built in and doesn't need libraries, whereas JavaScript and NodeJS in particular need you to install libraries for a lot of things.  The flexibility is nice, but the libraries can be a real mixed bag in quality.

Also, the newer versions of PHP are still pretty ugly, and getting uglier in ways that only modern C++ can compete with, but they have addressed some limitations of the language.  I think you can even pass functions around as first class arguments now like you can in JavaScript, which is probably my favorite feature of JavaScript.

I would use any of those languages (well, maybe not php), but I'm not quite sure I could write a Makefile with those.

I have honestly considered doing it at least once... although I'm not sure it would have made the build process any simpler.  Maybe easier to understand, but not simpler.  The idea would be that you'd have the script invoke the compiler for each source file to build the object files, then invoke the linker afterward.  Same thing that makefiles do, but admittedly it's something they handle relatively seamlessly and invisibly.  It would really only be helpful if you had some pretty complicated conditionals on which files got built and when.

Edit: I wonder now if there's an NPM module for using NodeJS as a build system...
« Last Edit: August 08, 2016, 09:10:46 pm by Telgin »
Logged
Through pain, I find wisdom.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9877 on: August 08, 2016, 09:10:04 pm »

Speaking of web, how does one get started learning to program web applications? I don't want to rent server space for experiments and learning, so what do I need to download to reasonably simulate a website operating on a server (besides an IDE)?
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9878 on: August 08, 2016, 09:18:20 pm »

The tried and true way to do it, which is how I started, was to install the Apache web server (which can be done on any of Windows, Linux or Mac OS), the PHP module for it, and MySQL to use as a database.  You can run it locally on your computer and just use http://localhost to access webpages served up by your server.

Following up on that, the bad old way, which again is how I started, was following very bad PHP + Apache + MySQL tutorials that tried to teach you how to do all of the above with absolutely no security or good practices in mind.  It's a simple way to get started, but beware what you might find.  In particular, if you do decide to learn PHP + MySQL, try to find a tutorial that teaches you how to integrate the two using PDO and not the built in mysql_* functions, which are deprecated and insecure.

A much more modern approach, which is probably simpler, is to install NodeJS and write your pages in server side JavaScript.  You can again do that on any platform, and it requires less configuration than Apache, but you have to learn to install and use extra libraries to even do something as simple as serve a webpage.  You'd need to install Express at a minimum to do that without tearing your hair out, and the tutorials you find might make the whole process more complicated than it needs to be.  Make that even worse if you want to use MongoDB, which is the de facto database people use with NodeJS these days.  MongoDB is a lot harder to use than MySQL in my experience, at least from a database management point of view.

Or, if you're interested in just doing simple things that don't require any kind of server side logic, you can even just write the webpages using Notepad and just point to them in your browser.  C:\Users\[your user name\Documents\index.html for example.  You can do a lot this way and don't even need to install a server, but you can't do database integration, sessions or things like that.
Logged
Through pain, I find wisdom.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9879 on: August 08, 2016, 09:47:56 pm »

What about any of the Apache branches? It's probably simple enough to compile vanilla Apache for myself, but I'm feeling lazy and many of the branches just have plain installers.

Is it worth even learning PHP, or should I just start with Perl or Python? I've already used Python before but Django looks scary.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9880 on: August 08, 2016, 10:46:23 pm »

... NodeJS ... MongoDB ...

AKA PHP v2. You can make good software but it's also easy to not do so. It also encourages dependency hell of the worst degree.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #9881 on: August 08, 2016, 11:08:12 pm »

On Linux, nginx is a lot less headache, lighter than, and much simpler than apache. Windows nginx has some weird issues with usability so it's not as good. You also use Python or whatever to make a simple webserver, too. Stuff like flask, django  and cherrypy work.
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9882 on: August 09, 2016, 12:33:36 am »

... NodeJS ... MongoDB ...

AKA PHP v2. You can make good software but it's also easy to not do so. It also encourages dependency hell of the worst degree.

Absolutely...

Anything trendy is a magnet for making bad software, I guess.  NodeJS and MongoDB are the trendy things to build webapps with now, so people will slap things together with them using bad tutorials left and right.

Dependency management is easily my least favorite part of NodeJS development.  Nothing we've tried at work completely eases the pain.  Shrinkwrapping the dependencies kind of helps.  Running our own NPM cache to ensure that the versions remain available works but then the dang private NPM registry screws up if more than a few processes are building from it at once...
Logged
Through pain, I find wisdom.

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9883 on: August 09, 2016, 01:45:37 am »

Even the simplest possible web app with Python looks like you need a lot more boilerplate than building something with php. Correct me if I'm wrong.

Even simpler.

And now for some PHP - search for example #3.

Where is your god now?

What does that even mean? PHP Example #1 and #2 are about creating a standard HTTP server, which is what the Python example does as well. PHP Example #2 starts an HTTP server in your chosen root directory, which is what the Python code says it does, and the entire PHP code is this:

Quote
$ cd ~/public_html
$ php -S localhost:8000 -t foo/

That was two lines of code, and it doesn't even require any PHP. It does the same thing as the Python program in your other example.

PHP Example #3 is showing how to customize HTTP requests in a completely universal programming fashion. The basic structure is an if/else statement. That's it. The only remotely complex thing is that it's using a regex to do the file type checking. That's nothing to do with PHP per se. If you have trouble reading that, brush up on your Regexes - they work the same in every language.

Quote from: PHP Example3
<?php
// router.php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) {
    return false;    // serve the requested resource as-is.
} else {
    echo "<p>Welcome to PHP</p>";
}
?>

But there's NOTHING in your Python example which shows how to filter page requests in this sort of custom manner. Show me the working code for that and I'll bet it's very similar in complexity.

You're comparing apples and oranges.
« Last Edit: August 09, 2016, 02:03:41 am by Reelya »
Logged

LoSboccacc

  • Bay Watcher
  • Σὺν Ἀθηνᾷ καὶ χεῖρα κίνει
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9884 on: August 09, 2016, 01:58:59 am »

What about any of the Apache branches? It's probably simple enough to compile vanilla Apache for myself, but I'm feeling lazy and many of the branches just have plain installers.

Is it worth even learning PHP, or should I just start with Perl or Python? I've already used Python before but Django looks scary.

apache + php + mysql have portable version for many environments. install anywhere, and forgot about backend, because in 2016 backend language matters not: 80% of stuff is making the user experience pretty and comfty, which requires tons of javascript, html and banging the head on the screen while searching on caniuse.com. get yourself a decent ORM (Exists in many languages), and forgot about the database. the backend now only need to check authentication, authorization, and expose in json data from the ORM. note that you shouldn't write authentication either, just google simple oauth + language of your liking and let facebook, twitter, google or whatever do the auth stuff for you

beside everyone is missing the main strength of php: hosting costs 12$/year. find a hosting with same feature and allowing for running a python/java server, I dare you.

Logged
Pages: 1 ... 657 658 [659] 660 661 ... 796