News for hackers. Stuff that matters.
Re:Gravity – An embeddable programming language by stinos on Friday June 22, 2018 @11:19AM (#17374619)
For anyone who considers this interesting and/or looking for alternatives: apart from the well-known Lua there's also MicroPython [1] whos specs actually read a lot like the specs of Gravity but then some more (well, it's Python 3.5 minus a couple of features, also compiles with C99 compilers, is fairly small for being a Python, embeddable, more mature at this point, been tested on more platforms/architectures, ...).

[1] http://micropython.org/ https://github.com/micropython/micropython/

Re:Gravity – An embeddable programming language by bakery2k on Friday June 22, 2018 @11:41AM (#17374830)
MicroPython is a subset of Python intended for resource-constrained embedded devices, unlike Gravity which is designed to be embedded in applications. This is a significant difference - a while back I considered embedding MicroPython in an application (the Lua/Gravity/Wren scenario), but the Python programmers I discussed this with generally disliked the idea.

It seems those who already know Python want either the whole Python language, or not Python at all. I guess it's easier to learn a whole new language, than to use a language you already know but where some parts are suddenly off-limits?

Re:Gravity – An embeddable programming language by stinos on Saturday June 23, 2018 @03:18AM (#17379993)
It seems those who already know Python want either the whole Python language, or not Python at all

Depends on whom you ask I guess. The subset implemented is fairly big imo. Maybe I just got lucky but I never really missed something, and looking at the list of differences [1] that might be because most of them are rather obscure/fancy features which I usually tend to avoid anyway or don't even know exist (multiple inheritance, attributes for functions just to name some) or else can be worked around.

[1] http://docs.micropython.org/en/latest/pyboard/genrst/index.h...

Re:Gravity – An embeddable programming language by int_19h on Saturday June 23, 2018 @09:05AM (#17381089)
You might not use those features directly, but they're often used in library code. For example, attributes on functions are common technique for function decorators to store some associated data.
Re:Gravity – An embeddable programming language by stinos on Saturday June 23, 2018 @09:12AM (#17381111)
Fair point. Porting existing libraries is usually a bit of a struggle. Luckily for the particlar applications we use we get along just fine with the standard library subset, everything else is a mix of custom C++ and Python modules.
Re:Gravity – An embeddable programming language by SlowRobotAhead on Friday June 22, 2018 @11:35AM (#17374774)
Just a nitpick... but I’ve seen people who aren’t working on what i would consider typical embedded recommend eLua and MicroPython readily without ever mentioning the downsides that mPy needs 128k+ ROM and includes a ridiculous standard lib most of which you would never use on embedded, and eLua supports some Cortex m3 and is a dead project. These two you mentioned are more of people using Rasp Pi syyle embedded (Cortex m-series vs Cortex A/R series... small devices vs phone processors).

The issue is everyone has this “great idea” for an embedded language to replace C which means device headers in the Lang, and that’s way too much to support.

If the goal is to replace C imo it’s a waste of time. But there is a market IMO for an embedded lang that you can execute tests and scripts from C in a VM that can foreign function interface back to C functions.

There is on that uses JS called mJS but I found the one of the guys that supports it to be extremely rude and unhelpful. Documention is lacking. You basically need to be an expert in JS to get started. And then they doubled their ROM use age from 23k to ~50k. But it does seem to be the best out there for the goals I stated.

I’m still on the hunt.

Re:Gravity – An embeddable programming language by fundamental on Friday June 22, 2018 @11:43AM (#17374851)
It depends upon what's the target you're trying to embed into. If you're trying to put something on a PIC or an 8 bit AVR, you're down to something like assembly, C, or a very low memory language like forth. If you're looking at larger targets like the ESP32, then you can use an embeddable python, ruby, lua, js, etc without being too concerned. On something like a raspberry pi compute time likely ends up being more of a concern than memory or build complexities.

The other target is trying to embed some interpreter in a larger application, which ends up being mostly constrained by how nice the language is as well as how nice the C API barrier ends up being.

C is certainly not going anywhere, but it is pretty cool that other options are being built to lower the barrier of entry for some application domains.

Re:Gravity – An embeddable programming language by vvanders on Friday June 22, 2018 @12:59PM (#17375529)
FWIW there's still a pretty large delta from Lua and JS as far as embedding targets go. We use to run our whole game state in a 800kB fixed block on a 8mb system heap in vanilla Lua(pre-LuaJIT) with good success.

I've done some poking at various embedded JS frameworks like Duktape and it's pretty easy to trip on various memory leaks[1] that make it really hard to recommend it as a viable platform for memory constrained spaces.

[1] http://point.davidglasser.net/2013/06/27/surprising-javascri...

Re:Gravity – An embeddable programming language by nickpsecurity on Friday June 22, 2018 @01:24PM (#17375710)
One project used ATS for an 8-bitter:

http://metasepi.org/doc/metasepi-icfp2015-arduino-ats.pdf

http://www.ats-lang.org

Chez Scheme used to run on 8-bit platform, too. Then there's Pascal and BASIC dialects for microcontrollers. Astrobe has Oberon dialect for ARM Cortex's. AVR-Ada lets you use Ada with AVR's. OcaPIC put Ocaml subset on PIC microcontrollers.

People are using C because most people already use C with the ecosystem benefits that follow. Although C and assembly are dominant, there are other options available if people think their pro's and con's line up with their needs.

Re:Gravity – An embeddable programming language by PeCaN on Friday June 22, 2018 @06:20PM (#17377963)
Always cool to see ATS in the wild. Higher-order functions on an 8-bit CPU makes me happy. :D
Re:Gravity – An embeddable programming language by rurban on Friday June 22, 2018 @05:14PM (#17377423)
That's excellent news. ATS is one of the best languages out there. It used to beat C in the shootout benchmarks, and adds much better security and types than C/C++.

I'll try to use in my next embedded job, where they do just C.

Re:Gravity – An embeddable programming language by pjmlp on Friday June 22, 2018 @03:27PM (#17376648)
There are Basic and Pascal as well, there are a few embedded companies still selling compilers.
Re:Gravity – An embeddable programming language by detaro on Friday June 22, 2018 @11:48AM (#17374899)
I don't see why you'd use MicroPython on a raspi-class device, unless you can't use a OS that runs CPython for for some reason. MicroPython is more for smaller stuff.
Re:Gravity – An embeddable programming language by SlowRobotAhead on Friday June 22, 2018 @03:04PM (#17376501)
If you have 1/2 your code in C and want a Python VM for one reason.

But keep in mind that even MicroPy recommends 256k ROM, which is before your program at all, that excludes nearly all Cortex M series and 16 and 8 bit micros. So that’s what brought me to Pi in the first place.

Re:Gravity – An embeddable programming language by ricardobeat on Friday June 22, 2018 @04:25PM (#17377075)
Check out http://duktape.org. Extremely easy to embed, great performance, and can go down to a ridiculous 1.5KB of RAM at startup.

This and JerryScript (https://github.com/jerryscript-project/jerryscript) are the two most active embedded JS engines.

Re:Gravity – An embeddable programming language by sitkack on Friday June 22, 2018 @08:38PM (#17378698)
How is eLua dead? https://github.com/elua/elua

eLua is famously used in the https://en.wikipedia.org/wiki/NodeMCU firmware for the ESP8266, a non-Arm based system.

Re:Gravity – An embeddable programming language by eggy on Friday June 22, 2018 @09:35PM (#17378919)
Have you tried Zig? [1] I tried Rust, but found I made better progress with Zig, and I can see it being a good, incremental replacement for C.

  [1]  https://ziglang.org/
Re:Gravity – An embeddable programming language by skybrian on Friday June 22, 2018 @01:22PM (#17375693)
Also, at first glance, Gravity looks a lot like Wren: https://github.com/munificent/wren
Re:Gravity – An embeddable programming language by rurban on Friday June 22, 2018 @05:19PM (#17377464)
Which looks a lot like Potion: https://github.com/perl11/potion

But wren and Potion are much smaller. Wren added a nice work-stealing native-thread scheduler on top of potion.

Re:Gravity – An embeddable programming language by fundamental on Friday June 22, 2018 @11:29AM (#17374711)
MRuby[1] is another option in this space. From what I can tell the work for MRuby began around the same time as micropython, though micropython has seen more adoption.

[1] http://github.com/mruby/mruby

Re:Gravity – An embeddable programming language by PeCaN on Friday June 22, 2018 @06:25PM (#17377992)
I was surprised nobody mentioned mruby in this thread until now. It's tiny, super easy to embed, and Ruby is a fun language.

Also, mruby has the benefit over most of these other languages of having had a recent thorough security audit[1].

1. http://mruby.sh/201703270126.html

Re:Gravity – An embeddable programming language by petre on Saturday June 23, 2018 @12:44AM (#17379583)
It's still quite huge compared to Lua, not to mention slower. And gems need to be enabled at compile time.
Re:Gravity – An embeddable programming language by ccccccccccccc on Friday June 22, 2018 @03:19PM (#17376596)
mruby has a much higher adoption in Japan, but I don't think it ever really caught on outside of it