Max vs. Java vs. JavaScript (speed)
Sorry if this has already been discussed somewhere, but I couldn't find it searching.
I know in general the same action coded in C versus Max will be faster in C and that because of the JVM, C will be faster than Java. I was wondering if anyone has any info on the speed of Java vs. JavaScript vs. Max doing similar tasks. I know I've had some ideas that would be easier to code Java/JavaScript than in Max, but I am a little lost on how to decide which language to write an object in (if you can't tell, I have some background in Java/Javascript/C, but am only just starting to get into Max object development, so sorry if this is a common noob question).
On Mon, Aug 4, 2008 at 2:59 AM, Roth Michaels wrote:
>
> Sorry if this has already been discussed somewhere, but I couldn't find it
> searching.
>
> I know in general the same action coded in C versus Max will be faster in C
> and that because of the JVM, C will be faster than Java. I was wondering if
> anyone has any info on the speed of Java vs. JavaScript vs. Max doing
> similar tasks. I know I've had some ideas that would be easier to code
> Java/JavaScript than in Max, but I am a little lost on how to decide which
> language to write an object in (if you can't tell, I have some background in
> Java/Javascript/C, but am only just starting to get into Max object
> development).
>
>
For starters I have to say I'm not as experienced with Java as I am with
C/C++ so that's likely to make my opinion more biased than needs to be.
Apart from what language you prefer to work with, I think the right choice
depends on what kind of processing you're doing. Java can be pretty equal to
C in terms of speed, as long as you don't frequently have to cross the Max/C
JVM boundary, cause that's relatively expensive. If you write externals
that do a lot of i/o or number crunching, C will probably be faster by a
fair amount.
I don't use Java because I personally don't like the language and prefer to
have full control over things like memory management. Also I don't have a
use for the extensive library that often makes Java a popular choice. I do
like to work with classes and inheritance and all that, so that's why I use
C++ for most of my externals now, using variations on Graham Wakefields
template approach.
I used to use Javascript mainly for Jitter related things and I'm very happy
to have replaced all that with Lua. I don't think I'll ever look back:) I
have found Javascript in Max to be annoying, slow and even unreliable at
times. I won't use it for anything other than very basic scripts /
prototyping.
The choice is really yours to make, and I don't want to start a heated
language discussion (you can find plenty of Java vs C etc discussions
online) but my personal choice would be:
- High performance code without compromise: C/C++.
- Simple prototyping / patch logic : javascript or the 3rd party
alternatives that I don't have any experience in (lisp?, etc). Possibly
there will be a Lua option for this in the near future.
- Anything OpenGL / Jitter : jit.gl.lua.
- There is also the option to use Lua for audio/synthesis: lua~
If you're coding less speed/time critical things, and you find good use for
the extensive Java libraries, go for that if you can be bothered to learn
the language.
I choose to focus on C/C++ and Lua. One for ultimate performance and the
other for dynamics / flexibility and ease of use. They are both very good at
what they're designed for, complement each other nicely, and also play well
together. With these languages I currently don't feel a need for anything in
between. For me Java is something halfway in between performance and
flexibility. I guess some might argue that's a strong point.
It will take some time and effort to become really comfortable with C/C++
and the Max SDK (I expect the upcoming Max5 SDK might simplify certain
things a bit), but once you're there it can be fairly easy and fast to code
externals. Of course your mileage may vary.
If you're mainly working on Mac you can also look into the ObjC framework
Tim Place just released. I don't have enough experience with ObjC to make
any claims about it but it certainly looks interesting to me. Afaik you can
compile externals written in ObjC for Windows as well.
My 2c,
Thijs
I would be interested on more feedback on this subject
thank you
Emmanuel
I'm not sure which part of the thread you are interested in, but I can comment on one thing Thijs said. ObjC on Windows is a total disaster. I can't recommend against it strongly enough. I wasted a lot of time on that, so now you don't have to ;-)
Hello Timothy:
I am working mostly with jitter so my curiosity was mostly about the speed performance. I have been using java and javascript for doing some basic matrix calculations and i have the impression that javascript is considerably slower when it comes to cpu usage. At the same time, i think that c is still the best option. So i would gladly listen the opinion of more experienced users.
Thank you
Emmanuel
JavaScript is slower than Java indeed, and Java is slower than C. That's in term of CPU/memory usage. In term of development time, it's about the inverse, but that's just depends what you're trying to do. Unlike the general feeling about Java, it's quite efficient, however the bridge between Max C land and Java is the bottleneck. So advice would be to stay in the same language as much as possible, and avoiding going back and forth which is something which costs.