Why does Skia include a Forth interpreter? - forth

Why does Skia include a Forth interpreter?

The Forth interpreter inclusion was originally going to be a mini-scripting language to call Skia.
Mike Reed, software engineer and manager (second line of article) of one of the Google offices, confirmed that here.

Related

Android Things Custom Hardware

I'm interested is it possible to install and use Android Things(former Brillo) on custom produced hardware?
I can see from the official documentation there is preselected and certified SoMs listed, but I'm interested in using my own hardware.
Is it possible to have best of both worlds - use the familiar to me Android & Android Things but run it on proprietary hardware?
If not, what other options do I have - I researched about micropython, but apparently it seems it also comes with designated board(pyboard).
So my question is what are options to not thinks too much about the firmware on the device(and write C code), but focus on more higher-level business logic and programming languages(Java, Python).
Android Things isn't open source, so you can't put it into that isn't officially supported.
If you're looking for custom options, you will need to find a compiled language like C that works for that board. While C may be a bit intimidating, you may be able to find languages that compile to similar machine code. Rust and Go may work on microcontrollers too if you check.
I'm not too familiar with micro python. It says that it compiles to bare metal/machine code, so I believe you should be able to use it on other boards. While they may officially support the compiler for one board, the community may have support for additional microcontrollers.

The Language is Lua and the word is "embedded"

I was reading about the language "Lua" and I was confused with the three following lines :
Lua is designed primarily for embedded systems and clients .
The only competitor to Lua back then was TCL which was meant to be embedded into applications .
Lua is intended to be embedded into other applications,
So , what is the difference between the meaning of word "embedded" in the first line and the word "embedded" in the second and third line .
What does it mean for a language to be embedded into other applications ?
According to Wikipedia
An embedded system is a computer system with a dedicated function within a larger mechanical or electrical system, often with real-time computing constraints.
Typical examples include cars or coffee makers, where computers are embedded into the system to fulfill certain tasks.
The typical constraint is that embedded systems are often less powerful than a typical desktop computer due to cost and energy constraints. Therefore, languages to be used on embedded systems should allow for a lightweight execution. This is how "embedded" is used in the first line.
The second and third line refer to the usual application of Lua:
It is meant to be used to extend the functionality of existing programs. For example think about a coffee maker where you can specify your own coffee recipes. Then the actual control program of the coffee machine is written for example in C, while you can specify the coffee recipe in Lua. In this way, your coffee recipes that you write in Lua are embedded in the C application.
Application of Lua in embedded systems
Due to a comment that questions the use of Lua in embedded systems, here some examples taken from Wikipedia's list of Lua applications:
The Canon Hack Development Kit (CHDK), an open source firmware for Canon cameras, uses Lua as one of two scripting languages.
Cisco Systems uses Lua to implement Dynamic Access Policies within the Adaptive Security Appliance (ASA), and also SIP normalization in Cisco Unified Communications Manager (CUCM).
Custom applications for the Creative Technology Zen X-Fi2 portable media player can be created in Lua.
Lego Mindstorms NXT and NXT 2.0 can be scripted with Lua using third-party software.
LuCI, the default web interface for OpenWrt, is written primarily in Lua.
NodeMCU uses Lua in hardware. NodeMCU is an open source hardware platform, which can run Lua directly on the ESP8266 Wi-Fi SoC.
Sierra Wireless AirLink ALEOS GSM / CDMA / LTE gateways allow user applications to be written in Lua.
The Perimeta session border controller from Metaswitch Networks uses Lua as a scripting language to manipulate SDP data on the fly.
Rockbox, the open-source digital audio player firmware, supports plugins written in Lua.
The Squeezebox music players from Logitech support plugins written in Lua on recent models (Controller, Radio and Touch).
TI-Nspire calculators contain applications written in Lua, since TI added Lua scripting support with a calculator-specific API in OS 3+.
The use of the term "embedded" here is not the the same meaning as the [embedded] tag, in SO, or even the term "embedded systems" as it is conventionally used.
The link in the Wikipedia page is erroneous and misleading - the link is to "embedded systems", but the citation refers to it being an embeddable language - which is not the same thing.
Don't confuse these things - I have been developing embedded systems for many years and don't see Lua featuring anywhere. It could of course be used an an embedded language in an embedded system (for end user customisation for example), but it is not an embedded systems language as such.
1 states that Lua is for devices which have a certain purpose instead of many.
2 and 3 states that Lua may be implemented in, for instance, a C++ application to do a function.
For instance, a part of an application can use Lua, but it can also mostly use C++.

What is the official standard for pthreads?

