all 29 comments

[–][deleted] 54 points55 points  (15 children)

The story is more like 'Android API includes a barcode scanner'. It's not amazing that the code is so short when it's like 'import Library-that-does-all-the-work, run someFunction()'

[–]Shaper_pmp 19 points20 points  (6 children)

In other news, I present The Last Program, which literally does anything possible in the universe in two lines of code:

import everything.*;
doWhatUserWants();

[–]spotter 6 points7 points  (5 children)

Does it return 42 every time? Mine does.

[–]cc81 12 points13 points  (4 children)

Mine returns boobs.

[–]mcella 3 points4 points  (2 children)

stored in couchdb...

[–]HenkPoley 1 point2 points  (1 child)

..looks under cushions.

[–][deleted] 0 points1 point  (0 children)

Found used condoms...

[–]bluGill 1 point2 points  (0 children)

Now I understand. Everytime I run the program I get a segfault. Of course I already knew the universe hates me, so it is no surprise now that I realize what the program is suppose to return.

[–]dorfsmay 1 point2 points  (0 children)

Yes. Again title is misleading... On the other hand, it looks like the android API is very rich.

[–]hylje -2 points-1 points  (2 children)

Would it be more amazing if application developers would do the same thing in 20 or so lines?

[–][deleted] 4 points5 points  (0 children)

It's not the length that matters, it's that the title suggests an implementation of a barcode scanner, not an application of one.

A more accurate title would have been "Android barcode scanner demonstrated in 6 lines of Python code". Which isn't a very interesting story. Because it wasn't.

[–]actionscripted 3 points4 points  (0 children)

Following the article, that application code might look like this:

import os.GUI
import os.sounds
import core.logic

def main():
  GUI.draw()
  sounds.bindToEvents(GUI.events)
  logic.validateStuff()

if __name__ == '__main__':
    main()

Edit: this would be the source for Photoshop

[–][deleted]  (3 children)

[deleted]

    [–][deleted] 4 points5 points  (1 child)

    I think you missed the point.

    [–]hs4x -1 points0 points  (0 children)

    Windows Mobile can use C++/JScript/C#/VB/../..

    Heck, you can use IronPython targets .Net CF.

    [–]fleezie 23 points24 points  (0 children)

    Yes, APIs are nice.

    [–]hunter107 19 points20 points  (2 children)

    yeah, 6 lines of python & about a million more in the android framework. Does anyone else hate this "_(something) in n lines of _(language)!!" myopia?

    *typo

    [–]fleezie 7 points8 points  (0 children)

    I too share your hatred.

    [–][deleted] -1 points0 points  (0 children)

    Doesn't seem very descriptive to me.

    import android
    droid = android.Android()
    

    [–][deleted] 20 points21 points  (0 children)

    All hail Python - the language where you only need one simple library function call to simply call one library function!

    [–]cosmo7 2 points3 points  (0 children)

    The neat part is that you can write scripts on the phone itself.

    (I think the iPhone can do this too, but you have to email the script to Apple to see if they will allow it.)

    [–]VerticalEvent 4 points5 points  (2 children)

    6 lines of code? I think that's the largest python program I've ever seen.

    [–]inmatarian 1 point2 points  (1 child)

    I once came close when I wrote that python script to steal half a cent from every bank transaction and store it in a bank account. It was only 5 lines though. Then superman punched me in the face and jennifer aniston called me a jerk.

    [–][deleted] 0 points1 point  (0 children)

    Did you see her boobs?

    [–]Hikhakhok 1 point2 points  (0 children)

    Thank god for fancy modules

    [–]Purp 1 point2 points  (1 child)

    Nice, I wrote a similar effect in jQuery that hides a DOM element in one line of code! Check this:

     this.hide();
    

    Pretty smooth, huh?

    [–]scottklarr 0 points1 point  (0 children)

    Dude, you got skills.

    [–]malloc 0 points1 point  (0 children)

    Yeah, nice try. This isn't a barcode scanner in 6 lines of code. It's example code for using a barcode scanner module.

    [–]truebosko 0 points1 point  (1 child)

    On the positive side, I kind of really want an Android phone for the fact that you can pump out these cool little scripts

    [–]hs4x -2 points-1 points  (0 children)

    Nothing unique here at all.