26 ms·
The Sparkling Programming Language
- sdegutis 11y agoThe 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 11y agoSo OS X can have window managers? Are there any already?
- sdegutis 11y agoKind 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 11y agoAlso, 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 11y agoTechnically 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.
- CyberDildonics 11y ago> Arrays are separate things than Hash-maps I think this was a very elegant solution for Lua and ads to it's simplicity
- cmiller1 11y agoI 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 11y agoHi, author here. Sparkling does have a modulo operator, it's spelled '%', just as in C (in fact, it maps directly to C's % operator).
- any1 11y agoDoes it have GC? Or does it perhaps use reference counting? Can it detect cyclic references?
- sdegutis 11y agoThe 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.
- wofo 11y agoHow is reference counting deterministic in a multi-threaded environment?
- H2CO3 11y agoin the sense that an object is deallocated as soon as all pointers to it cease to exist.
- H2CO3 11y agoExactly, 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 11y agoImplementing 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 11y agoWhy 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!
- sdegutis 11y agoMeh. I'll take "too many syntax options" over "too few stdlib functions" any day. (I'm looking at you Lua!)
- johnmaguire2013 11y agoFalse dichotomy?
- H2CO3 11y agoI can remove that option at any time, if it turns out to be an important enough issue :)
- johnmaguire2013 11y agoAnd you'll break backwards compatibility with every app written prior.
- H2CO3 11y agoYes, exactly. So this should probably be decided early.
- nikolay 11y agoI 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!
- d08ble 11y agoIdeas 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.storage.acpul https://github.com/d08ble/acpul-demo/blob/master/atests/test...
- i336_ 11y agoThis 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 11y agoPlease 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 11y agoLooks great and straight forward, just need a syntax.vim plugin and off to races with Sparkling for me.