Become a fan of Slashdot on Facebook

 



Forgot your password?
typodupeerror
×

Comment Re:Reference counting and unmanaged resources (Score 3, Insightful) 196

these implementations pay a penalty for relying on the VM's tracing garbage collection, and this penalty is loss of finalizer functionality.

And this is why it is best practice in Python to use the with statement, to make sure that things get cleaned up when you are done with them.

In CPython you can get away with just dropping your objects on the floor, and the reference counting will clean them up for you. In other implementations, not so much.

This works okay in CPython:

def read_data(fname):
    f = open(fname)
    return f.read()

In CPython, with no references to f it gets cleaned up, and the open file gets closed.

In any version of Python, this works great:

def read_data(fname):
    with open(fname) as f:
        return f.read()

The with statement ensures that the open file will be closed, no matter how the function is exited (including by exception).

And I actually prefer the with statement these days... I like how it makes the lifetime explicit for the stuff it wraps.

Raymond Hettinger has expressed the opinion that the with statement is one of the really best ideas in Python. I think that was during his PyCon session where he listed his favorite things in Python.

Comment Re:And it still has the GIL (Score 1) 196

You actually have two complaints, not really related.

One complaint is the GIL. As I understand it, the GIL is mainly needed because the CPython reference counting model needs to touch a whole bunch of reference counts when churning objects, and this needs to not screw up. Thus Jython and IronPython, leveraging the garbage collection of their respective underlying VM platforms, didn't need a GIL.

The other complaint is that the language is too dynamic. That's just part of the design of the language. I can somewhat sympathize; I don't overuse the dynamic nature of the language (I know I can rebind "list" to do my own thing, but I never ever do that), and since I don't do that I would rather not pay the runtime penalty for it.

PyPy's JIT works by watching what the code is actually doing, and when it sees that (for example) your code never rebinds "list" it can strip out the dynamic lookup of "list" and just hard-code in a reference to the builtin "list" class. It can gain an extreme speedup when it detects a simple for loop, because it can replace all the Python VM machinery (creating new int objects, then freeing them) with a simple loop.

And, on the other hand, I do use the dynamic "duck typing" features to write less code, and I don't want to lose that. I love writing functional Python code where you can pass a function object in to another function and get a lot done with a relatively small amount of code.

It's possible that someday, some other language with a different static/dynamic tradeoff might eclipse Python; but I'm still using it because I get work done in it, and it is fast enough for the things I am doing.

Comment Re:And it still has the GIL (Score 5, Insightful) 196

You make it sound as if it were no big deal to remove the GIL. It has been tried, and Python got 2x slower, so that attempt was abandoned. Python 3.2 gained a different implementation of the GIL, and that fixed some problems, but other problems still occur.

The GIL is Python's hardest problem.

https://www.jeffknupp.com/blog/2012/03/31/pythons-hardest-problem/

https://www.jeffknupp.com/blog/2013/06/30/pythons-hardest-problem-revisited/

As noted in the above referenced blog, you can use Jython or IronPython to avoid the GIL; PyPy will be using Software Transactional Memory to avoid the GIL; and you can use the multiprocessing module to use multiple cores without GIL problems. You do have options other than just using CPython.

If removing the GIL was as easy as you seem to think, it would be gone now, at least in a fork of CPython. Yet still it remains.

Comment Re:OLPC served its purpose (Score 1) 111

no....
If OLPC wants a new mission, it should be to develop FREE educational software that runs on standard Android tablets.

Sure. They give away all the software they write already, and I assumed that they would give away any Android software they write. It seemed so obvious that I didn't feel the need to put in the word "free" but I guess I should have. Thanks for the comment.

one of the largest problems is that there are not a lot of books printed in the languages of 3rd world countries. and absolutely no advanced education texts.

I agree. IMHO that is the "killer app" for the OLPC devices, or for Android tablets. It's great that they can run software, but it's essential that they serve as textbook reading devices.

I think the ultimate educational tool for developing countries would be a ruggedized Android tablet with an e-ink screen. Color is a nice-to-have rather than essential, and the dramatic increase in battery life would be the win.

This suggests another idea for OLPC's future: they could make a deal with Amazon and ship a customized Kindle e-ink reader. Or maybe make a deal to ship a customized Nook. But either way, ride the coattails of a company that already spent the R&D and focus just on adding educational software.

Comment Re:for the record (Score 1) 406

I disagree with your analogy in which you compare stealing a car with patent grabbing.

Um, no. I said that stealing a car with the keys inside is still stealing; despite the fact that the car owner "enabled" the theft by being careless with the keys.

In the same way, being a jerk with patents is being a jerk, despite the fact that the USPTO "enables" patent jerks by granting patents that should not be granted.

Even if Apple were to have freed every one of their smartphone inventions, there would still be lawyers arguing that those inventions are not comprehensive, that their client has patents that fall between the gaps.

