Python vs Java, from a different perspective

So, follow me with the crazy idea of creating a Java-based package manager (using Java SE). Yeah, you got it right, a typical GNU/Linux package manager.
Why does it sound so crazy after all? Let’s assume that we could split the Java libraries into two, removing Swing/Awt stuff creating a theoretical java-core package. Moreover, let’s assume that disk size is not an issue (nowadays, it’s not).

Let’s start from Python. There are so many package managers out there using Python, completely written in Python (like Entropy), which has many disadvantages in my opinion: dynamic typing, cough cough, which is the root of all the Evil in this world, and makes it impossible to reliably introspect code by static analysis tools; slowness: to write fast (enough) code, you have to write “ninja combos” (list comprehensions, cough cough), Java is much faster than Python (fact!)… and so forth! And, don’t get me started with the Python 3.x idiocy, please no (this proves that Java is much more mature and reliable than Python, syntax wise).

So, am I really crazy to think that, given the “constraints” listed above (Swing/Awt and size), it wouldn’t be too bad to consider Java as programming language for package managers, given that Python brings more or less the same dependencies and pitfalls (more and more pitfalls, actually)?

Food for thought.

About lxnay

the creator of Sabayon Linux, Entropy Package Manager {Eit, Equo, Rigo}, Molecule release media buildsystem, Matter Portage buildbot/tinderbox and only God knows what else...

