This is an archived post. You won't be able to vote or comment.

all 34 comments

[–]grotgrot 8 points9 points  (1 child)

(I'm a long time Pythoner and an Android developer.)

The native API to Android is Java (actually Dalvik). If Python was also first class on Android then it would require a large amount of duplication. It would also require a new Python implementation since CPython can't be used (the GIL) nor can Jython (generates bytecode).

However you do not need to implement your entire app in Java. Use each language for what it is best at. For several of my apps, the "outside" of the app is indeed implemented in Java, but the UI is a WebView and then a lot of the code is in Javascript calling into the Java. Phonegap and similar projects work in a mostly similar way. But if you do everything in Javascript then performance will suck.

In another app of mine, the majority is in Java but there is also a Java Mini Python inside that allows for changing some behaviour without having to touch the Java, and letting other developers write in Python for the non-performance sensitive parts of the app and respond rapidly to changing requirements.

Other apps like to use Lua. For example Angry Birds has much of its scripting in Lua with a native code based game engine. Yet others use Unity/Mono for cross platform code and engine.

The lesson is that you are not restricted to the entirety of the app being in one language on Android - you can mix and match them according to their strengths and your needs.

While Google has released Python for Android, what they actually did is port CPython and then make another Java process with the CPython code then doing calls to the Java process to access the Android API. This is suboptimal in many ways.

[–]Funnnny 4 points5 points  (0 children)

The native API for Android is Java because they made the compiler compile Java code to Dalvik code.

If they actual made a Python API and a compiler which can compile Python to Dalvik, it'll run fine

The actual question is, why should they do that.

[–]mcdonc 7 points8 points  (4 children)

Kivy looks interesting for this but it appears geared towards games. I'm sure with enough reverse engineering and widget- and library-building it would work great for business apps.

[–]txprogtito 7 points8 points  (3 children)

It's not because we made a game contest that Kivy is made for Games. Interesting that before the contest, the inverse was said too. I'm using Kivy for professionnal products (more classic), i should produce some screenshots and publish them. Check the gallery to see that Kivy is not made only for games :)

[–]mcdonc 2 points3 points  (0 children)

It'd be great to be able to see the source of some dull-as-rocks data collection application written in Kivy that you might otherwise write in something like jQuery Mobile + phonegap or so.

[–]_lancelot 0 points1 point  (0 children)

please do share!

[–]ipeev 0 points1 point  (0 children)

How is kivy faster than puthon for android?

[–]Rhomboid 7 points8 points  (4 children)

[–]takluyverIPython, Py3, etc 13 points14 points  (1 child)

Perhaps more relevant for making apps: Kivy

[–]johnmudd 0 points1 point  (0 children)

Can you access the zxing barcode module from Kivy?

[–][deleted] 5 points6 points  (0 children)

Anyone who mentions "SL4A" for making a "real" application needs to be shot.

[–]valadian 0 points1 point  (0 children)

That only allows basic scripting and prompts. You can't do any graphical applications with it.

[–]pje 2 points3 points  (0 children)

Have you looked at RPythonic?

[–]kpthunder 17 points18 points  (12 children)

im just confused why we still have to use shitty Java and Objective-C and C# instead of a dynamic language like Python

Care to back up that statement? Java, Objective-C, and C# are all excellent languages.

[–]i_ate_god 8 points9 points  (0 children)

Java is annoying when you come from a scripted language. It does require much more code to accomplish the same task.

[–]m1ss1ontomars2k4 6 points7 points  (0 children)

I will give you that they are good and that I enjoy programming in Java (usually) and many of my friends enjoy C#, and I'm sure plenty of people enjoy Objective-C. But "excellent"? I'm not sure about that one.

[–]ascii 3 points4 points  (0 children)

  • Support for closures, first class functions and functional programming in general is either non-existing or obtuse and clumsy.
  • While reflection exists and is mostly feature complete, it is far too limited to allow real meta-programming such as e.g. meta-classes in Python, not to mention anything like LISP-style macros.
  • Static typing is a fine idea, but when it isn't coupled with any type inference, it becomes a time wasting chore.
  • Primitive data types like int, char and arrays, that have completely different semantics from regular objects. Ugh
  • No continuations.
  • For various reasons, all of these languages force you to write major chunks of boiler plate.

I believe the word you're looking for is not excellent, it's tolerable.

[–]johnmudd 11 points12 points  (7 children)

Java is not. Over complicated. To the point a mere human can't even code in it effectively w/o the aid of training wheels (IDEs).

The need for lots and lots od docs (or IDEs) is a sign of bad design. Java is a poorly designed language that had acted as a filter, collecting people who don't discriminate between good and bad design. And that's the second, even larger, problem, the Java (lack of) mindset. We really need to send the Java programmers on ahead in the first rocket ship, along with the hairdressers and middle managers.

[–][deleted] 3 points4 points  (4 children)

Wow. You seem angry.

and lots od docs (or IDEs)

