What is squirrel?

Hello there,

can someone explain to a noob why electric imp uses squirrel-lang? For me as a beginner, it is poorly documented and everywhere I read, the same sentence is being repeated: "Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games."
I always thought, programming and scripting are two completely different things. Second, I’m not programming a game engine - I want the light in my kitchen switched from the internet.
So, why not just use something like C or C++?
Please explain or point me to a thread where this has allready been discussed.

Regards
leo

We chose Squirrel very much because it’s a scripting language – the idea being that, just like the situation with scripting video games, many developers will not be software experts (in our case, they’re more likely to be hardware experts), and there’s a lot of value to be had in making the software side of things easy to use. Which, in turn, means making it hard for people to mess up; which, in turn, means running an interpreted scripting language so that the interpreter itself can sanitise what’s going on – for instance, by reporting runtime errors in our web IDE rather than by just crashing, which is the usual result of a bug in a C or C++ program.

Peter

hi leo,

I do not know the “why” to your question but maybe I can offer an opinion or some help. I am not a professional software guy; I know VB6, a bit of C# and in the last few years used Arduino and learned to use the datasheet of the chip to set up timers and interrupts in Arduino.

I have come to prefer the imp product for some applications and I have managed to figure out what I need in Squirrel language. I agree that the documentation of the language is poor or perhaps too technical for me. The documentation of the imp API is better.

To me the advantage is that it is a higher-level language and I do not have to use the datasheet of a micro to use it. There are some applications where this is a problem, such as tracking interrupts at high speed or other situations in which you are desperate to know precisely what the micro is going to do.

Some things that I have learned the hard way:

  1. When you declare a global variable, do it this way.

myglobalvariable <- 3.0; //Declares a floating point
myglobalinteger <- 5; // declares an integer

//after declaring them with this notation, use normal syntax.
myglobalinteger += 1; //increment.

  1. use the keyword “local” only in functions, not globally.

  2. there does not seem to be any way to make a static variable in a function. I use globals for that or else create a class.

here is one link that will help

http://devwiki.electricimp.com/doku.php?id=writingefficientsquirrel

other than that, the best approach is to dig through the examples.

Hey guys,

thanks for the explanation. I allready have some things working by digging through the examples.

leo