I am trying to find the document that specifies the standard for pthreads. I've seen various links which point to IEEE 1003.1c-1995 (i.e. Wikipedia or OpenGroup). However when I searched for this document on the IEEE standards site I eventually found this page which said "Superseded Standard."
The IEEE page for 1003.1c-1995 did have a note that said: "Abstract not available. See ISO/IEC 9945-1." Searching for that on Google led me to a page for ISO/IEC 9945-1:1996 but the status said "withdrawn."
So my question is what is the current active standard for pthreads? Even better would be if there was a link to a free version of the standard, but it looks like most of the links I've seen for standards cost money. But I figure if I can find out the actual standard then I might try to see if I can access it through my school's library. But first I want to know what document I should be looking for.
I believe you want ISO/IEC/IEEE 9945:2009 as it is newer than ISO/IEC 9945-1:1996 , which was revised ISO/IEC 9945-1:2003 and ISO/IEC/IEEE 9945:2009 revised that.
The following POSIX FAQ provides additional information, specifically relevant Q4. Where can I download the 1003.1 standard from? and includes links to a free HTML online version that requires registration here.
There is understandably a lot of confusion around the relevant standards. We have:
ISO/IEC 9945
IEEE 1003.1
POSIX.1
Single Unix Specification
The Open Group Base Specifications
Possibly others
Why so many different standards? I'm sure it's mostly historical. At one point some or all of these standards might have referred to their own thing. But the simplest answer is that, today, all of these specifications are now just different names for the same thing*. Here is the opening sentence from the online version of The Open Group Base Specifications, Issue 7:
POSIX.1-2008 is simultaneously IEEE Std 1003.1™-2008 and The Open Group Technical Standard Base Specifications, Issue 7
Some of the standards bodies do not provide free or registration-free access to their copies of the standard. However, The Open Group does allow free (and registration-free) access to the current issue of their online copy.
*The Single Unix Specification may not be exactly the same; it seems it contains everything in POSIX, plus the X/Open Curses standard.

Is there a programming language with semantics close to English?

