Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
eevee
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
22 ms
·
241.
▲
by
eevee
14y ago
It's only default behavior. The alternative is for any request that runs more than one query to be inherently but unpredictably unreliable; that is definitely not acceptable. If you're doing something complicated, you're going to have to t
242.
▲
by
eevee
14y ago
CGI is easy, yeah, but it has a lot of the same disadvantages as mod_php: no routing, no shared state, slow execution, server misconfiguration can expose your code, possible code execution if you accept uploads, etc. There are approaches th
243.
▲
by
eevee
14y ago
Python has a `cgi` module that does most of the superglobal stuff for you. But, er. Does this really matter? Yes, you can get "hello world" in PHP with one line of not-PHP. You can also get "hello world" in Python + Flask with seven line
244.
▲
by
eevee
14y ago
I guess that's true, but you know... so what ? Can't we worry more about building something cool than about shaving seconds off the one-time setup cost involved with sharing that cool thing with the world?
245.
▲
by
eevee
14y ago
I've only read about Ruby strings, not used them, but they seem like a middle ground between Perl's approach and Python's approach. What do you perceive as the problem with Python?
246.
▲
by
eevee
14y ago
Right. Learning Python 3, once you know 2, is really easy. Library maintainers have two problems: they have to twiddle their thumbs until all their dependencies have ported, and then they have to get their code running against both 2 and
247.
▲
by
eevee
14y ago
Python 2 versus 3 isn't anything like PHP 4 versus 5. The problem is that there are a few minor but backwards-incompatible changes to the syntax in py3. Libraries can't update until all their dependencies update. And web frameworks are
248.
▲
by
eevee
14y ago
It's a chicken-and-egg problem. Best I can do is encourage more people to write more Python software, so those crappy free hosts are more inclined to support running it. Until then, I don't think it's terribly unreasonable to pay twenty bu
249.
▲
by
eevee
14y ago
This is part of an FAQ series. The bolded part ("I only know PHP...") is the question I'm answering. I'll leave you to contemplate the irony here.
250.
▲
by
eevee
14y ago
Fair point. Correction: working with encodings sucks. Py3 isn't magnitudes better with Unicode; it's better about converting incoming bytes, and it makes literals into real strings. But the former isn't necessarily a good thing, and you
251.
▲
by
eevee
14y ago
Most of the post _isn't_ strictly necessary. You don't need a database to get your feet wet. You don't need to care about XSS for your first throwaway app (though, arguably, you should). I pimp Mako precisely because there's no separate
252.
▲
by
eevee
14y ago
That's why e.g. Flask exists: it gives you the basics, plus light structure and templating and routing and XSS protection and deployment options and whatever else. With no setup and no boilerplate. It's about as much effort as typing `<
253.
▲
by
eevee
14y ago
Exposing source code is the least of your problems. With creative use of command-line arguments, you can run arbitrary PHP code via any vulnerable URL. It took me a bit to figure out _how_, but it's nothing obscure or difficult. In fact i
254.
▲
by
eevee
14y ago
Yes, I am definitely experiencing your shameless self-promotion.
255.
▲
by
eevee
14y ago
Have you tried tmux's window monitoring settings? tmux can beep you when a window becomes active, goes silent, or prints a particular string—which will presumably make your terminal emulator yell at you somehow, too.
256.
▲
by
eevee
15y ago
JSON objects are explicitly unordered, but you would be amazed by how many gripes I've seen about JSON libraries or systems that don't preserve the order.
257.
▲
by
eevee
15y ago
JSON will let you do that just as well. Or, if you must, there's ast.literal_eval which will only allow Python literals.
258.
▲
by
eevee
15y ago
We don't WANT to replicate PHP's deployment model! It's hard to scale, it's hard to configure, it's hard to secure, it's hard to make work across different web servers. It's convenient for newcomers, sure, but even for something like phpb
259.
▲
by
eevee
15y ago
I actually had to learn more PHP than I'd have liked to write this post. It was never my language; I started in the Perl days before PHP was a thing, stuck with it, then jumped ship to Python. I've interacted with it in the form of horror
260.
▲
by
eevee
15y ago
Only a couple of these things are outright wrong; I removed the offending bullet points earlier tonight. A few things I listed because they're weird, not outright wrong, and I stand by those. For the most part you've defended PHP's behavio
261.
▲
by
eevee
15y ago
I've done this several times with Perl. It wasn't difficult. The template was a blob of TT in a __DATA__ block at the end of the script. Deploying as PSGI would take, like, three lines of nginx configuration and wrapping the bulk of the s
262.
▲
by
eevee
15y ago
I used to concede that PHP is appropriate for little scripts, but I changed my mind over time, because so few of those scripts stay "little". Where is the line drawn? Do we find we need a new feature one day, decide that's enough to tip t
263.
▲
by
eevee
15y ago
I was kidding (and lost the final asterisk); I would lose a lot of faith in Python if that ever worked. :) Maybe new devs should learn Perl, instead... http://search.cpan.org/~adamk/Acme-Everything-1.01/lib/Acme/...
264.
▲
by
eevee
15y ago
There's surely some middle ground, here. PHP defines constants with a function, creates functions with a function, creates data structures with a thing that isn't actually a function but is inexplicably designed to sorta resemble a functio
265.
▲
by
eevee
15y ago
Well, that's coming from the perspective of someone who doesn't like "private" in the first place; it forces me to rely on whatever use cases the author has imagined and makes extending the class in a novel manner a pain. Except this is PH
266.
▲
by
eevee
15y ago
Several people have brought this up. I thought about it for about ten seconds the first time and told them that English is definitely worse. Luckily, programming languages are a bit easier to learn and replace than spoken languages.
267.
▲
by
eevee
15y ago
from * import
268.
▲
by
eevee
15y ago
Please enlighten me! I'm interested in correctness. The "non-programmers" remark refers to a quote from the PHP 2.0 documentation. I tried to minimize the editorializing.
269.
▲
by
eevee
15y ago
Whoa. Definitely don't run Python as CGI. Use WSGI, run your app as a devoted low-priv user, proxy to it. Then you have only one entry point; there IS no sandbox, and nothing to exploit.
270.
▲
by
eevee
15y ago
Nope. This works as you'd expect in Perl: the replacement is treated as code and executed like an inline function, never eval'd.
More ›