I’ve been trying to learn C to be able to create apps for my PT2 when it arrives. I though i would give it a shot, as I already know quite a bit of python, but it’s reaaally hard for me to wrap my heard around the rigidity and strict typing, pointers and stuff. I’ve been devouring tutorials and documentation, but this language doesn’t click with me.
The announcement of the javascript SDK made me wounder if I should switch to learning that instead. It seems a lot easier, but I have a lot of negative preconception against it : I believe that it will be less resource efficient, need more memory space and consume more battery.
Are these belief justified ? What would be, if any, the impacts of use Javascript rather than C on my pebble watch ?
Because if they are small enough, i’m gonna switch languages.
Thanks for your answer. However I’m not sure what conclusion to reach with your input.
I’ve taken a look at CloudPebble, and the platform looks great. However, just tweaking code I don’t understand doesn’t feel right to me. I believe that by doing so, i’ll eventually encounter road block that I wont be able to overcome, or that i’ll write poor and underperforming code. Plus, my whole purpose for getting a hack-able watch is to actually master the beast, and just whacking code into place defeats that process to my eyes.
So my point in knowing how Javascript compares to C is to decide if i should persevere in C, or if javascript would allow me to reach a good understanding faster. The syntax of the later seems to suit my hobbyist brain better.
I think it’s worth it to try both. Do you want to make apps for the older hardware too? Currently Alloy only supports the latest two watches (the ones that haven’t shipped yet) with support for the 2 Duo arriving At Some Point™ and with none of the original Pebble watches being supported. With C, you’ll be able to write for every platform. Though if that doesn’t matter to you, try out JS! There’s no harm in learning more things
It has been my experience that learning how to do something in a new programming language will improve my ability to do something similar in a more familiar language. In your case, learning both C and JS will improve your C, JS, and Python skills.
If however you want to focus on just 1 language, I would second @Flynn‘s suggest of sticking with C. Writing apps for PebbleOS is my first real-world experience with C, and because the end result is targeting what is basically an embedded system with limited resources, the static typing of C makes for a more efficient application.
Thanks, your opinion on static typing on embeded systems is a great input.
I understand the value of learning more things. However I’m new to both C and JavaScript, and coding is a skill I enjoy but do not use in my everyday life. I don’t have the time to learn both and have to start somewhere. Hence my question about performance.
If anyone has a benchmark, or if any dev could provide tips about it, i’d love it.
IMO JS is more lenient, and easier to learn because of that. If you dont’ have a preference between the two and all you want is to start making watchfaces/apps quickly, I would learn JS. If in the future you decide you want to support all the watches, I think you’ll find it easier to learn C having learnt another language first.
In terms of language benchmarks, the only truth is the one that you can prove yourself on your own machine. However, an often cited resource is the Vercel benchmark site. Here is the comparisons between C and JS: C VS Javascript benchmarks, Which programming language or compiler is faster. You’ll see that C beats JS in every benchmark in execution time.
This site also makes comparisons for memory usage, where JS memory usage is much larger than C memory usage for all benchmarks. I don’t know the numbers on the Pebble firmware, but a JS app will use more memory than a C app on any device. So if you plan on building something substantial you might want to focus on C.
Both of these results are consistent with what you will find between a compiled language (C) and an interpreted language (JS). The benefit of higher level interpreted languages like python or JS is that they are often easier to work with compared to lower level languages like C.
If you want to move fast, you are better off sticking with JS. If you want your machine to move fast, you are better off sticking with C.