It's even worse than it appears.
Wednesday September 4, 2019; 10:10 AM EDT
  • In JavaScript they have const, var and let which control how things are stored. Every language has these. Using Frontier, I got used to having persistent data storage. If I created something in the object database, the kernel took care of persisting it. I could just use it like memory that was always there, and didn't have to worry about saving it to files. I find all the time I wish that JavaScript had this. I think I may have finally figured out how that might work. #
  • Here's the idea. A new storage attribute called persist. It can only apply to global objects. You could write this:#
    • persist serialnum = 0;#
  • Then you could do normal operations on it like:#
    • serialnum++;#
  • Next time the app runs it already has a value. Unlike with var or const the initialization code only runs when there is no persist object named serialnum (i.e. the first time the app runs with this value declared).#
  • It would be easy to implement this in the language interpreter. It might even be possible with proxies. I don't understand them well enough yet to know. I also think you could do it with somewhat less elegant code using an NPM package. #
  • Matt Terrenzio asks "Persist where?" My response: Somewhere. Anywhere really. Probably in a file on the local hard drive, stored in JSON. It could be in a database or in the cloud. It should be something that the developer can override, and it should default to something simple. #

© 1994-2019 Dave Winer.

Last update: Wednesday September 4, 2019; 10:23 AM EDT.