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


Forgot your password?
Get HideMyAss! VPN, PC Mag's Top 10 VPNs of 2016 for 55% off for a Limited Time ×

Comment Re:Stupid python comment (Score 1) 160

But on the other hand, neither form is something that a beginner would know without being told, really you're going to need to be handed an example to learn it, so the actual practical difference between the two isn't that huge.

A beginner wouldn't know that a "read" method exists in a "file" object. But when confronted with a "file.read()" invocation, the meaning seems pretty straightforward to intuit.

Now, "local $/;" gives you absolutely nothing to reason over it. Only after your explanation I have a grasp on what's happening (which in Python could be represented with "".join(file)) , though I still don't understand how the $/ syntax means $INPUT_RECORD_SEPARATOR = undef.

Comment Re:Stupid python comment (Score 1) 160

It's mostly because Perl is line-by-line by default. Most of the time you don't want to read a whole file into memory, do you?


You could also do my @data = <$file>; which slurps the whole file, line-by-line, into an array, if that's what you need.

I can't say "most of the time", my guess is I use equally reading the whole file, reading chunks of binary files, and reading lines.

local $/; switches to slurp mode (temporarily).

Ahhh, of course!!! That's obvious! </sarcasm>

Not only the syntax is cryptic, the terminology is terrible! "Slurp" is a funny way to describe the process, but introduces one more step (two more for non-native speakers) to understanding it. Compare that to Python's `file.read()` and `file.readlines()` and you'll understand why Python is better for beginners and for people that want maintainable code.

Shakespeare's style might be great for poetry, but if you use it to write guides, don't be surprised if people get lost.

Comment Re:Stupid python comment (Score 1) 160

a) Scientists are terrible at Perl. "You can write FORTRAN in any language" applies to them; they often write Perl as if it were C. Or that's my experience based on Stack Overflow and Perlmonks questions. They aren't programmers, they're scientists, and it shows.

Yep, that's usually the case.

b) A rewrite is always clearer, no matter the language.

You are right, of course, and as I used the word "translated", that could imply a rewrite. I should have used "transliterated", as I kept the original structure.
I tried to find these scripts so I could give a concrete example, but I could only find my Python versions. But it was stuff in Perl like

open($file, "file.txt");
my $data = do { local $/; <$file> };

that in Python becomes

data = open("file.txt").read()

that makes you think, wtf Perl??? Really, why do you need all that crap just to read the whole file?

Comment Re:Stupid python comment (Score 1) 160

Thanks for your comment, it expresses my view pretty well. I want to add a note about this:

Also, Python has done pretty well as a first programming language, even if the design runs out of steam at certain points. In contrast, we tend to think of Perl (especially Perl 6) more as a last programming language, the language of choice for people who need a language that won't give up when the going gets tough.

I started coding with BASIC and Z80 Assembly in the late 80's, then coded mostly C until 97 when I switched to C++, then finally in 2006 I switched to Python as main programming language. In these ~30 years I obviously had to program in several other languages, and Perl is by far the one I most hated. After my bad experience with Perl I even translated some Perl scripts coded by a biologist friend (Perl seems to be strong in the field) to show her how much more clear and concise they can be made in Python, and the difference is undeniable.

So it seems to me that Python (with occasional C extensions for speed) is a suitable "last language", though what the future holds no one knows. Except that it will be neither Perl 5 nor 6.

P.S.: JavaScript as it was in the beginning was pretty terrible too, even if it had a saner syntax. But it redeemed itself in the latest ES standards, and with the recent frameworks it is actually quite enjoyable.

Comment Re:Microsoft announcement: "content youâ(TM)v (Score 5, Insightful) 115

It's even more interesting when you contrast it with the way the media conflate copyright infringement with stealing. When someone makes a bootleg copy of a movie, the original is still accessible. When someone steals something from you, you lose access to what has been stolen.

So, when will we read the news "Microsoft will steal workout videos from consumers"?

Comment Re:More Proof (Score 5, Insightful) 102

The FBI is only one of the cogs. Isn't it troubling when you can read either as ...

The secret *government requests* for customer information


The *secret government* requests for customer information

because the FISA Court allows for exactly that, a secret and unaccountable government. Some day they'll swap "Foreign" for "Federal" in that acronym and nobody will notice any difference.

Comment Re:I always prefer magic in my fantasy (Score 1) 951

It would be so much better if Musk took up a conventional religion with decent moral imperatives

The intersection you want is empty, unfortunately. Unless you consider Jainism conventional. Religions in general have a tendency to consider moral the killing of people with certain (arbitrary) characteristics. IMHO, if you believe that you're as immoral as you could be.

United States

Civil Liberties Expert Argues Snowden Was Wrong (usnews.com) 209

An anonymous reader writes that in 2014, Geoffrey Stone was given access to America's national security apparatus as a member of the President's Review Group on Intelligence and Communications Technologies. Last week Stone, a staunch civil liberties supporter, moderated a live discussion with Edward Snowden from Russia, and this week he actually praised the NSA in a follow-up interview: "The more I worked with the NSA, the more respect I had for them as far as staying within the bounds of what they were authorized to do. And they were careful and had a high degree of integrity... I came to the view that [the programs] were well intentioned, that they were designed in fact to collect information for the purpose of ferreting out potential terrorist plots both in the U.S. and around the world and that was their design and purpose...

"I don't doubt that Snowden was courageous and did what he did for what he thought were good reasons. But I think he was unduly arrogant, didn't understand the limitations of his own knowledge and basically decided to usurp the authority of a democracy."

Meanwhile, a new documentary about Julian Assange opened at the Cannes film festival this week, revisiting how Wikileaks warned Apple that iTunes could be used as a backdoor for spies to infiltrate computers and phones.

Comment Re:Oculus is worse than microsoft (Score 3, Interesting) 78

Yes, MS loves UNIX standards. Like when they decided to use \ as folder delimiter, just to be different. And instead of using about any-fucking-thing else, they had to pick exactly the escape character. The Devil himself was envious of their ingenuity, which was eclipsed only many years later, with the launch of IE6.


Lab-Grown Meat Is In Your Future, and It May Be Healthier Than the Real Stuff (smh.com.au) 274

An anonymous reader shares an article on The Sydney Morning Herald:Scientists and businesses working full steam to produce lab-created meat claim it will be healthier than conventional meat and more environmentally friendly. But how much can they improve on old-school pork or beef? In August 2013, a team of Dutch scientists showed off their lab-grown burger (cost: $435,000) and even provided a taste test. Two months ago, the American company Memphis Meats fried the first-ever lab meatball (cost: $23,700 per pound). Those who have tasted these items say they barely differ from the real deal. The Dutch and the Americans claim that within a few years lab-produced meats will start appearing in supermarkets and restaurants. And these are not the only teams working on cultured meat (as they prefer to call it). Another company, Modern Meadow, promises that lab-grown "steak chips" -- something between a potato chip and beef jerky -- will hit the stores in the near future, too.

Slashdot Top Deals

"Indecision is the basis of flexibility" -- button at a Science Fiction convention.