Why not Java?

Well, this question is more directed towards the TLL team. I remember reading a while a go that Codea was at first going to be a Java IDE instead of Lua. I want to ask the question in the title, why not Java? Why Lua?
I’m in the process of learning Java, I have been learning for a few days so I’m just getting the hang of the syntax but even at the start it seems like a more complex (probably because it’s the start!) language that’s capable of a bit more than Lua. By more capable I mean has better memory usage. I looked at a bench mark for Java vs Lua: http://benchmarksgame.alioth.debian.org/u32/lua.php and the difference is quite big! So I’m wondering why the decision was made to use Lua instead? I’d like opinions from others as well, I want to know:
a) If you do Java as well, and which one do you prefer?
b) What would you think of a Java based Codea?
c) If you have learnt Java, how easy/hard is it compared to Codea Lua?

jsany is “Javascript Anywhere”, so that’s not Java. Procoding might do Java, but paper.js and three.js are javascript libraries, not Java.

I know it’s confusing, so maybe we should rename javascript to JNJ, meaning “JNJ’s Not Java”.

The language itself is often less of an issue than the API. For instance C# is good, but the main thing that makes it effective for business apps (don’t have experience on other types of things for it) is the .Net framework which gives you a massive set of stuff you can just use.

As to Codea, I like Lua, it has that whole lightweight dynamically typed languageness similar to Ruby that makes it very forgiving and accessable for non-experts. But the main value of Codea is the extensive API into fast functions, eg the hooks into shaders, sprite libraries, screen already setup for you, inbuilt game loop etc that TLL provide. The great thing about these, is the heavy liftings already done, the downside is, if the API doesn’t do just what you want then the sandboxed environment of Codea doesn’t give you anyway to attack the problem differently (eg create your own openGL buffers with different settings). But that’s not TLL’s fault, that’s the challenge of writing within a sandbox.

Speed wise, this also means the main performance heavy actions are through APIs to non-lua code anyway, so any notional lack of performance in Lua doesn’t really cause an issue.

For something like Codea in a sandboxed environment, the complexity of more structured staticly typed languages like Java would give little real pay back, because you still couldn’t get to the raw OS anyway.

@Bee trusty advice there, well I do like java as I have bought procoding. It’s quite good and has quite a few libraries pre-installed such as paper.js and possibility of three.js didn’t double check. But this should be a good starting place. No where near as efficient as codea, and the java language structure sucks compared to Lua, but never the less, its good and they have good examples to learn from.

@TheRogueBatcher I had a look at that before procoding but procoding won because I wanted to do processing as well

The write once, run anywhere (except iOS) part is great. There are security issues, but a JVM can easily be sandboxed, so that’s not a valid argument against porting it to iOS.

Swing is a pain, but it’s easy to knock up a GUI in a few minutes that works and maybe looks good. A mini-Swing with iOS components would be awesome.

My main issue with Java is lack of closures. Being able to pass a function to a Factory class would eliminate 100s of lines of code and anonymous functions to call other functions in my current project (stuck at 1.6 for historical reasons.)

Well I remember reading a similar question, and @Simeon answered there ‘Lua is more word based sintax, which is easyer on ipad’ or something like that

I only know the basics of java, so I cannot answer to the questions

Tho for b, if one really want a java version, well then, who’s in for the built? :wink: (I would like to help but I’m not capable enough for such a project)

I asked some time ago to Simeon ‘why lua’ and he made a nice answer.
I’ve programmed in java, and learned lua with codea, and for me no question: lua is a fantastic language for casual programmers. If you want performance rather than easiness, why not going directly to objective-C then? I assume you wont be more efficient with any other langage than apple native one?

@Jmv38 That’s a good answer, but java would have made it easier to put on android as well, which is a bonus for both creator (Simeon/John/Dylan) and the developers which is us as there’s a wider market. And Java is the native language for android, one of the reasons I started learning it.

It appears that the benchmarks you cite are heavily disclaimered as being OS/Hardware specific comparisons (under Linux) with a set of example programs.

Also, without forensically examining the benchmark examples, I would hazard to guess that these have not been optimised to get the optimum performance out of either language - so probably an unfair comparison (although I might be wrong!)

From what i know about Lua - its physically tiny, bloody fast and easily portable to virtually any platform that supports an ANSI C compiler (ie. all of them!). From a tech perspective this makes it ideal for integrating/embedding in other systems - hence it’s popularity. From using both, I think for beginners and casual users its a lot more accessible and forgiving than Java.

I guess, a Java-esque implementation of Codea would probably look very similar to Processing, as its based upon Java. It might be worth having a look at one of the many iPad implementations of Processing such as Procoding - all of which are significantly slower IMHO than Codea for doing similar things. :slight_smile:

