29 comments

[ 18.4 ms ] story [ 1153 ms ] thread
The link compares it to Lua. Further reading reveals several improvements over Lua (IMO):

- "var", "let", and "extern" means no more accidental globals

- Arrays are separate things than Hash-maps

- Simple C API [1] that's not stack-based

- More built-in operators (even the conditional operator ?!)

- More "traditional" object/class concepts

- Strict typing!

- Fuller standard library

Neat!

My next project may very well be a Sparkling-scripted window manager for OS X.

[1]: https://github.com/H2CO3/Sparkling/blob/master/doc/capi.md

So OS X can have window managers? Are there any already?
Kind of. You can do it with Apple's Accessibility APIs, but lately they're making that harder and harder. Apps that use those APIs can't be put on the app store, and there's no automated way to give an app permissions to use Accessibility: the user has to go deep into the System Preferences panel to enable it. And even then, the APIs, which aren't quite meant for window-managing, are very limited and sometimes don't work like you'd want them to. I forget how specifically, but I've written about a dozen of them so far and it's not a super pleasant experience. It's a little nicer in Swift, because you get to wrap the ugly C APIs in Swift using generics.
Also, iTunes tends to crash your program if you try moving/resizing it via Apple's Accessibility API if you're playing a video in it.
Technically you can run any of the window managers you use for Linux or BSD on top of X11, but you can only run *nix software, not Mac specific software, in those windows.
> Arrays are separate things than Hash-maps

I think this was a very elegant solution for Lua and ads to it's simplicity

I threw together a quick, naive, FizzBuzz in it on their online demo, was surprised to find that it doesn't have a modulus operator. Can anyone come up with something simpler?

  let divisible = fn (x, y){
    return (x-(x/y*y))==0;
  };
  for let i=1;i<=30;i++ {
    if divisible(i,15){
      print("FizzBuzz");
    }else if divisible(i,3){
      print("Fizz");
    }else if divisible(i,5){
      print("Buzz");
    }else{
      print(i);
    }
  }
Edit: Correction, apparently it does have a modulo operator.
Hi, author here. Sparkling does have a modulo operator, it's spelled '%', just as in C (in fact, it maps directly to C's % operator).
Oh! I didn't see it in the list of operators on the tutorial so I assumed it didn't.
No problem – documentation may still be somewhat incomplete at some places, sorry for that.
Does it have GC? Or does it perhaps use reference counting? Can it detect cyclic references?
The readme seems to suggest it uses reference counting and doesn't do anything special about reference cycles:

> Another thing is garbage collection. It seems to be the silver bullet of automatic memory management when it comes to scripting languages, but it has some definitive, serious downsides. Non-deterministic behavior is one, speed is two, memory overhead is three, the difficulty of a decent implementation is four. Reference counting is a simpler approach that is more lightweight, easier to implement, completely deterministic and it has no memory allocation overhead (a program uses only as much memory as needed). Refcounting has its disadvantages too (e. g. memory leaks caused by cyclic references), but I believe that its good properties outweigh them.

How is reference counting deterministic in a multi-threaded environment?
in the sense that an object is deallocated as soon as all pointers to it cease to exist.
Exactly, Sparkling uses reference counting, and one of the major TODOs is the introduction of weak references in order to address the issue of cycles.
Implementing weak references sounds like a feature that will make the language's source code much more complex than the simplicity emphasized in your goals.
nim has some sort of automatic cycle detection. You might want to look into how they do it. It doesn't hurt to check it out.
Excellent! I was hoping that the answer would be that there is no GC.
Why are parentheses optional for functions? The big thing one can borrow from Python 3 is that there should be one way of doing something to save the community the endless unproductive fights of which one of the many ways of doing something is best!
Meh. I'll take "too many syntax options" over "too few stdlib functions" any day. (I'm looking at you Lua!)
I can remove that option at any time, if it turns out to be an important enough issue :)
And you'll break backwards compatibility with every app written prior.
Yes, exactly. So this should probably be decided early.
I think having multiple options is always a bad idea for a language. It complicates the syntax and make people ask why not make parenthesis optional for loop statements as well? Then they perceive this as imperfect design - consciously or not. To me personally, this looks like a patch put in place just to entertain the Ruby crowd and is not along the lines of the solid unambiguous syntax that you're striving for!
Ideas looks like ACPUL. ACPUL is simple & easy algorithmic declarative language. It based on C-like languages syntax & sugar-free without noise, designed for minimalistic coding on mobiles.

Code sample: https://github.com/d08ble/acpul-demo/blob/master/atests/test...

This repo can haz README.md? :P

Seriously, this looks really interesting, but "firehose of code!!1" is generally ideal for dispersion, not retention, and when combined with "ooo, I want to try this" results in a small sense of panic :P

Please provide your iOS DeviceID to PM (encrypted, shure). I can make build for your personal demo. My native language is so bad, I'm autistic, pls understand me. Thanks.
Looks great and straight forward, just need a syntax.vim plugin and off to races with Sparkling for me.