Your language loads the question here. You presuppose that Apple "invented" everything that they patented; I think some of it has prior art, some of it is obvious (like the patent on dialing a number by touching the number on the touchscreen), and some of it is probably genuinely new and interesting but by now I'm predisposed to assume Apple is a jerk.

And as for your main point, you are simply mistaken. If Apple had not patented anything, but just made a public demo of the iPhone, nobody would be able to file a patent after that and use the patent to hammer Apple. Apple's iPhone would now be prior art. If you disagree, please post some sort of reference to any example that would disprove this idea.

I work at an IP company, and it has been hammered into me not to disclose anything that might be patentable, because once the idea has been publicly disclosed, it becomes not patentable. I'm not a lawyer of course.

the analogy here is a defense system vs having weapons of your own.

I understand the possible use of patents as a defense. For example, Google: I am not aware of any case where Google tried to shut down a competitor using patents. This despite the fact that they own many patents.

However, Apple has been trying to use patents to prevent Samsung from selling phones. I have a problem with that.

you can't blame one company for doing it in a world in which everyone has the bomb.

Um, the whole point of my comment is that I do blame one company for doing this. I blame Apple, I blame Microsoft, I blame any company that is getting egregiously bad patents and enforcing them.

Comment Re:OLPC served its purpose (Score 3, Interesting) 111

I agree.

If OLPC wants a new mission, it should be to develop educational software that runs on standard Android tablets.

You can buy "white box" Android tablets at amazingly cheap prices because they are mass-produced in China. While these tablets fall short of the ideal devices imagined by OLPC, there is absolutely no way for OLPC to get their costs down to match.

You can buy at least three Android tablets for the cost of one OLPC device. You could bundle tablets with a keyboard, a carrying case, and maybe a solar panel, and still massively undercut the OLPC's custom hardware.

Cheap Android tablet's don't have great battery life. But I bought one of the original XO-1 laptops and it only had a few hours of battery life, so clearly OLPC must consider even the limited battery life of a cheap tablet to be sufficient.

One of the nifty things about the OLPC custom design is that it's easy to repair. But with the massive cost advantage of a generic Android tablet, whole spare tablets could be shipped.

