Programming the Photon in JavaScript

But that option does not exist.

To take your illustration, imagine your language is a non-written one, you’d never be able to finish that book after all (unless you’re thinking of audio books ;-)).

And you are not going to write a book but rather something like a quick post in a forum, for that it’ll do. (I’m not writing this in my own laguage, but for the sake of broader understandability, I do it in the common language of this forum :wink: )


Have you seen the mistakes, they happen, but don’t harm - and could even be corrected (which I chose not to do for the illustration)

But boy, once you figure out that language, man, then you can write some really good books. Imagine having to write your book on a typewriter with chopsticks. If you’re used to that, then great. But you’ll be so much faster once you get the hang of a computer :wink:
It’s not that JavaScript isn’t nice or anything (I’m using it as well), but it serves a different purpose. C/C++ is much more suited for hardware like this, in which speed and optimization are precious. I’ve seen endless discussions about people needing to make certain pin functions several nanoseconds faster. For that, you need a low(er) level language.
Like @ScruffR mentioned, it’s not so much about the language as it is about the way you think and engage problems. Most programming languages share a lot of similarities, but differ in implementation. If you have a general idea how to approach a problem, you’ll find your way regardless. Like I said, there are SO many Arduino examples available, that make it so much more easy/interesting to learn wiring/C/C++, that makes it really worthwhile.
Don’t give up before your tried it. The Core was my first microcontroller, and for the biggest part of the time, I still haven’t got a clue as to what I’m doing. The willingness to learn, and put in effort is what makes the difference. If you’re willing to learn it, then you will, be it with help from the community. Just give it a shot. What’s the worst that could happen, you end up liking it? There’s not much to lose…

2 Likes

That is a really great point. Since you know and use JavaScript would you use the Tessel 2 or the Espruino Pico? I like the Pico because it is small and uses less power than the Tessel but I like the Tessel 2 because it is faster and has wifi and ethernet built in but it uses more power and I don’t want to have to deal with linux when I am trying to program a microcontroller.

I would add… if you challenge yourself to learn C, you can learn any language. From my experience [of hiring developers], whoever get grasp of C’s pointer arithmetics can make real good programmer. And since you know JavaScript, C++ or Object Oriented Programming in general should not be an issue for you (although JS’s “prototype inheritance” is somewhat different from what I call “standard OOP” as in C++).

On the other hand, if you do not wish to pursue programmer’s carreer, you might go better with skipping C/C++ and sticking with what you know. If you wish though, I would strongly recommend to at least try. After all, there is more than one way to skin the cat, as they say.

Not sure if theres a lib to do IR decoding yet, but the WOL part should be simple enough, sadly I dont have a testsubject here, so havent been able to verify the code below other than it compiles.

UDP Udp;
Udp.begin(9);
Udp.beginPacket({255,255,255,255}, 9); //Broadcast
uint8_t packet[120];
uint8_t x = 0;

packet[x++] = 0xFF; //Sync stream, 6xFF
packet[x++] = 0xFF;
packet[x++] = 0xFF;
packet[x++] = 0xFF;
packet[x++] = 0xFF;
packet[x++] = 0xFF;


for (uint8_t i=0; i<16; i++) //16 repetitions of the target mac address
{
    packet[x++] = 0x12;
    packet[x++] = 0x13;
    packet[x++] = 0x14;
    packet[x++] = 0x15;
    packet[x++] = 0x16;
    packet[x++] = 0x17;
}

//optional password 4 or 6 byte
/*
packet[x++] = 0x17;
packet[x++] = 0x17;
packet[x++] = 0x17;
packet[x++] = 0x17;

packet[x++] = 0x17;
packet[x++] = 0x17;
*/

Udp.write(packet, x); //102 106 or 108bytes depending on password
Udp.endPacket();