http://www.jroller.com/obie/entry/top_10_reasons_why_java
http://mobile.betanews.com/betanews/#!/entry/10-things-that-suck-about-java,50273bf37af68a84dc805fa5
http://www.zdnet.com/three-billion-devices-run-java-yeah-but-do-they-like-it-7000017911/
http://tech.jonathangardner.net/wiki/Why_Java_Sucks
:-& :-& :-& :-& :-&

Lmao @Zoyt! Brilliant.

My two cents…

Java requires a full Virtual Machine which is supported on MacOS but will never be supported directly on iOS for similar reasons why Flash is not supported, basically security, as Apple lock down all filesystem etc functions to avoid any malicious apps…

As stated above, Lua fits well as it is basically C-based so integration with the underlying OS is well-defined, and despite possible shortcoming around type-safety etc. is a very friendly language, especially in the way Codea has implemented it…

Brookesi

I mostly program in Java and have been doing so for more than a decade. Interesting links @Zoyt, especially Obie Fernandez’s because back in 2007 he thought that Ruby won but I’d like to see his face when he checks the TIOBE rank (http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html) and see where Ruby is nowadays and what way it is heading to.

Back to the original question @Luatee, my first contact with Lua was when I installed Codea. At the time obviously I wished I could write Java code instead, but time went on and the usage showed to me that Lua was a better choice. Java is good, powerful, fast, omnipresent (except in iOS), but it is also too verbose and use more symbols, which makes it harder to type on a virtual keyboard. However, the main reasons for not choosing Java are probably those already mentioned by @brookesi, which is a shame because it not only rules out Java but also any JVM language. If I had to choose a JVM language for writing code on a tablet it would probably be Fantom (http://fantom.org). It is way less verbose than Java, has a succinct but eloquent and elegant syntax, can be statically or dynamically typed and many other niceties, but it is a JVM language, like Java, Scala or Clojure. It doesn’t mean that one couldn’t write iOS apps in it, but certainly not on iOS.

@Luatee - Being a Java programmer doesn’t longer mean that you cannot create iOS apps. Today there are options like Codename One (http://www.codenameone.com/) or RoboVM (http://www.robovm.org/) and reuse your Java code over multiple platforms as shown in this example http://blog.software4java.com/?p=148

I have to say, the concept is great - Code for anything once. It works great on non-visual devices, but things like iOS and Mac, it gets really clumsy. That being said, I do admit I have not spent too much time coding on it. Android’s main language (if I’m not mistaken) is Java, so that’s laregly why I’m sticking with iOS. To tell you the truth, I’m starting to think Android is great, but it has so many small irreversible flaws that keeps me with iOS from a developer’s point of view. I use what I code for. I could go on about Android, but that’s off topic.

@Zoyt it is Java, but it’s not as open sourced as it should be if it really wanted to be top. I think the problem with it is sandboxing while still having some freedoms to change layout, system controls and there’s a framework mod that has been added which adds some nice features but there’s still a cap on it which really does bring it down. Anyway back to topic, @brookesi I guess that would be a huge disadvantage and the only java interpreters I’ve seen on iOS are quite basic in their functionality. It does make sense to use Lua because it’s very easy to integrate in to every C language as far as I know of. @LightDye I’ve just looked at Code name one and it looks pretty good! I’m going to give it a try when I’ve finished learning the basics of java!

@Luatee Codea was never going to be a Java IDE — I initially weighed up Python and Lua and decided to use Lua because I like it more. Lua is also tiny, which was a strong factor in the decision (the Python library is on the order of megabytes, Lua is a minuscule amount of C code).

I still like Python, but I always find myself using it for shell scripts, interacting with text, and so on. For game programming I have always gravitated towards Lua.

I have never really liked Java. Though I am sure it’s getting better as its popularity grows. I never liked the burden placed on syntax by the language design (being forced to throw exceptions or use try/catch, no implicit casting, forced to declare public/private qualifiers). It’s a verbose language, but not in a way that assists readability and understanding. These things have probably changed in the last five years or so.

Java sucks! Period. If you want a verbose language, I suggest you to use Pascal instead. Well, every language has its own flaws, but IMO Pascal is better than Java. But for quick programming for prototyping and brainstorming, both Lua or Python (if you like OOP that much) are much better. Thankfully, I got Codea and Pythonista for that. :slight_smile:

@Bee btw, what’s up with pythonista? Omz seems to have left it aside of his scope… Isnt there any improvement to be made? Is it ‘finished’?

@jmv38: Pythonista is fine. The latest update was out just a couple of weeks ago. The development seems to be going well though not as fast as Codea. The community seems to be alive as well though not as active as here. Unfortunately, the latest Pythonista’s update requires iOS 7 which is a bad thing if you only got iPad 1, like me. That’s why I do really hope the next Codea update will not leave us -iPad 1 owners- be left in the dust. My iPad 1 still rocks. I got no reasons to buy a new one.