Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
User Journal

Journal Journal: Circular dependencies in three languages 1

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.

User Journal

Journal Journal: One Too Many 2

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]

User Journal

Journal Journal: The "new" and "de-improved" Slashdot 4

If you've known /. for a while, you've certainly noticed all the recent changes. The front page articles auto-load-extend (presumably through AJAX code), the link to get to your own page has moved twice, and now there are two (that both look alike - your username - but work differently), and checking if anyone has replied to your comments has been a two-click journey instead of the old one-click for a while now.

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.

Television

Journal Journal: multicast video: someone's finally doing it 1

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.

Programming

Journal Journal: I can't believe this happened. I miss .. Pascal?! 1

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 .. obvious.

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.

The Military

Journal Journal: Hudson River plane crash 1

It just astonishes me that they got everyone out of that plane safely. Kudos to the Coast Guard and whoever else ran that operation. It's absolutely mindblowing.
TurboLinux

Journal Journal: Hudson River plane crash

It just astonishes me that they got everyone out of that plane safely. Kudos to the Coast Guard and whoever else ran that operation. It's just mindblowing.
Transmeta

Journal Journal: What to buy on eMusic? 3

My new wireless router came with a coupon for 50 free downloads from eMusic. Is there a particular strength that store has? It seems like mostly the usual unfiltered jumble of unknowns, with no good way to see what gems others have found and Todd Snider is the only one I know at all, with shovelware albums from some bigger-name artists mixed in.

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.

Security

Journal Journal: The ad business REALLY sucks 2

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.

Power

Journal Journal: Bailout bill, Rosh Hashana 2

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!

Red Hat Software

Journal Journal: Williamses versus Mannings

I'm still not entirely sure what that commercial is selling (Oreos, right?) but I wonder if I'm not the only person who watched it and thought "The four of them of them totally ought to date!" They seem like they'd hit it off, actually, and it might be the only way the Brady-Bundchen/Monahan kids will get any serious competition.
Perl

Journal Journal: A Python window manager

Remember when there used to be those window managers whose big selling point was that you could do things to them in LISP, back when people still cared vehemently about window managers. We now have qtile which now allows the same thing in Python. I'll give it a try to see why anyone would want that, which I never understood for the LISP browsers.

Slashdot Top Deals

HELP!!!! I'm being held prisoner in /usr/games/lib!

Working...