22 responses to “Python vs Java, from a different perspective

  1. Hi lxnay.

    I think using C or C++ would be the best way for a package manager because Java isn’t really free (thanks Oracle).

    Kindest regards

  2. Ra

    Not entirely crazy, no… but I’d definitely use Scala as JVM language – it is just more fun and actually very useful.

    The question is, are these really the only two options? C++ is out? Haskell is out?

  3. I like Java too. It would be easier to me to contribute with code too🙂

    I can’t see the problem with the graphic library. The JRE is something around 30MB, not really a problem in nowadays systems.

  4. Caster

    The problem is that a package manager has to work on all platforms supported by the distro. And the number of platforms with a JVM with JIT support (otherwise it’s damn slow) is quite low…

    • Fair, but doesn’t apply to Sabayon. Question is, many people dislike Java, but in the end, Python follows the same “philosophy” (code is converted to bytecode which is “understood” by the underlying virtual machine). So why the hate, beside politics and performance on supported architectures (which is not my case).

  5. Zack

    Java really is a lot faster than Python, but then C++ is a lot faster than Java, and for Qt, native. QtJambi is no longer officially supported, whereas PyQt not only still is, but PySide is up and coming, leading to more choices in the Python/Qt space. I really don’t see where Java would make sense for Sabayon, specifically. Can you think of any reason not to use C++ or even C for the base package manager, and then native C++ Qt or stay with PyQt for the front-end alone, if what you want is static typing?

  6. Necoro

    I’m wondering, why you used list comprehensions as a downside of python… They are (in my eyes) one of the great constructs of python.

    And Java … idk … I always hate it, when I’m forced to use it😛

  7. Zack

    Addendum to my previous comment: Since I use the Oxygen-Molecule GTK+ theme, I forgot that Sulfur was PyGTK, not PyQt. Same applies there though; according to http://www.gtk.org/language-bindings.html , only the C++, Python, JavaScript and Vala bindings are up-to-date, as well as the original C API of course. Java-GNOME is three versions behind, and who knows if it’s going to make the GTK3 transition.

    Vala could actually work well if you want a Java-like language (as Vala takes from C# syntax, and C#’s is derived from Java’s), and it even compiles down to native code. Then just make the back-end in C (or Vala also), and you’re all set. Alternatively, C++ and gtkmm could work too.

  8. I think Entropy is plenty fast.

    If you want a statically typed language, I’d recommend Scala or Haskell.

  9. Cata

    Nowadays I earn my living as a Java programmer (and it is my language of choice for most tasks), but I would have to agree with people supporting C++ instead.
    Pros:
    – C++ is faster
    – you can write nice, clean, OOP code in C++
    Cons:
    – C++ is not so type safe as Java (in my opinion at least)
    – Java might not be free for long (Oracle basically already destroyed Solaris, I would expect a closed and expensive Java version any day now)

    PS: I never worked with Scala or Haskell, but from wikipedia I see that they are both functional languages (I only learn a bit of Lisp back in college) and I think an imperative language (C++, Python, Java) would be a more appropriate than a functional one for the case of a package manager

    PS2: If Java is voted, I would really like to contribute (C++ too, but my C++ skills are a bit rusty these days)

    • Ra

      Java is GPL’d, and that is non-revokable. Only the “Java” trademark is at stake. But the language isn’t really at stake. Java -unlike Solaris, which is an extreme fringe OS by now- has a massive number of capable users with very strong (also in monetary terms) interest in the language not being corrupted by Oracle. If Oracle did that, the forked versions of Java would nearly inevitably take over about all of Java’s market.

      As for the languages I mentioned: Functional code would actually work well. Apart from that Scala is OO/imperative as well as functional and it runs on the JVM (so it is Java-compatible, Scala can use Java libs and Java can use Scala libs).

  10. Bob

    I’ve primarily programmed in C/C++, Java, and Python. Of course, you can’t use Python with static analysis tools, it is a dynamic language. That why they have other analysis tools. Dynamic languages are always slower than statically type languages on a per instruction basis, but I always find it faster to code something in Python than Java.

    Where Python can be faster than Java is with the multiprocessing module. Like C, but unlike Java, it allows you create real system processes with cpu affinity. It also supports coroutines that people have been asking for in Java since 1999.

    You don’t like list comprehensions (not a Python invention) so you probably don’t like functional languages.

    There really isn’t a “different” perspective in this blog. It is that you like this but don’t like that. Nothing about the suitability of the language for the task. I think Python is a perfect fit for a package manager, the difference in performance versus development time and the ability to modify makes a Java a poor choice.

    If you were performing 10^10 floating point calculations you would definitely want a statically typed language. So, why not use C++ or even Go for optimal performance?

    This is what a lot of financial services firms do. Their short term (i.e., seconds) models use C++ and their long term models (i.e., days) use Python, particularly for its support of complex numbers and scientific calculations.

    For web performance, the difference between Java a Python can be insignificant because of the inherent network delays. Youtube is written completely in Python.

    Having spent years with Java, I am now hard pressed to find it the correct tool for a job from an engineering perspective. Where it really shines is in finding programmers. Everyone seems to know Java. So for day to day corporate work it is a perfect fit.

    • I didn’t say I don’t like list comprehensions, I’m just saying that they make your code harder to understand in most cases.
      And the case here is not about “what is the best language for PMs”, but rather “if we all use Python, what’s wrong with Java?”. Maybe it wasn’t that clear😉

      • Zack

        For a command-line-only package manager, absolutely nothing is wrong with Java. From the perspective of “what if?” instead of “should we?”, my earlier comments perhaps are better reframed as:

        Java sucks with regards to availability of GUI libraries. C++ and Python lead compared to any other language in that department, by a pretty long shot. So while nothing is wrong in the performance front, you have to look at the larger picture; e.g.: don’t use Java for PMs unless you are cruel and want to inflict Swing on your users.😉

      • Ra

        @Zack: I disagree, there’s a boatload of GUI libraries for Java, both native Java and foreign-language with bindings.

      • Zack

        @Ra: They exist, but are they actually maintained? The three major toolkits used on Linux are GTK+, Qt, and wxWidgets. The Java bindings to the first hasn’t been updated in three versions [1]; the second, officially discontinued by Nokia [2]; the third, hasn’t been updated since 2006 [3].

        The ball’s in your court now. If you wanted to create a GUI in Java that has a native look-and-feel (so no Swing), what would *you* use? I freely admit that I am not a Java expert, so if there’s anything I’m overlooking, please tell me.

        [1] http://www.gtk.org/language-bindings.html
        [2] http://qt.nokia.com/about/news/preview-of-final-qt-jambi-release-available/
        [3] http://jwx.sourceforge.net/

      • Radtoo

        @Zack: Off the top of my head, I remember only that SWT has native look and feel for GTK+ and Motif (plus experimentally, QT). I don’t like or use AWT much, but that also renders stuff natively.

        As for the links, you looked in the wrong place. While I indeed cannot spot any activity on wxwidget’s side, QT Jambi and Java-Gnome are still maintained very actively. Check the development repositories (sorry, can’t remember how to post pretty links on WP right now).

        However, most importantly, things looking “native” (whatever that means – I’ll presume you really want QT or GTK+) is not a necessary criterion for a GUI toolkit at all.

        There are plenty of applications and things even in Linux that do already not look native by the standard mentioned above. To name a just few I remember: All the popular Google applications, most games and many other OpenGL applications, web pages, FLTK applications, Enlightenment’s applications, Cinelerra, Motif applications, even Xorg and the VTs outside in terms of text theme. And of course this is not a complete list – as I said, I just pulled that out of my head. Besides, show me a GTK / QT version that adapts my Awesome WM / Xmonad theme…

      • Zack

        @Radtoo: Yeah, there are some programs that do look out-of-place on the Linux desktop. One other variety you didn’t even mention is Tk, which is actually in more common use than FLTK, Enlightenment, Motif, or pure X applications. Programs that use pure OpenGL like in games are in a completely different category; an interactive 3D package management game would be cool, but probably not very practical.

        Still, 99% of what people generally use day-to-day on Linux uses GTK+ or Qt, whether directly or through a more abstract toolkit like wxWidgets or XUL (used by Mozilla applications).

        Or, apparently, SWT. It looks like it is kept current, and does try to fit into its native environment. Not perfectly (I downloaded and tried Eclipse to see it in action), but certainly a large improvement over Swing. I suppose that if you must use Java for GUI work, then SWT would be the way to go. Thank you for pointing that out.

        You’re not the only person to dislike AWT; all the web pages I found about it were from the 90’s or the early years of this century, so I question if it is even maintained anymore.

        (BTW, it’s Qt, not QT; QT usually stands for QuickTime, not the Qt toolkit. That’s not as bad as people that conflate the Apple Mac with a network MAC address though. And as nifty as xmonad is, you have to admit that it’s a niche desktop for Linux, as are all the non-GTK, non-Qt desktops. Not that there’s anything wrong with that, but don’t expect applications to try to fit into it.)

  11. Stupot

    As far as speed goes, you can’t do better than a compiled language, which is why I’d tip my hat at C++ over java or python.

    That said, it’s only as good as you make it and will be more to maintain than either python or java. In terms of performance vs. ease of programming, java is a very nice compromise.

    As a side note, I know C++ better than any other language and would definitely be able to help make bug fixes better.

  12. Thilo Bangert

    you may want to check out GO

    • Zack

      AFAIK, where Go shines is parallel computing. Other than that, is is merely another systems programming language like C, and very C-like at that. Package managers are mostly IO-bound though, whether in downloading from the Internet or unpacking to disk, so parallel processing won’t really help anything, thus I don’t see the point of Go. Nice thought though.

  13. Snow4Life

    I think java would be better than python, but C++ would be even better than java.
    A package manager, IMHO, should be compiled in order to run, not only faster, but most importantly, in any situation without needing other software layers to run.
    Moreover java Swing/AWT libraries are pretty orrible😛
    For an OS, particularly GNU/Linux, the package manager is one of the most important component, but, specially with a gentoo derived distro, the situations that the OS have to face up may be very different and can shift so much from the normal behavior or environment, so it’s important to rely on fewer external dependency as possible.
    For me the best to achive this task is native programming in a compiled language, C or C++ i think are perfect, about the GUI, i don’t know how X11 native programming is difficult but probably if some one can install X.org of course can install Qt (GUIs with Qt are very easy also with C++).
    About the programming languages, I know java and I am studying C++ just now, but, for now, the real differences between these ones are that java is more type safe and C++ have some little extra particularities, but once learned there isn’t more other things.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

hello, twitter

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 585 other followers

del.icio.us

%d bloggers like this: