News for hackers. Stuff that matters.
Re:Gravity – An embeddable programming language by ainar-g on Friday June 22, 2018 @09:45AM (#17373885)
>null

>dynamic typing

>naked if-else bodies

I'm sorry, but I just don't see how this improves on anything. How will GravLang make me a better, more productive programmer? How will it make my programs more robust?

Don't get me wrong, as a hobby project it's fine, but as a "real" language it doesn't have any selling points to me.

Re:Gravity – An embeddable programming language by api on Friday June 22, 2018 @09:57AM (#17373978)
It doesn't improve much on e.g. JavaScript or Python. That's not the point. The point is that it's a small fast zero-dependency embeddable language that could be used for e.g. scripting in games or small devices.

Wren is another nice one:

https://github.com/munificent/wren

Re:Gravity – An embeddable programming language by ainar-g on Friday June 22, 2018 @10:05AM (#17374024)
Don't we have already Lua for that? It even has a state-of-the-art JIT compiler.

I am all in for competition, but I can't see how both of these languages could improve over Lua.

Re:Gravity – An embeddable programming language by logimame on Friday June 22, 2018 @10:36AM (#17374243)
Although LuaJIT is crazy fast, it can't be used on iOS, so we first need to compare this with the unJITted version of Lua.

Lua is pretty simple and elegant, but has its woes on being too flexible and wonky (especially with nil and global variables). It also doesn't support OOP syntax directly, so everyone started to create their own wonky class system, which broke easily because of Lua's wonkiness. Gravity seems like a good embedding language packaging a nice OOP syntax with a lot of syntactic sugar (such as properties and access specifiers), so I think some UI/game developers would choose this over Lua.

Re:Gravity – An embeddable programming language by sitkack on Friday June 22, 2018 @11:33AM (#17374747)
>it can't be used on iOS

LuaJIT interpreter which is _faster_ can be used on iOS. So you would use an immature language everywhere because you can't use the fastest implementation on one platform (iOS), when infact, the LuaJIT interpreter is the fastest interpreter of any dynamic language on all platforms.

Wonkiness is not a substantive claim. How do class systems break because of it?

Re:Gravity – An embeddable programming language by TooBrokeToBeg on Friday June 22, 2018 @01:57PM (#17375943)
Magic methods are wonky. Things that get called, although they don't exist, have to traverse an arbitrary system to determine an implementation (may or may not exist). Now add that you can determine that system of traversal, at runtime. Now add arbitrary constraints like 42 local vars per scope, singular inefficient table, no switch (but currying is ok, certainly one of these is more confusing than the other in every CS class) ultimately forcing some wonkiness in every project. It's truly a strange confluence of features leading to an even dumber javascript. I use Lua a lot.
Re:Gravity – An embeddable programming language by samatman on Friday June 22, 2018 @04:59PM (#17377297)
Different strokes I guess.

I consider Lua's type system almost mathematical in its elegance. For my taste, Lua is the penultimate dynamic language, held back only by the unforgivable Wirth-style indexing from 1.

The one place where I simply must correct you is in calling tables inefficient. LuaJIT's implementation, as interpreted, is demonstrably among the fastest general-purpose container classes in widespread use.

Re:Gravity – An embeddable programming language by armitron on Friday June 22, 2018 @01:21PM (#17375682)
Of course it can be used on iOS, there are commercial applications that do exactly that. You can turn off the JIT and you're left with probably the fastest interpreter for a dynamic language that currently exists.

LuaJIT is state-of-the-art even without the JIT. A lot of people miss this and go down various rabbit holes only to come up with something that's significantly worse. Personally, given what I just described, I don't see how Gravity compares at all favorably to Lua.

Re:Gravity – An embeddable programming language by ainar-g on Friday June 22, 2018 @10:49AM (#17374355)
I see your point, although I would probably use something like mruby[1] if I wanted something embeddable and OO.

[1] http://mruby.org/

Re:Gravity – An embeddable programming language by lasagnaphil on Friday June 22, 2018 @11:12AM (#17374557)
I've also looked at mruby, but the language seemed quite complex. (It claims to have a Ruby compatible syntax, but also has its strange warts.) It doesn't help that its documentation is rather poor. Also by looking at the issues section I was pretty scared about the bugs that might come up while using this (https://github.com/mruby/mruby/issues). If there was any successful usage of it in game development I would have jumped in, but so far I haven't found any.
Re:Gravity – An embeddable programming language by api on Friday June 22, 2018 @10:59AM (#17374448)
Can anything interesting be used on iOS?
Re:Gravity – An embeddable programming language by lasagnaphil on Friday June 22, 2018 @11:39AM (#17374811)
There are some nice non-JIT embedded languages such as Angelscript (resembles C++, uses refcounting instead of GC), Squirrel (extension of Lua syntax to support classes and other nice features), and recently Wren (has a nice class system and uses fibers for concurrency).
Re:Gravity – An embeddable programming language by api on Friday June 22, 2018 @11:53AM (#17374943)
Does Apple still prohibit any form of downloaded code or scripting or did they finally ease that?
Re:Gravity – An embeddable programming language by 0xCMP on Friday June 22, 2018 @04:38PM (#17377149)
They do if the user can download and execute the code themselves. If the underlying app uses it (e.g. React Native app downloads updated bundle) and user can't touch it then it's okay.
Re:Gravity – An embeddable programming language by megous on Friday June 22, 2018 @02:39PM (#17376264)
Wren looks interesting. It stands out by the lack of use of setjmp/longjmp for error handling. It's probably side effect of being able to return/suspend fiber from any call stack depth.
Re:Gravity – An embeddable programming language by rurban on Friday June 22, 2018 @05:24PM (#17377507)
Haxe is the leader there, besides swift.
Re:Gravity – An embeddable programming language by SlowRobotAhead on Friday June 22, 2018 @11:46AM (#17374883)
Ok, find me a Lua compiler for my ARM Coretx M4 that can spool up its VM on my chip, run my C functions natively, and takes less than 30k ROM.

There is a difference here where 1/2 people something iphone can run, and the other half want something that would run on a small 32bit.

I want a scripting VM with an FFI. Lua while supposed to be able to do that just isn’t supported by anyone for that purpose.

Re:Gravity – An embeddable programming language by chillingeffect on Friday June 22, 2018 @02:40PM (#17376279)
I think you might be served by elua, embedded lua. I haven't used it myself, but it looks pretty active.

https://github.com/elua/elua

P.s. the cortex m4 is awesome!

Re:Gravity – An embeddable programming language by SlowRobotAhead on Friday June 22, 2018 @02:52PM (#17376400)
eLua is dead though. Shot itself by trying to be a C replacement. If an embedded Lang for embedded micro has system headers to allow you to stay in the embedded Lang - it’s not going anywhere.
Re:Gravity – An embeddable programming language by SketchySeaBeast on Friday June 22, 2018 @11:02AM (#17374472)
>naked if-else bodies

For my own interest, do you have examples of the way other languages do it? I'm interested, and but I'm afraid to google that.

Re:Gravity – An embeddable programming language by ainar-g on Friday June 22, 2018 @11:10AM (#17374529)
In Go, one has to always write the if-else bodies in curly braces (and, the opening brace should always be on the same line). I think this is great for two reasons. Firstly, it prevents bugs where a very tired programmer needs to add something to the else body, which is written like this:

    else
      foo();
and writes

    else
      foo();
      bar();
which compiles, but doesn't do what you think it does. And I have seen this bug in actual projects.

Secondly, along with gofmt, it prevents style wars.

Re:Gravity – An embeddable programming language by jerf on Friday June 22, 2018 @11:41AM (#17374829)
"In Go, one has to always write the if-else bodies in curly braces (and, the opening brace should always be on the same line)."

If you really want to twist the knife... even Perl 5 gets this right. Even Perl 5 thinks that naked if/else bodies is too crazy and error prone.

Re:Gravity – An embeddable programming language by renox on Friday June 22, 2018 @08:35PM (#17378688)
'even Perl5'? Perl5 has also 'use strict' which ensure that variables ate declared before usage, a feature that Python doesn't have AFAIK.
Re:Gravity – An embeddable programming language by krylon on Friday June 22, 2018 @04:44PM (#17377181)
That is why I got into the habit, very early on, to always, always enclose blocks in curly braces (or begin-end, depending on the language). If it is ingrained deeply enough, one no longer has to think about it.

But it is nice if the language enforces it. I would even go so far as to claim it is common sense.

Re:Gravity – An embeddable programming language by arrty88 on Friday June 22, 2018 @02:24PM (#17376136)
It has automagic GC!