Here are six files for ya, showing a problem in 3 different scripting languages. What will they do?
--------- test1.php:
<?php
require 'test2.php';
define('SOMECONSTANT','hello world');
function foo() {
return SOMECONSTANT;
}
echo foo(); echo "\n";
--------- test2.php:
<?php
require_once 'test1.php';
echo foo(); echo "\n";
--------- test1.py:
#!/usr/bin/python
import test2
SOMECONSTANT='hello world'
def foo():
return SOMECONSTANT
print foo()
--------- test2.py:
#!/usr/bin/python
import test1
print test1.foo()
--------- test1.rb:
#!/usr/bin/ruby
require 'test2.rb'
SOMECONSTANT='hello world'
def foo
SOMECONSTANT
end
puts foo()
--------- test2.rb:
#!/usr/bin/ruby
require 'test1.rb'
puts foo()
---------
Ok, scriptfiends, predict the output of these three commands:
php -q -f test1.php
python test1.py
ruby test1.rb
and then do some pasting and try it out. Match your predictions?
The PHP one bit me pretty hard today.
I have a password written on a post-it note underneath my keyboard. Decades went by without this ever having happened, but now I have one of these. [rationalize]And I'm keeping the post-it, because it'll probably be months or years before I ever need that password again, so there's just no chance I'll be able to remember it (it's actually a pretty well-made password).[/rationalize] OTOH, I suppose I could just throw it away and then the next time I need it, ask someone for it again. [truth]But no, it amuses me that I've entered the ranks of people with passwords on post-its at their desks, so I'm keeping it, for that reason if nothing else.[/truth]
If you've known
Then there's the annoying inline popup (so it's not caught by popup blockers) that tells you that "Firehose is paused due to inactivity". Whatever that means, it doesn't seem nearly important enough to interrupt my reading.
Quite frankly, from a user interface design standpoint, the "new" slashdot sucks. Badly. Maybe I'll try disabling all javascript for slashdot.org and check if that improves the experience.
I've long advocated that the future of video delivery should either be multicast, or old-school protocols like HTTP combined with caching at the ISP. (Why all ISPs don't run transparent Squids, I still don't understand.) Bittorrent just isn't the right way to do it.
Thanks to Freedom To Tinker I've just learned that someone is using multicast to deliver TV.
Except it's not available in my area, and still requires propriety DVRs/STBs, which I assume means that it probably uses DRM and therefore has massive interoperability problems.
But it's a start. I hadn't heard of anyone actually doing it, before now.
I was writing a function in PHP4 and it kept getting bigger. It could use some splitting up for readability/testing/debugging purposes, although it didn't really need that to work. But then I realized I needed to reuse some sections of code, and since I hate duplicating code, those parts needed to be pulled out into their own functions.
But they needed access to the working set of local variables of the big function. Oh great.. do I pass all those vars by reference, making the argument list really long? Do I move all those variables into a struct (well, an associative array) and pass that?
These are, like, Programming 101 issues. Experienced programmers don't normally have to think about this stuff, because the right thing to do is just
Then I remembered that Pascal has the unusual (and rarely(*) needed) feature of nested procedures, where the sub-procedures can directly access the outer scope's local variables. It dawned on me: that would be incredibly convenient (and readable) in this case.
I wussed out and put everything into a class. It's not really oop (all this class does, is return a result) but that looked like the best way to deal, except now I have an ugly this-> in front of everything.
(*) I haven't programmed in Pascal (or anything like it) in over 20 years. Never really missed that feature until today.
Any suggestions for an artist or genre I could try out, or a better way to browse? The site also has a lot of scripting that my Firefox doesn't like.
It's bad enough when you're actually serving the data from your own site but it's in some form where you can't audit it. That's one of the many reasons I hate Flash.
But even Javascript sucks, when you <script src="someothersite">. The moment you do that, you know that all sorts of horrible things can go wrong. You just have to have faith. Faith is what it comes down to. And it can be justified, I guess, because you can get away with it for years.
Until this morning when our webpage was only showing for a second and then the whole thing would then redirect to someone else's site. Adios, visitors.
(What actually happened: the domain we were including from, apparently expired and now any http request goes to a Network Solutions page, instead of returning a DNS error like it should. Fuck you, Network Solutions, as if we didn't already know you're evil and dangerous. But the same risk remains even if someone's domain doesn't expire; they can always serve a different script today than they did yesterday, and that script can do anything with the DOM that it wants to. There's no way to sandbox it.)
It's "standard practices" to include external scripts. Everyone does it. The ad people aren't techies; if I were to tell them, "uh, we don't want to include any external scripts that might change from load-to-load, and we also don't want to include any Flash crap unless we've compiled it from readable, auditable source ourselves," they would think I'm crazy. You know, one of those open source fanatics. They would say, "Gee, that's a shame you don't want the money," and go on sending the same dangerous ads to our competitors while we collect nothing.
Is it really an unreasonable weirdo religious fanatic position, to just want to be able to make sure that stuff will work and not do anything crazy? I don't think so. The fucking "standard practices" need to change, but how can one person do that? *sigh* I feel so powerless.
I'm not qualified to have an informed opinion on the bailout bill, and I certainly understand the skepticism and hostility towards it. But I get the feeling that this was a huge missed opportunity to avoid disaster...
Anyway, Shanah Tovah to all Jewish readers!
To the systems programmer, users and applications serve only to provide a test load.