Esoteric Programming Language
Tags: beginners, tutorial, javascript, webdev
Published: 2020-01-01 15:27:53

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/c4uuik2013pr6mxbtxc6.jpeg)
#JSF*ck

As every CS guy would always love to learn a new programming language. This Blog emphasise the fun part of the programming languages(playing with the programming language)


As of Introduction
Programming languages are divided into many types depending upon the properties they possess:
Few of the Programming languages categorised as
1. Array type
2. Declarative type
3. Concurrent type
4. Esoterical type
5. Compiled type
6. Interpreted type
7. Functional type
and the list goes on...

You can find the complete list in the wiki.

To keep things tidy we would not go into the question of **what properties did segregate them**.

Some languages even might belong to more than one category as it would possess the specified categorical properties.
Example: Java -It posses the properties of Declarative and Compiled type.
               Java belongs to both categories.
         
Now the discussion is all about the Esoterical programming languages.
Esoterical Programming languages however, they are not meant for any software development, but to test the limitations of the conventional programming languages(as stated by the one of the sites). Learning them doesn't make you a career, but might help to play with computer and enjoy better for those who are obsessed with computer programming.

Taking dive deep into the Esoterical type programming languages discussion. programming languages list under the esoterical type states as BF(Brain Fuck), JSFuck, Piet.

I would like to make it short and formal to spell JSFuck as JSF in this blog.
Now, here the discussion is about JSF It would be a tutorial for the JSF Programming Language. Among them, Piet and BF would require the special compiler to execute, whereas the JSF can be executed in the web-browser console and node as well.
As the name suggests JSF is a subset of JavaScript and the syntax whatever would be similar to the Java Script.

Those who are familiar with the JS would find of no surprise in the JSF syntax. JSF includes only 6 characters and the whole script need to be written using only those prescribed 6 characters.

6 characters listed here: [, ], +, (, ), \


###JSF an exceptional of esoterical programming languages
Advantage of learning Esoterical languages wouldn't help but learning JSF
make you strong with the puzzling scripts of JavaScript, which need not to scratch the head when encountered while dealing with JS.

To be said in another way, to practise the confusion part of JS getting familiar with JSF will surely help


###Making JS Basics Familiar

```javascript
    []      //evaluates []
    ''      //evaluates ''
```


```javascript
   '' == []     //evaluates true
   '' === []    //evaluates false
```

! operator in JS returns the Boolean **NOT** of the operand.
In JS empty string, Boolean false, null considered as a falsy.

```javascript
!''       //returns true
![]       //returns false
!Nan      //returns true
!null     //return true
```

As a Bonus, few of the JS would go
```javascript
![] == null //returns false
```
Here null is not a Boolean yet, still, it is a special null value so it returns false. After the occurrence of the '!' operator type coercion occurs and converted into Boolean value.

'+' operator is used as concatenation operator as well as the addition operator. The behaviour depends upon the operands being acted.
If any of the operands is String it would convert the non-string operand into the String and concatenate into a new String.
```javascript
  "Hello"+2            //returns Hello2 String
   "Hello"+Nan         //returns HelloNan
   "Hello" + Infinity  //return Hellonfinity
```

Though Nan, Infinity are special values in JS, type coercion is made upon the Nan and String type result is obtained.

``` javascript
    +[]         //return Nan
    +![]        //returns 0
    +!![]       //returns 1
    2 + ''      //returns '2'
    [] + []     //returns string
    [2] + [3]   //returns '23'

```
##Detailed JSF
In JSF as no special characters should be used except those of 6 characters makes the JSF Interesting. 

```javascript
   ![]            //value '0'
   !![]           //value '1'
   +![]           //value 0
   +!![]          //value 1
   !![] + ![]     //value 10
   [][[]]         //value undefined
   +[![]]         //value NaN
```
Same as in JS, JSF has Constructors but with of those 6 characters
```
[] + []    //String Constructor

+[]        //Number Constructor

![]        //Boolean

[]         //Array Constructor

```

Whenever you want to print the value n, the value of one (+!![]) should be added to recursively 'n' times. And hence the corresponding result would be obtained.

Now Whenever you want to print the alphabets, we shall extract the corresponding characters from the String and print them

Example:
```javascript
   [![] +[] ][ +[]][ +[]]   //gives f
```  

###Usage of [ ]

An array is an object to hold one/more number of elements and each element is given an index to access. An array may also contain other arrays inside it as an element. It is legal to use such.

IN JSF [ ] is regarded as an Array
```javascript
   []       //Array
   [[]]     //An array with an element at index 0 as []
```

Whenever we want to access the elements in Array we would do them with index placed within the square brackets _[]_
When we want to access the element at the index at 0


```javascript

[][]          //Syntax to access the elemnts in an array
[][[]]        //sytax to access the '' property of object inside first[]  
[[]][ +[]]    //returns an empty array []
```

As stated earlier [ ] is an array, and [ ] can also be used in the array elements access. Same happens here in the first expression
To keep things simpler [array][index] supposed that 'array' is the name of an array. But remember that we don't have alphabets to name the array hence we should keep the names as with expressions.

In the above second expression, we are trying to access the property of the Object stated in the RHS side. It returns the property value if it has.
But in the expression, it is given as [ ], which evaluates as ''(empty string). Hence we are trying to access the ''(empty string) named property to an object in the RHS side.


In the above third expression, there are two parts to evaluate first let us evaluate the left side expression as goes **[[]]**. It can be evaluated as an expression of an array with an inner array as its element. 
And the second expression goes as **[ +[]]**] as the left part of the expression evaluated as an array, the square brackets in the right-side can be used to access, so the right part needs to be given an integer value to access the elements in an array. To get the index value we are accessing we need to evaluate the inner expression of the right-side part.

so upon evaluation of the inner **+[ ]** expression it gives the value of 0, and at the index 0, an empty array is present so it returns an empty array.
 
The same method to access the characters in the strings can be used.
```javascript
   
   ![]                     //returns false
   ![] +[]                 //returns false as string
   [ ![] +[]]              //Keeping the false string in an array
   [ ![] +[]][+[]]         //returns false takes outside from an array
   [ ![] +[]][+[]][+[]]    //returns the 'f'

 ```

And the various methods can be used to extract the characters from the predefined JS words.such as true, null, undefined, Infinity, false.


Isn't that fun to get the numerical values and other characters whatever you required and whenever without actually using them.

Yes,It is....

JSF can be used to write functions and objects as well.
I want to make it as a series of posts and complete them.
In the next post, we could dwell little with the Functions, classes, Objets and more. 


**Programming is fun, Programming languages are funnier and, post readers are the funniest :) .**

Sigh.