develop an external in C or Java or Lua?

WilhelminaFHole's icon

I'm thinking about writing an external that runs a couple of FFTs and some other processing in OpenGL and I'm not sure of the best approach. I have zero experience with C and Lua, but a fair amount with java (and processing) so I have a couple of questions. Is the performance gain from working with C going to be worth learning how to use it? I generally prefer scripting jitter and have done it with JS, so how steep would the learning curve for learning Lua be? and finally since hopefully all of the heavy work will be done in GL should I just stick with Java?

arcadiadivine's icon

Warning: I skipped over your first sentence by mistake so some of my long post won't apply. Sorry!
Question: I don't know much on either language but have you tried searching for free tutorials in C or Lua? You'll know real quick if you want to learn either language by reading some of the free tutorials offered. I'll post some links at the end of my long post.

On one end, one of the developers on the Csound (audio language like max but textual) list (if I'm not misquoting him) said that LuaJit is faster in some areas than optimized C. Of course, all that depends on if you can use LuaJit to develop an external in the first place, though I don't see why you couldn't.

On the other end C is pretty much the father to quite a few languages and it's still powerful after all these years even though it seems to be slowly getting replaced by C++ (at least from the bit of research I've done). If I recall correctly, Lua is written in C anyway but I could be wrong so someone feel free to correct me if I am off on that.

Right in the middle you have Java, which you say you already know. If you can do the same thing with Java as you eventually will be able to do in C or Lua then there may not be much of a point in switching if you aren't programming complex externals.

Personally, without knowing what you plan on developing it might be slightly hard to answer the question regarding performance gains. In my opinion, if you plan on developing complicated or resource heavy externals than you may be better off switching. What I recommend you do is try Java first considering you already know the language and if you don't get the desired results no matter how hard you try than that's probably the cue to switch.

As for the learning curve for Lua, I didn't think it was too steep but I haven't done much with the language yet. The only thing I have against learning Lua is the lack of books available. Comparing the available learning resources of C versus Lua, C wins without a doubt because it's been around forever.

Edit: On second thought, if you plan on programming with OpenGL then there might not be much of a point in learning C considering the language isn't object oriented anyway. I might be wrong on C's inability to deal with OpenGL though, you never know. If I were you I would stick with Java or learn Lua. I found Lua much easier to learn than C but your case could be different.

Here are some links to learn Lua and C:

WilhelminaFHole's icon

Thanks for the detailed response! I had no idea that C clashed with OpenGL so thanks for that tip. The first draft of the project is a youtube video betterifier and a christmass present for my girlfriend so I'm kinda stuck with JS for now and for the moment it seems to be fine but as the project progresses it's going to have to run fft on three different sets of video data. Needless to say, investing in a new gpu and learning a higher performance language are on the to-do list and after reading yer post it's looking like Lua is gonna be the one. So really, thanks again for the post!

One of these days I'm going to take the time to learn C but I'd like to have this project ready for field testing by the summer

vichug's icon

uh ? problem between c and opengl ? first time i hear that... or maybe it's because the frontier between c an c++ is so thin that i did not notice opengl is c++ exclusively, and not c at all. I thought opengl was, like, a c library...

WilhelminaFHole's icon

yeah, just looked that up and C can use OpenGL... still not gonna go outa my way to learn C just yet though

arcadiadivine's icon

Yeah, sorry I was wrong on C and OpenGL. I would've said something sooner but my internet went down.