Shop OBEX P1 Docs P2 Docs Learn Events
JavaScript? Listen to .Heater! - Page 5 — Parallax Forums

JavaScript? Listen to .Heater!

1235»

Comments

  • Heater.Heater. Posts: 21,230
    @potatohead,
    ...type it right in... It's all interactive that way....
    What you are describing is what I have been doing for a long time now. With STM32 micro-controllers running the Espruino Javascript engine. Just connect to it with a serial terminal and start typing expressions, functions, etc. It all runs immediately. It can all be listed and saved to FLASH at any time.

    Kind of like the interaction with old 8 bit computers using BASIC. But vastly better.

    https://www.espruino.com/

    In fact the Esprunio's creator, Gordon Williams, has made such a retro style computer with Espruino. http://www.espruino.com/Espruino+Home+Computer

  • cgraceycgracey Posts: 14,133
    Heater. wrote: »
    Chip,
    I really like this example someone gave:
    That was me. It was Javascript.
    Maybe there could be some framework that allows those simple kinds of declarations to coexist with compiled code.
    It's not clear to me how one would do that. To get rid of type declarations one could create a language with only one type, say long, so that it never has to be specified.

    Otherwise one needs to have type information stored with every variable so that the system knows what it is at all times. Which means an interpreter or some complex byte code. It all gets big and complicated.

    Or, just use Javascript. Potentially a small JS engine, like Espruino or JerryScript, could be included in a users compiled binary program written in Spin, or whatever language. The user could interact with that. How that JS would interact with the users Spin code is another problem....

    Making things very approachable has high value. The friendlier something is, the more it instills confidence. Since I got all the hard stuff documented, and the chip is ready to synthesize, I've gone back to thinking about the high-level language tonight. I'm getting the memory usage figured out. It's going to be way better than what we've got now.
  • Heater. wrote: »
    Chip,
    I really like this example someone gave:
    That was me. It was Javascript.
    Maybe there could be some framework that allows those simple kinds of declarations to coexist with compiled code.
    It's not clear to me how one would do that. To get rid of type declarations one could create a language with only one type, say long, so that it never has to be specified.

    Otherwise one needs to have type information stored with every variable so that the system knows what it is at all times. Which means an interpreter or some complex byte code. It all gets big and complicated.

    Or, just use Javascript. Potentially a small JS engine, like Espruino or JerryScript, could be included in a users compiled binary program written in Spin, or whatever language. The user could interact with that. How that JS would interact with the users Spin code is another problem....
    Old LISP compilers used to do type inference in addition to declarations. Often you can tell the type by how something is used. If you see an expression like "a + 3" then you can probably assume that "a" is an integer. Stuff like that.
  • Heater.Heater. Posts: 21,230
    Don't forget declarations do more than specify a type. They also determine where a thing is. When you just write "a = 2" then is that "a" a local variable, a property of some object, a global?

    Whilst you can do that in JS it will make you variable global. Probably not what you want.
  • Heater. wrote: »
    Don't forget declarations do more than specify a type. They also determine where a thing is. When you just write "a = 2" then is that "a" a local variable, a property of some object, a global?

    Whilst you can do that in JS it will make you variable global. Probably not what you want.
    Yup. That's a problem. That may be another reason people find BASIC easier. At least in the original version of BASIC, all variables were global so there was no ambiguity. Not a good solution for writing anything complex though.
  • Not a good solution for writing anything complex though.

    This is fine, let them get there. When they do, they can either use the scope features in the language, or apply what they have learned to a more capable and or structured one.



  • Heater.Heater. Posts: 21,230
    That is the way I see it.

    In BASIC you can get very simple things done very simply, even interactively, instant feedback and a hook to suck you in to do more.

    Similarly for JS, Python and others. I'm told Forth is good for this.

    Later, when people get in a mess with their global variables they will be in a position to appreciate scopes and other software organizational ideas. Features that would be just clutter and confusion when they are starting from scratch.
Sign In or Register to comment.