
The Sparkling Programming Language - ingve
http://h2co3.github.io/
======
sdegutis
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](https://github.com/H2CO3/Sparkling/blob/master/doc/capi.md)

~~~
listic
So OS X can have window managers? Are there any already?

~~~
sdegutis
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.

~~~
sdegutis
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.

------
cmiller1
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.

~~~
H2CO3
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).

~~~
cmiller1
Oh! I didn't see it in the list of operators on the tutorial so I assumed it
didn't.

~~~
H2CO3
No problem – documentation may still be somewhat incomplete at some places,
sorry for that.

------
d08ble
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...](https://github.com/d08ble/acpul-
demo/blob/master/atests/test.storage.acpul)

~~~
i336_
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

~~~
d08ble
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.

------
joshbaptiste
Looks great and straight forward, just need a syntax.vim plugin and off to
races with Sparkling for me.

------
any1
Does it have GC? Or does it perhaps use reference counting? Can it detect
cyclic references?

~~~
sdegutis
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.

~~~
H2CO3
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.

~~~
sdegutis
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.

------
nikolay
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!

~~~
H2CO3
I can remove that option at any time, if it turns out to be an important
enough issue :)

~~~
johnmaguire2013
And you'll break backwards compatibility with every app written prior.

~~~
H2CO3
Yes, exactly. So this should probably be decided early.

