DEV Community

Discussion on: Creating a New Programming Language That Will Allow Anyone to Make Software

Collapse
 
sativ01 profile image
sativ01 • Edited

I have just tried the BasicApp in a codesandbox, one question I have,
Why should I use a component's name as a string, instead of referring to it as to an object?
e.g. there's field
component: "Form",

so how do I know what's the name of the component that will be used?
I can import a component via
import { Form } from 'mson-react'

but when I use it as
component: Form, // this doesn't work

Using strings is very error-prone, you can't check if the name is correct, so things might not render, and you don't know why.
The error that appears on wrong naming is
const app = compiler.newComponent({
____________________^

Collapse
 
redgeoff profile image
Geoff Cox

Great question! If we were to use objects instead of strings, the definition would be JS and not JSON. By keeping it JSON there is native support for many things like storing JSON in a DB. Moreover, there are tons of tools that work with JSON that we can leverage, eg JSON editors, YAML to JSON converters, etc...

The MSON compiler attempts to validate some of these values (types) upfront. It wouldn't be too difficult to run the MSON compiler as a linter.