Inspiration
I wanted to try a very non-conventional and non-mainstream programming language.
Palindrome-Checker-in-Hodor-language
A project to check whether a number, a word or even a sentence (in all lowercase/uppercase with punctuations removed) is a palindrome or not through this prompt box, but here's the twist: I attempted to convert my JavaScript file into a Hodor file ( a very non-mainstream programming language!)
Hodor Language:
Hodor is an actively used esoteric programming language (also called: esolang) created in 2015. It primarily uses jumbled permutations of the word, "hodor", over and over again. So, Game of Thrones fans, REJOICE!
Useful links:
However, here's a guide you can refer to:
Installation
To install Hodor please make sure you have nodejs installed on your machine.
npm install -g hodor-lang
Features
- Hodor
- Hodor hodor hodor hodor
- Hodor hodor hodor
- Hodor HODOR hodor
- Hodor!
Hello World
The classic Hello World example is made easy with Hodor.
$HODOR: hhodor? Hodor!? Hodor!? oHooodorrhodor orHodor!? d = HoDoRHoDoR () {
hodor.hod('Hhodor? Hodor!? Hodor!? o HODOR!? orHodor!? d!');
};
hhodor? Hodor!? Hodor!? oHooodorrhodor orHodor!? d();
Now run the hello world example.
hodor tests/helloworld.hd
HODOR: \-> tests/helloworld.hd
HODOR!
js2hd
To hit the ground running, you can convert your old JavaScript files to Hodor using the js2hd tool.
js2hd myfile.js -> myfile.hd
About my code:
Palindrome Checker in Browser using HTML and JavaScript
Firstly, I implemented the logic for checking Palindrome to build a Palindrome checker which takes user input through a prompt box and then provides output on screen as either of the following two:
1- It is a palindrome: if the input string is a palindrome
2- It is not a palindrome: if otherwise
However, I decided to convert my JavaScript file to a Hodor file by using the js2hd tool which resulted in the creation of Palindrome.hd file containing the Palindrome.js equivalent code but in Hodor script.
Challenges I came across
When I converted my JavaScript file to a Hodor file by using the js2hd tool, it generated a Palindrome.hd file containing the Palindrome.js equivalent code but in Hodor script.
And, I decided to execute it from Command Prompt:
C:\>hodor Palindrome/HodorPalindrome.hd
HODOR: \-> Palindrome/HodorPalindrome.hd
undefined:27
const string = prompt('Enter a word or sentence(in lowercases without punctuations) or a number: ');
^
ReferenceError: prompt is not defined
at eval (eval at convertCode (C:\Users\Abhilipsa\AppData\Roaming\npm\node_modules\hodor-lang\hodor.js:60:3), <anonymous>:27:16)
at convertCode (C:\Users\Abhilipsa\AppData\Roaming\npm\node_modules\hodor-lang\hodor.js:60:3)
at Object.<anonymous> (C:\Users\Abhilipsa\AppData\Roaming\npm\node_modules\hodor-lang\hodor.js:41:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\Abhilipsa\AppData\Roaming\npm\node_modules\hodor-lang\bin\hodor:3:1)
The error was expected because prompt() is a method of Global window object found in browsers. The Palindrome.js file allows the webpage to respond to user activity, therefore, it is best suited to browser console or from inside an HTML file.
In this case, the Hodor script simply works as a Cipher text, and can be converted back to JavaScript file anytime.
The error was expected because prompt() is a method of Global window object found in browsers. The Palindrome.js file allows the webpage to respond to user activity, therefore, it is best suited to browser console or from inside an HTML file.
Palindrome Checker in Command Prompt using Hodor Language
However, I modified the existing Palindrome.js file to Palin.js to take Command line inputs. Then, I converted it to Hodor file Palin.hd using js2hd tool via the Command Prompt only. And it works!
My own Palindrome Checker using Hodor Programming language was up and running!
You can use the converted Palin.hd file for execution or generate your own Hodor file from your own Palin.js file using js2hd tool in the Command Prompt.
Accomplishments that I'm proud of
It was a fun hack and I'm proud of all the fun I had. Also, resolved issues related to installation.
What we learned
I learned more about HTML, JavaScript.
Built With
- hodor
- html5
- javascript
Log in or sign up for Devpost to join the conversation.