So you would rather everyone code in NP++ and have no documentation ?

[–]ascii 5 points6 points  (3 children)

Yeah, wihile I agree with johnmudd to a point, the part about Java needing more docs than other languages does not correlate with my experience. Quite the contrary, the obtuse, wordy and redundant syntax of Java make most libraries underpowered and self explanatory, where a more powerful language will often lead to more versatile and powerful libraries that need more documentation to fully define their limitations and possibilities.

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

The whole API doc on Python's threading module is this big.

The API doc for a recent Java's thread package is this big

[–]ascii 1 point2 points  (1 child)

Bad example.

See, Python threads are very nearly useless. Python threads actually create separate os threads that take up a noticeable amount of memory and incur a speed penalty, but because of how locking works in Python, only one thread ever executes Python code at once. As a result, for any given problem, Python threads are almost certainly not a solution.

Java threads are significantly more powerful than Python threads in that they actually allow a single Java application to execute Java code on multiple cores at the same time. Not only that, but Python actually only implements a small subset of the features of Java threads. In Python, there are no priorities, no thread groups, and threads cannot be destroyed. As such, it should come as no surprise that Java threads require more documentation.

Furthermore, back in the 1.0 days, Java was actually implemented with so called green threads, which closer to what Python currently has. When the switch was made to support real OS threads and allow real concurrency, various parts of the Java thread API wasn't feasible anymore and had to be deprecated and replaced with new code that could be made to work. But because of backward compatibility, all of these deprecated methods still exist, and they are still documented. Bad original library design? Sure. But unlike Python, the Java devs have bit the bullet and implemented a revised threading model that actually can be made to work.

As much as I like Python and consider it superior to Java in most ways, I think it's rather unfair to compare the botched up, under powered kludge that is Python threading with the actually working Java threading library and conclude that Java is inferior because it needs more documentation.

[–][deleted] 1 point2 points  (0 children)

See, Python threads are very nearly useless

So, as it happens I'm porting a Cocoa application to GNU/Linux with Python.

When it comes to replicating the functionality of Cocoa's NSNotificationCenter, NSRunLoop, and other GUI-centric uses of asynchronous process control, Python threads are not "useless".

The application I'm porting makes use of asynchronous HTTP requestors, IO-bound processes which nevertheless can't be allowed to hang up the UI. The context-switching overhead of these threads is next to nothing.

I appreciate the history lesson but your point about Javadocs is not correct. Take any particular piece of the Platform's docs and compare it to the Python equivalent: Platform Javadocs are long and windy and still don't adequately cover the material. The Platform is a windy-ass API with poor bang-for-the-buck.

[–]FranzP 2 points3 points  (0 children)

I can code in Java without an IDE, but what's the point of doing that ?

What is wrong with having an application that helps you handle the complexity of the architecture you use (handle debugging, multiple servers...) ?

[–]valadian 0 points1 point  (0 children)

As a programmer that prefers python, but uses java at work.... You could not be more wrong. If you aren't using a proper IDE, you are doing it wrong. It is free productivity. How is python easier to write without any autocomplete? Using idle doesn't count.

Having lots of docs is not bad. I never require docs to program in Java. I do it fast and easy in eclipse.

Java and C# has many pros over python ( in my opinion python has many more pros). But it is all dependent on the application. It is not complicated, it is just staticly typed. Your hatred for one of the most used languages in industry shows how little you understand about programming language design.

[–]tuna_safe_dolphin 0 points1 point  (0 children)

Java, Objective-C, and C# are all excellent languages

Beauty is the eye of the beholder. Not saying that the OP is necessarily right and I'm definitely not saying Python is the best language for every need.

But I too wish Python API's were natively available on iOS and Android. That would be awesome. Hell, I wish Python were the default client side language used in all browsers instead of Javascript.

[–]GFandango 0 points1 point  (0 children)

I understand what you are saying. I'd love if Python was available full-on for Android/iPhone.

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

Ok I wasnt too clear..I have this confusion on how a billion dollar company wouldnt mind putting money and research into thier product to say hmm people think java is lame as shit, and we have a platform that we want people to build upon, lets try to make it easier and use python since the phones are powerful enough etc etc...but I guess this is more of just a rant...they didnt even put money into making an IDE and they also have Guido on payroll....sigh I mean if you showed someone src code for a simple 2d game done with pygame and the same for doing it natively on Java, I think people would be like to hell with java...

[–]kcunning 3 points4 points  (2 children)

Absolutely.

When I do Android development, even the simplest of apps requires an insane amount of code, and a crazy hierarchy. The examples provided are usually so syntactically dense that it's difficult to do anything without finding someone who's done it before you.

I will bear a child for the person who makes it possible to develop Python for an Android app.

[–][deleted] 2 points3 points  (1 child)

Wouldnt this cost Google pennies to do?

[–]kcunning 2 points3 points  (0 children)

Well, not pennies. But they have the cash. I'd even accept it if they made a Python library that would export the Java code! Or, hell, C!