The promise of Sugar never was realized. For example, one of the reasons I bought an XO-1 laptop was that I was excited by the thought of the "show source" key, where you were supposed to be able to go anywhere in the system, hit the "show source" key, and find some kind of editable Python source code you could tweak. I never did find any source to tweak before I gave away my laptop. (It's in India now!)

Another part of the OLPC custom hardware was the "mesh" networking, which aimed to make it possible for multiple students to cooperatively share limited networking resources. Did that ever actually get used? All the photos I have seen show students in classrooms, and if the classroom has WiFi then an Android tablet would work fine. If the "mesh" networking is valuable, then maybe OLPC should invest in a one-off gadget that just does that, and plugs into the USB port on an Android tablet.

Comment Re:for the record (Score 4, Insightful) 406

Apple is not the problem. The patent system is.

Can't we agree that both are?

If you leave your car with the keys in the ignition, then it is partially your fault when someone climbs in and drives away. However, the person who stole the car is also to blame. It's not a valid defense to say "He left his keys in the car so it wasn't stealing."

If all Apple wanted was to make sure nobody else got patents on all this UI stuff, they simply could have fully published the details of how their phone worked, and nobody filing after that would be able to claim to have invented it. And I'm not a lawyer but I think Steve Jobs's public "one more thing" demos would have sufficed to make all those UI features unpatentable by anyone else.

But that wasn't enough for Apple. "Patented!" crowed Steve Jobs. Apple patented everything they thought they could get away with, including totally obvious stuff like squishing your fingers together to make things get smaller on the screen, and spreading your fingers wide to make things get bigger on the screen. Come on, that is totally obvious and there even was prior art on it. So we return to where we started: the USPTO is a problem because it let Apple patent obvious stuff, but Apple is part of the problem for trying to patent obvious stuff. (Fortunately the "pinch-to-zoom" patent was in fact invalidated, due to Samsung winning in court against Apple!)

Samsung is going to go scorched earth on this new lawsuit. Millions for defense and not one cent for tribute. And Samsung has the millions. I hope Samsung wins big and invalidates all of Apple's patents.

(And then, as long as I'm dreaming, Samsung can go invalidate Microsoft's mobile patents next.)

Comment http://www.foldscope.com/ (Score 4, Informative) 83

They have a website devoted to this:

http://www.foldscope.com/

And the news on the web site is that they will give away 10,000 of these to people who volunteer to test them. If you think you could do a good job of testing, maybe you should sign up.

http://www.foldscope.com/#/10ksignup/

To me, the most impressive part is that he claims they have very accurate focusing. I believe he said "micron" focusing. I'm not sure how that works, but the paper is cut to a very accurate shape (the video showed some sort of computer-controlled cutter, it might even have been a laser cutter). By moving a tab I guess the paper can be made to flex predictably to focus the lens?

Comment Not really big news (Score 2) 42

The biggest part of this story is that it is now easier to make a trojanized version of a legit app. But it has been possible from day one.

Android apps are written in Java, and Java bytecodes can be decompiled into something remarkably similar to the original source code. Then the source code can be edited and complied back to an app. Hey presto, you have a hacked up version of the app.

http://stackoverflow.com/questions/12370326/decompile-an-apk-modify-it-and-then-recompile-it

But -- and this is important -- the person using this attack has no way to sign the malware with the same signing key as the upstream source of the original, legit app. This means that it is much harder to trick someone into running the malware.

So, if you get an app from the Google Play store, and later someone tries to overwrite your app with a new build that is malware-infected, Android will refuse to install the new app, because the signing key isn't identical.

http://developer.android.com/tools/publishing/app-signing.html

So, if a user gets an email with an attached "free" version of an app that normally costs money, and that user has not previously installed the legit version of the app, and that user sideloads the malware version, then that user will have malware on his/her Android device.

So, as usual, it's easy to protect yourself: get apps from the Google Play store, and don't sideload apps unless you are certain they are clean.

For that matter, if you are browsing the Google Play store and you see an app that has only been up for a day, and claims to be a miraculously free version of a payware app... just say no.

Comment Career advice from Yoda (Score 4, Insightful) 451

If once you start down the Microsoft path, forever will it dominate your destiny, consume you it will...

Seriously, Microsoft is in decline, and already has a bunch of people trained up in it. You should consider learning mobile development for Android, iOS, or both. If you want to learn server-side stuff I would learn the open stack: Linux, MySQL and/or Postgres, maybe Hadoop.

Comment Re:We're number one! (Score 4, Insightful) 193

explain the lack of similar quantities of malware for iOS between 2007 and 2012?

Because of Apple's "walled garden". The only way to get apps for iOS is from Apple's store, and Apple tries to keep the malware out.

Apple always charges $100 to put an app in the store, so malware has to make at least $100 before it is discovered or the person who put the malware on the store loses money.

The "walled garden" does have advantages.

Personally, I like having a device where I can install anything I want... but I pretty much just get stuff from the Google Play store. If I need an SSH app, and I see one with over 30,000 votes rating it 4 or 5 stars, I'm pretty sure it won't be malware when I download it.

And according to TFA, almost all of the malware was side-loaded. Almost none of the malware came from the Google Play store. Thus, Android gives me the advantage of the walled garden, while still being more free than iOS.

P.S. The reason I went with Android rather than iOS was Apple's policy of no interpreters and no emulators. I wanted Python and games emulators. Apple has since then unbent a bit, but Android has always allowed you to install whatever sorts of apps you prefer.

Thus I am able to install interpreters and emulators, without rooting my phone, and getting them from the Google Play store. Why wouldn't I want this?

Comment Re:"Interactive" (Score 1) 769

I'm guessing that the chip in the pod tailors the brewing cycle for the coffee (or tea) in the pod for the best possible quality.

That's not enough to make people embrace the lock-in, I don't think. To anyone who is already okay with these single-serving machines, that won't make a difference.

So, they have their choice: stop making the old machines to try to force everyone to upgrade, or have people not care about the upgrade.

P.S. Nespresso machines read a bar code on the pod, which customizes the brewing. So custom brewing isn't even a new idea in single-serving coffee makers.

Comment What do the humans actually do on a ship? (Score 4, Insightful) 216

The article is mainly about using telepresence and computers to pilot a ship. But other than piloting, what else do humans do, and how automatable is it?

For example, how often do people have to repair ships while under way? During a storm, do people ever have to run around fixing chains that are working loose, or fix a leaking seal and set up pumps to pump out a flooded compartment?

I don't know the answers to the above questions, by the way. I don't know much about cargo ships.

Even if we still need humans for some tasks on a cargo ship, perhaps not too far in the future, we might have telepresence robots that can do the tasks.

Comment Mobile app wisdom (Score 4, Insightful) 333

There's an old saying: To gain knowledge, add something every day; to gain wisdom, get rid of something every day. I'm not sure exactly how that is supposed to work (where does the wisdom come from?), but clearly you can choke your life if you accumulate too much stuff.

And that's really true for mobile apps, which can choke your phone. Two years ago my wife's phone (Android 2.x) became unusable, and I discovered that she had installed five or six dozen free apps, and many of them had installed service daemons. (Why do workout tracking apps, cookbook apps, or lightweight games need daemons?) She made an effort to purge down to just the apps she needs.

Even if you assume that the phone can handle all the apps, they still add chaff for you to sort when you are looking for the app you actually want to run.

P.S. Jeff Atwood's rant was good, but he missed one of my pet peeves: I will click on a news story link in a blog or Slashdot or something, and the linked site will pop up a banner: Hey! Don't you want to install and use our mobile app? Why no, web site I have never heard of before, I really don't want to download and install your app. I just want to read the one story, and at the moment I'm reconsidering even that.

Slashdot Top Deals

"God is a comedian playing to an audience too afraid to laugh." - Voltaire

Working...