Most languages allow to 'tweek' to certain extend parts of the syntax (C++,C#) and/or semantics that you will be using in your code (Katahdin, lua). But I have not heard of a language that can just completely define how your code will look like. So isn't there some language which already exists that has such capabilities to override all syntax & define semantics ?
Example of what I want to do is basically from the C# code below:
foreach(Fruit fruit in Fruits)
{
if(fruit is Apple)
{
fruit.Price = fruit.Price/2;
}
}
I want do be able to to write the above code in my perfect language like this:
Check if any fruits are Macintosh apples and discount the price by 50%.
The advantages that come to my mind looking from a coder's perspective in this "imaginary" language are:
It's very clear what is going on (self descriptive) - it's plain English after all even kid would understand my program
Hides all complexities which I have to write in C#. But why should I care to learn that
if statements, arithmetic operators etc since there are already implemented
The disadvantages that I see for a coder who will maintain this program are:
Maybe you would express this program differently from me so you may not get all the
information that I've expressed in my sentence
Programs can be quite verbose and hard to debug but if possible to even proximate this type of syntax above maybe more people would start programming right? That would be amazing I think. I can go to work and just write an essay to draw a square on a winform like this:
Create a form called MyGreetingForm. Draw a square with in the middle of
MyGreetingFormwith a side of 100 points. In the middle of the square write "Hello! Click here to continue" in Arial font.
In the above code the parser must basically guess that I want to use
the unnamed square from the previous sentence, it'd be hard to write such a smart parser I guess, yet it's so simple what I want to do.
If the user clicks on square in the middle of MyGreetingForm show MyMainForm.
In the above code 'basically' the compiler must: 1)generate an event handler 2) check if there is any square in the middle of the form and if there is - 3) hide the form and show another form
It looks very hard to do but it doesn't look impossible IMO to me at least approximate this (I can personally generate a parser to perform the 3 steps above np & it's basically the same that it has to do any way when you add even in c# a.MyEvent=+handler; so I don't see a problem here) so I'm thinking maybe somebody already did something like this ? Or is there some practical burden of complexity to create such a 'essay style' programming language which I can't see ? I mean what's the worse that can happen if the parser is not that good? - your program will crash so you have to re-word it:)
Check out:
The Osmosian Order
of Plain English Programmers
Code Example:
The background is a picture.
A button has a box and a name.
To clear the status:
Clear the status' string.
Show everything.
To create the background:
Draw the screen's box with the white color.
Loop.
Pick a spot anywhere in the screen's box.
Pick a color between the lightest gray color and the white color.
Dab the color on the spot.
If a counter is past 80000, break.
If the counter is evenly divisible by 1000, refresh the screen.
Repeat.
Extract the background given the screen's box. \or Create the background from the screen. Or something.
Some Interactive fiction designers use a language syntax extremely close to the English language. Here's some Inform 7 code, which you can play online:
The foyer is a room.
The apple is in the foyer. It is edible. The description is "This is a ripe,
green granny smith apple."
The apple core is a thing. The description is "This apple core all that is
left of that granny smith apple you just consumed."
After eating the apple:
now the apple core is in the player;
say "You gobble down the apple careful not to eat any of those cyanide-
laced seeds you heard about."
I tutored a course that used Inform 7. One of the tutors had the impression the assignment was to design, not write a game. So he marked the programs by reading them, without realising they were actual programs.
I don't think that this would be an easy task nor do I think it is going to make life easier for debugging
How would you deal with these issues?
spelling mistakes
different dialects in different parts of world
different dialects in the same part of the world
synonyms
which part of sentence do you parse first?
tear (rip) and tear (from eye) both words spellings are the same but mean two different things.
Bring back COBOL or can you remember "Walk West", "Examine Door", "Push Door", "Open Door", "Use key on door" :)
edit - how would you strongly type this?
I have written an extensible English-to-Python compiler called EngScript, which converts structured English into working Python code.
This is an example of EngScript code:
print{create a string from the file called "README.txt"}
print{save the string "Woohoo!" to a file called "ExampleText.txt"}
print{the first 3 letters of "EngScript"}
This is the output that was generated by the EngScript compiler:
print(pythonFunctions.stringFromTextFile("README.txt"))
print(pythonFunctions.writeStringToFile("ExampleText.txt", "Woohoo!"))
print("EngScript"[0:(3 - 1)+1])
LiveCode!
There are a few "natural language", high-level, English-like programming or scripting languages. Probably all of them were inspired by the oldest, COBOL. My personal favorite of these languages is LiveCode. LiveCode is a decendent of MetaCard, a Linux clone of Apple’s now defunct HyperCard that used an English-like scripting language called HyperTalk, which was inspired by SmallTalk, and in turn inspired JavaScript (as well as the entire World-Wide-Web). HyperTalk was the basis for another English-Like scripting language called AppleScript (and later AppleScriptObjC), which still comes with macOS to this very day. LiveCode uses a language called LiveCodeScript, or LCS which, like other HyperCard clones and that have existed over the years (SuperCard, Adobe’s Lingo/Flash ActionScript, Open Xion, Oracle’s Toolbook, etc.), is very similar to HyperTalk at it’s core, often referred to as an X-Talk language. LiveCode has several advantages; it’s very much still in production, it has a dual license (open source and commercial versions), the engine is cross-platform (Mac, Win, Linux, HTML5, iOS, Android, and a server version), and like HyperCard it is also a GUI toolkit and it is extensible. The LiveCode team is currently working on new a lower-level programming language called LiveCode Builder, or LCB. LCB is also an English-like, although LCB is a bit less readable than LCS, it has a goals of having capabilities on par with lower-level languages like C++, Objective C, etc., allowing for extending the LiveCode platform with code libraries and frameworks produced by other programming language libraries, and ultimately allowing for the LiveCode IDE to be written in it’s own language.
Try using the programming language called 'Google' - it has a natural English interface and your code fragment throws back all the answers you are suggesting. Interestingly just six minutes after you asked this question, this very page is #1 for the query:
Check if any fruits are Macintosh
apples and discount the price by 50%
Use the Google API and I think you have the basis of a natural English programming language.

How to support multiple languages on a microcontroller?

I'm currently working on upgrading a product for the Chinese market. The target is a ARMTDMI7 with a QVGA display. Most resources I've located on the net are targeted at desktop or web programming rather than embedded devices.
Can anyone suggest some tools and
resources that might be useful?
What are the best techniques for
extracting literal strings and
communicating with translators?
I suggest looking at EasyGUI but that depends on what graphics controller you use.
EasyGUI is a tool that simplifies design of user interfaces and comes with complete source code and driver for a varity of display controllers.
For localization you can use EasyTranslate that gives the translater a graphical representation of the interface. This lets the translator see how the translated texts fit on the screen.
EasyGUI is available with unicode support aswell as right to left script.
Freetype might be good for rendering fonts.
www.freetype.org
There are many ARM microcontroller forums which will help you find what you're looking for.
Atmel has a line of ARM7 processors, and they are pretty friendly to those who make a hobby out of this, so there's a lot of information on this processor. It won't be the same, but generally the tools and libraries can be used across the ARM line so you might find some help here - you'll want to focus on the AT91SAM7 series.
If you have more specific questions, you will probably get some reasonable response here.
-Adam
It sounds like you need to upgrade an existing codebase to make it support multiple languages.
If so, the fact that this is on a microcontroller shouldn't be an issue - I'd drop that fromt he title and focus on the language you're using (c?) and ask how to convert your program for internationalisation.
This is a problem many people have solved on a variety of platforms, and the fact this you're on a microcontroller doesn't mean that the same tools and such don't apply - the relevant factor is the language you're using
-Adam

Resources