10 ms·
Gravity: a new programming language and VM written in C
- sandbags 10y agoIt doesn't support logic programming. They weren't even trying.
- d--b 10y agoHas anyone tried this CreoLab thing? Any comment? Here's the main use case: http://creolabs.com/gravity http://creolabs.com/gravity
- chncdcksn 10y agoMay be off topic, but did Apple remove their restriction on using a VM in an app put on the App Store? Or was that restriction only for JITs and not interpreters?
- lobster_johnson 10y agoThat was about JIT, i.e. generating native code.
- Vendan 10y agoAlso about interpreters, at least on iOS side, and they have relaxed that slightly, though interpreters are still banned from running downloaded code
- salimmadjd 10y agoI just downloaded their beta version. Here's a direct link if you don't want to subscribe to their email: http://creolabs.com/creo_beta_download http://creolabs.com/creo_beta_download
- ams6110 10y agoI'm interesed also, in how it compares to Corona. Corona uses uses Lua (which seems similar to/inspirational for Gravity).
- snackai 10y agoGreat, just what we needed, another programming language.
- macintux 10y agoPretty sure we had all the programming languages we needed by the late 80s. Nonetheless, we need new perspectives on languages more than we need snark.
- bpicolo 10y agoSays it supports Functional programming, but I don't really see functional features. Seems premature? I see what the goals of Gravity are, but are there any reasons I want to use it? Side note: not a huge fan of implicit self, i.e. class methods automatically referring to "y" as the instance variable "y". I realize c# and Java do it, but worrying about name elision at all is something I'm not a fan of. From an ergonomics perspective, it makes editor autocomplete features slightly worse, as a prefixed "this" or what have you can give it additional context vs "anything in scope"
- Vosporos 10y agoSomeone need to write a functional language for that VM :p
- Tloewald 10y agoIt supports closures and higher order functions. The sample code doesn't show any of it. It basically looks a lot like a subset of Swift designed to allow someone familiar with Swift to get going faster with Creo. Creo looks interesting mainly as a better integrated development experience than XCode provides.
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- catnaroek 10y agoClosures and higher-order procedures do not a functional language make. It has to be convenient to implement procedures that compute actual mathematical functions. Assume there exists a (pure) function `f` and a list `xs`. Does the following expression always return `true`, or, at least, never return `false`? map(f, xs) == map(f, xs)
- tomp 10y agoBy this criterium Ocaml isn't functional either. Hell, even Haskell's not!
- traviswingo 10y agoFor those being negative about "yet another programming language," try creating a lang sometime...it's a fantastic exercise and, in the very least, will make you a much better programmer.
- FascinatedBox 10y agoI have (still am), and I wholeheartedly concur. It's difficult but extremely rewarding.
- wry_discontent 10y agoI don't understand that mindset. What's the alternative? Nobody creates any new languages? Only corporate giants should create new languages? It seems like a pervasive anti-intellectual attitude.
- goatlover 10y agoThere's probably thousands of languages in existence, with new ones being created all the time. Sure, if you're doing it as an exercise, more power to you. But if you're trying to get other people to use your language, the natural response is why should I bother with yet another language? I already don't have time to learn the the ten languages I'm interested in learning that already have a following.
- kordless 10y agoPeople have a right to their opinion, and people have a right to oppose other's opinions. I question whether people have a right to continue to argue about such an opinion in a way that spreads virally, however. One good technique for spreading irrationality virally is to ask leading questions which continue the "debate" about something that really isn't that important. We have programming languages, they are often times hard to learn, and learning new ones, or making new ones, is something only a subset of the programming aggregate can and are willing to do. i.e. It's an important topic for a few, but for the rest of humanity, it really doesn't matter that much day to day. (Which is not to say a new language might eventually be useful to all, but that argument itself is irrational given it may occur in the future.) I'm only calling out this argument here because I find this general viral behavior is occurring around other concepts in a way that is creating inefficiencies in communication channels - something we didn't really intend when building the Internet.
- andrewmcwatters 10y agoI'm totally biased since I love Lua and C, but this language looks great. Really loving what it's putting down. Edit: What's downvote worthy of this comment?
- corysama 10y agoYep. Lua is the standard for embedded languages. But, this does look quite nice. A big question is: How does performance compare?
- ternaryoperator 10y agoCan only speculate about the downvotes that perhaps "putting down" is being read in its traditional meaning, which might give your whole note a sarcastic feel. Other than that, I have no idea.
- chc 10y agoSince you asked: This comment is pretty insubstantial. There's no comment on what's good or interesting about this language, just "really loving what it's putting down," which is pretty inscrutable as praise goes.
- dualogy 10y agoQuite promising: clean-looking syntax, little overhead, portability seem to be driving motivations. Especially the following feature could promise adoption and momentum: dynamic typing (not a fan myself, but for scripting: OK --- would be great if all such languages had a statically&strong-typed option --- after all the compiler/JIT needs to guess/work much less) higher order functions and classes coroutines (via fibers) closures garbage collection operator overriding powerful embedding api Very neat-sounding. Will have to keep watch. Not as low-level as Go (can become wordy!), not as "foreign" initially as Rust (what, no GC, borrowing, a borrow checker, what?), not (yet!) as "haphazard" as... the majority of shell-scripting/server-scripting/client/web-scripting approaches.
- SomeCallMeTim 10y agoFor simple apps, dynamic typing may be OK, but I'm always writing complex apps, and static typing just seems like a minimum required feature for any language I want to use for complex apps. So I guess I'll stick with TypeScript or C# for writing my cross-platform apps. The ecosystems for both are much more robust anyway.
- dualogy 10y agoI think a problem is that complex apps are made with scripting languages. This nasty practice seems to have finally become widespread habit in earnest with Perl in the hey-days of CGI httpd, and then of course came along Python and JavaScript and here we are! I agree that strongly & statically typed languages allow for and indeed yield more robust ecosystems and complex apps. But scripting languages have their place, roughly at the level of bash/.sh/.bat scripts IMHO .. the issue is that as LoB apps evolve from "simple one-off experiments" and "just a quick'n'dirty prototype to see if-and-how" to "mission-critical infrastructure" there just seems to never be a good time for anyone to say "we stop here, let's transfer this to a more stringent language early on first now, better today than too late". Best would be if "scripting languages" actually had Haskell levels of type inference, even if not the rich type system, this way there wouldn't be type annotations (just like in scripting) BUT with a toggle-able "scripting-like lenience" that can be turned off to make the type-checker brutal, or initially during prototyping/scripting turned on by default to allow for ambiguous / uninferable / defer-to-runtime-and-allow-unsafe-conversions RAD-style work. With an additional middle-ground setting where it's still lenient but emits console warnings to review potentially troublesome sections. Someone should create a whole new scripting language just for that! Any takers?
- geofft 10y agoThis looks like a language designed for use with a commercial product / development environment (http://creolabs.com/ http://creolabs.com/). I'm curious how well that works - I know that used to be fairly common in the '80s and '90s, but it feels like that hasn't been happening much of late. The only very similar examples I can think of are Swift and Xamarin; Swift had the advantage of a large customer base (everyone writing iOS apps), and Xamarin was based on an existing, well-established language (C#). And all the older big examples that come to mind, VB, Delphi, Objective-C, etc., were variants of an existing language (Basic, Pascal, C, respectively), not a brand new language. Creo folks, are you finding that customers / potential customers are excited about picking up the new language? I'd love to live in a world where there's more work on programming languages (clearly, none of our existing languages are optimal) but I'm not super optimistic.
- aninteger 10y agoIt looks nice but... How do you call into existing C libraries? I didn't see an example of that.
- emsy 10y agohttps://marcobambini.github.io/gravity/api.html https://marcobambini.github.io/gravity/api.html Unfortunately, the reverse isn't covered yet (calling Gravity functions from C).
- JCDenton2052 10y agoWhat problem does it solve that is not solved already? What does it do better than it is done today?
- dbattaglia 10y agoWhy does it have to do either of these?
- carterehsmith 10y agoThere is like 5,000 programming languages around. If you "just" create another one, without any novel contribution to the "languages" domain, you are basically just creating noise. Nobody will use your language and nobody will write about it. So.. .what is the point?
- whistlerbrk 10y agolearning, but you're right about adoption of course
- Lazare 10y ago"Hey, want to buy a car?" "Maybe. What color is it? Manual or automatic?" "Why does it have to be a manual?" It doesn't have to be anything, but I'm not going to buy a car (or invest time looking at a new programming language) if you don't even tell me what it is. As others have noted, the design goals of the project make it sound like Lua would have worked quite well for them. They didn't pick Lua, so it suggests their project has some advantages over Lua. They don't need to justify their decision, but if it does have advantages over Lua, it would be interesting to know what they are. And even if it doesn't, it would be interesting to know why they made the decisions they did. The point of asking questions is to find out the answers; it doesn't mean we're all prejudging them based on the assumption their answers are going to be terrible, or even that the answers might be terrible. It's okay to start a project just because you want to!
- spc476 10y ago
- hubert123 10y agoIt looks good, but no word on performance numbers or debugger or IDE.
- weberc2 10y agoHow does the feature set differ from [Wren][0]? Also, the syntax reminds me a lot of Go. [0]: https://github.com/munificent/wren https://github.com/munificent/wren
- jlebrech 10y agoI've been looking for an embeddable language other than Lua to use in an ncurses app.
- kibwen 10y ago> Swift-like syntax But the example doesn't show any Swift-like syntax... except for `func`. Other than that, this is a dead ringer for Javascript.
- seibelj 10y agoCross-platform embeddable VM language written in C for iOS and Android? Strange, I've been doing this for years using Lua...
- chrisseaton 10y agoWhy are you being so sarcastic? I don't think they claimed that you couldn't do it before.
- chc 10y agoThe only explanation of its intent in the readme is that it was created "in order to offer an easy way to write portable code for the iOS and Android platforms." I think the parent comment was pointing out, in a sideways manner, that they didn't need to create a new language to do that, so it's somewhat mysterious what this is actually meant for.
- chrisseaton 10y agoThe parent comment said 'strange...' as if they had claimed that nobody had done it before, and therefore it was strange how he was doing it. But they hadn't claimed that. So what is strange? If a new bakery opens in my town I don't say 'strange... I've been buying bread for years'. It's an alternative offering. You may say it's not necessary, but it's not strange. That just doesn't make any sense as a snarky remark in this situation.
- chc 10y agoIf somebody asked why Hypothetical Dave opened a bakery and Dave answered "So this town would have a source of bread," I think it would be reasonable to find that strange. He isn't explicitly saying nobody has done it before, but the answer is weird if it's already been done. I mean, creating an unnecessary programming language isn't strange — it's extremely common, and some are even good. But providing a rationale for creating the language that doesn't explain why you created the language is a bit odd, isn't it?
- 10y ago
- eternalban 10y agoWell, they have an excellent 404 page: http://creolabs.com/404.html http://creolabs.com/404.html
- Entangled 10y agoWouldn't this be better served with defaults? // constructor func init (a, b, c) { if (!a) a = 0; if (!b) b = 0; if (!c) c = 0; x = a; y = b; z = c; } Like func init (a=0, b=0, c=0) { x = a; y = b; z = c; }
- pmontra 10y agoYes, but I guess it's only an example to demonstrate one liners and anything would do. I prefer not to have to surround conditions with () and terminate statements with semicolons. Plenty of languages demonstrated that it's ok. However I don't know how that impacts the complexity of the compiler. I used to know how to write one and reason about it but I spent my last 25 years doing other things. Nice touch to be able to do func + (v) { ... }
- spc476 10y agoIn Lua, this would be: function init(a,b,c) local x = a or 0 local y = b or 0 local z = c or 0 end "and" and "or" short circuit evaluation in Lua; nil and false are false, everything else (including 0) is considered true.
- marcoms 10y agoWhat's the argument for required brackets around if (conditions) and switch (conditions)? To me they seem redundant. -- As a side point, I hope switch statements are less like C and more like Rust (Rust happens to have better looking syntax, not just because its Rust): match <identifier> { <val> => { // } .. } C-style always creates confusion on how to indent blocks following case statements
- yarrel 10y agoThe argument (which I agree with, although it can be a pain to adopt at first): http://wiki.c2.com/?AlwaysUseBracesOnIfThen http://wiki.c2.com/?AlwaysUseBracesOnIfThen
- tekacs 10y agoWhat you linked is about braces around the /body/ of an if statement. What the GP poster was talking about was parentheses around the /conditions/ of an if statement. Note that Rust (for example) doesn't require the latter. In fact, if you always require braces (as in the post that you linked), then it's very easy to parse and read code which is lacking those parentheses on the condition. i.e. `if (condition) x = x + 1` would be hard to read without parens. but `if condition { x = x + 1 }` (with mandatory braces) is quite clear.
- weberc2 10y agoThe GP said brackets, not parens. Perhaps he misspoke?
- david-given 10y agoAh, yeah. I didn't twig until you mentioned it, but... if ever you get tired of emacs vs vi religious wars, try switching to discussing whether 'bracket' refers to a parenthesis or a brace. Given the context, I'm pretty sure the OP was using the 'parenthesis' meaning.
- chch 10y agoFor a short moment, I hoped that this was about a revival of one of my favorite non-Turing-computable esoteric programming languages, but I guess that's of pretty low probability! Unfortunately the original spec is long gone, but [1] at least mentions the gist: [1] https://esolangs.org/wiki/Gravity https://esolangs.org/wiki/Gravity
- pkd 10y agoI think the main value of this project is hidden under the "internals" link of the site. It discusses the construction of the language. Although it is incomplete as of now - hopefully the pages get filled up. https://marcobambini.github.io/gravity/internals/ https://marcobambini.github.io/gravity/internals/
- gct 10y agoHow's performance compared to eg: Python?
- deleted 10y ago[deleted]
- popobobo 10y agocan we stop producing languages and focusing on improving the old ones?
- pavfarb 10y ago"built-in JSON serializer/deserializer" near "closures" and "coroutines (via fibers)" feels a bit.. odd. Sign of the times, I understand, but still. Apart from this boring grumbling, the project is very interesting. Waiting for internals (https://marcobambini.github.io/gravity/internals/index.html https://marcobambini.github.io/gravity/internals/index.html) to arrive.
- adrianratnapala 10y agoI think languages should have built in help for serialisation, though not tied to a particular format. This is to get around the tension between automating the process (avoiding boiler-plate) versus "gating" to validate and transform data as it enters/leaves the domain model. All serialisation frameworks I've seen map internal record types (structs, objects) to an external schema, and write directly to record fields -- breaking down that "gate". What I would like is to map those schema to something like a constructor/factory parameter list instead. (Python keyword arguments come close, but the lack of typing means there is still no schema). Serialisation libraries should confine themselves to converting between (typed) key-value pairs and wire formats. Then there should be syntactic sugar to help the transition between that plain-old data and the real domain model.
- scott_karana 10y agoAny details about the runtime (or lack thereof)?
- deleted 10y ago[deleted]
- anilgulecha 10y ago// a represents a range with values 1,2,3 var a = 1...3; // b represents a range with values 1,2 var b = 1..<3; Ah! I wish they had gone for 1..3 and 1>..3 and 1..<3 and 1>..<3 to make it easy to understand. The above would map to [1,2,3], [2,3], [1,2] and [2] respectively. Range operator quirks with ... and .. have to today be memorized and waste developer seconds that add up to man-years.
- ChristianGeek 10y agoMakes perfect sense to me...three characters define the range. Should be 1...3, 1>..3, 1..<3, and 1>.<3
- amai 10y agoI like https://nim-lang.org https://nim-lang.org more.