/Swifty.js

Warning: This library is still in developement testing. Use at your own risk.

Primary LanguageJavaScriptMIT LicenseMIT

Swifty.js

Warning: This library is still in developement testing. Use at your own risk.

Simplifying JavaScript, without using JavaScript.

Swifty.js uses its own syntax and keywords.
Doing that will make JavaScript more fun (building custom keywords, specifying syntax etc.)
Here's an example code of Swifty.js:

[ swift version 0.3 ]

FUNCTION example = FUNC(
[...any],
({
constant params = any
return params
})
))

example("String") # "String"

Learning Step-by-Step

A complete walkthrough of how to treat Swifty.js keywords and syntax correctly.

How was Swifty.js built? (Using JavaScript!)

Swifty.js is a JavaScript PreProcesser that takes code, transforms it fully into JavaScript, and runs it.
Take this for example:

[ swift version 0.1 ]
FUNCTION myFunction = FUNC([...any], ({})))

##+
Check if version is valid and remove it
Take keywords and make the JavaScript-readable
Add semicolons
##-

Get started

You can get it by CDNjs:

Regular
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.3/swifty.js" async>[ swift version 0.3 ]</script>
Minified
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.3/swifty.min.js" async>[ swift version 0.3 ]</script>
  • Or download the file here.

Documentation

Let's walk through some CS (Common-Syntax) in Swifty.js.

1. Correct Placement

Swifty.js code is NOT to be placed in .js (JavaScript) files.
Swifty.js code is NOT to be placed the HTML <script> tag.

Instead, it uses its own tag called the <swift> tag:

<swift>
  # Code here
</swift>

2. Functions

Before anything, you need to define the version:

[ swift version 0.3 ]

The version number should be between 1 (0.1 -> 0.9). Continue...

From an example code, you may have noticed that Swifty.js functions are "UPPERCASE":

FUNCTION example = FUNC(...)
^^^^^^^^           ^^^^

It's so the code is not to be mixed with pre-defined keywords and variables, etc.
ALWAYS use "UPPERCASE" syntax for Swifty.js.

To define a function, just use FUNCTION.
Then, the function body starts with FUNC().

Example:
FUNCTION example = FUNC(...)

Then, to define paramaters, you use an Array:

FUNCTION example = FUNC(
[...any],
({
constant params = any # These will be the parameters
})
))

Note that Swifty.js never uses semicolons.

3. Variables

A variable is simple in Swifty.js, because it is just called a variable:

variable myVar = 1

4. Local Variables

A local variable is also simple in Swifty.js, because it is just called a letter:

letter myLet = 0

5. Constant Variables

A constant variable is also simple in Swifty.js, because it is just called a constant:

constant myConst = 2

6. Strings

Strings can be defined using the string keyword:

string myStr = "Test string"

myStr # "Test string"

7. Single-Line Comments

Swifty.js comments are quite familiar because they're related to other file-type comments.
They begin with a hashtag (#), and the comment comes right after it:

# This is a single-line comment

8. Multi-Line Comments

Swifty.js multi-line comments are not familiar.
First, you start with two hashtags (##).
The first one starts with a plus-sign (+).
The last one ends with a minus-sign (-).

Example:
##+
This is
a multi-line
comment
##-

9. Pop-up Boxes

The POP keyword lets you make JavaScript (default) alert boxes.

Syntax
POP.alert(message: String ? "")
Example
POP.alert("Hello, world!")
POP.prompt("Enter your name:")
POP.confirm("Are you sure?")

10. Dialouges

Dialouge boxes let you make smooth pop-ups with user interaction.

DIALOUGE("Select an action:")

11. Importing modules

Syntax
IMPORT(url: String ? "")
Example
IMPORT("https://www.example.com/file.js")

Here, we showed CS (Common-Syntax) in Swifty.js.

If you'd like to see more AS (Advanced-Syntax), please see the Full Documentation.

License

MIT

Other Swifty.js Versions

Swifty.js 0.2

Swifty.js

Simplifying JavaScript, without using JavaScript.

Swifty.js uses its own syntax and keywords.
Doing that will make JavaScript more fun (building custom keywords, specifying syntax etc.)
Here's an example code of Swifty.js:

[ swift version 0.2 ]

function example = func(...any) {
  constant params = any
  return params
}

example("String") # "String"

Learning Step-by-Step

A complete walkthrough of how to treat Swifty.js keywords and syntax correctly.

Quickstart

You can get it by CDN:

<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.2/swifty.js" async>[ swift version 0.2 ]</script>
  • Download the file here

Documentation

Let's walk through some CS (Common-Syntax) in Swifty.js.

1. Correct Placement

Do not place Swifty.js code in .js (JavaScript) files.
Do not place Swifty.js code the HTML <script> tag.

Instead, place it in the pre-defined <swift> tag:

<swift>
  # Code here
</swift>

2. Functions

To define a function, just use function.
Then, the function body starts with func().

Example:
function example = func(...)

Then, to define paramaters, you place all of them inside the parenthesis:

function example = func(...any) {
  constant params = any
  # "params" are the parameters
}

Note that Swifty.js never uses semicolons.

3. Variables

A variable is simple in Swifty.js, because it is just called a variable:

variable myVar = 1

4. Letters

A letter is also simple in Swifty.js, because it is just called a letter:

letter myLet = 0

5. Constants

A constant is also simple in Swifty.js, because it is just called a constant:

constant myConst = 2

6. Strings

A letter is also simple in Swifty.js, because it is just called a letter:

string myStr = "Test string"

7. Single-Line Comments

Swifty.js comments are quite familiar because they're related to other file-type comments.
They begin with a hashtag (#), and the comment comes right after it:

# This is a single-line comment

8. Multi-Line Comments

Swifty.js multi-line comments are not familiar.
First, you start with two hashtags (##).
The first one starts with a plus-sign (+).
The last one ends with a minus-sign (-).

Example:
##+
Multi
Line
Comment
##-
Swifty.js 0.1

Swifty.js

Swifty.js uses its own syntax and keywords.
Here's an example code of Swifty.js:

[ swift version 0.1 ]

function example = func(...any) {
  constant params = any
  return params
}

example("String") # "String"

Quickstart

You can get it by CDN:

<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.1/swifty.js" async>[ swift version 0.1 ]</script>
  • Download the file here

Documentation

Let's walk through some CS (Common-Syntax) in Swifty.js.

1. Correct Placement

Do not place Swifty.js code in .js (JavaScript) files.
Do not place Swifty.js code the HTML <script> tag.

Place it in the pre-defined <swift> tag:

<swift>

</swift>

2. Functions

A function body starts with func().

Example
function example = func(...)

Then, to define paramaters, you place all of them inside the parenthesis:

function example = func(...any) {
  # ...
}

Swifty.js never uses semicolons.

3. Variables

A variable is simple in Swifty.js, because it is just called a variable:

variable myVar = 1

4. Letters

A letter is also simple in Swifty.js, because it is just called a letter:

letter myLet = 0

5. Constants

A constant is also simple in Swifty.js, because it is just called a constant:

constant myConst = 2

7. Single-Line Comments

Swifty.js comments are quite familiar because they're related to other file-type comments.
They begin with a hashtag (#), and the comment comes right after it:

8. Multi-Line Comments

Swifty.js multi-line comments are not familiar.
First, you start with two hashtags (##).
The first one starts with a plus-sign (+).
The last one ends with a minus-sign (-).