StevenMDixon / IJScript

πŸ‘Ί A bit of fun, taken too far

Home Page:https://stevendixondev.github.io/IJScript/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ‘Ί IJScript

badge

What is IJScript? IJS is an attempt to write the most unreadable and short javascript code possible, and to develop a style of formatting code that can be reused.

This entire repo was inspired by code golf and code wars. If you don't know what code golf is check out this link code golf. It is worth noting that this entire idea is a subset of Code golfing because it relies on the same core idea.

What does the I stand for in IJS? Incomprehensible, indecipherable or inconceivable.

🎯 The Goal of IJS

Create a system of writing the most unreadable code possible. Random coding challenges will be used as examples to show of the progression of the system. If you cannot follow along or are having trouble reading the code that's the whole point. Check out the Tips page or the the Process page to find out how to write IJS.

🎨 The Methodology

  • All answers should be as short and unreadable as possible
    • Unreadable takes priority over length
    • Remove all unnecessary [spaces, parenthesis, ;]
    • Do not use [let, const, var]
    • Do not use i to represent a counter
    • Stay away from prototype functions as much as possible
    • [.length] should never be used.
  • All answers must be resolved in a single lambda expression
    • always use es6 arrow functions
    • always use implicit returns
    • define variables in the functions parameters
  • Math and Coercion are your best friends
    • Do not use 1||0 outside of strings
    • Do not use empty strings ''||""
    • Do not use +1||-1
    • Do not use ==||===
    • Do not use >=||<=
  • Do not use eval

One of the core principles of programming is writing readable code. IJS throws that to the wind and asks "What if we just wrote code that no one could read?"

Example

A simple calculator function that takes three arguments:

c=(o,n1,n2,a)=>({'m':n1*n2,'a':n1+n2,'s':n1-n2,'d':n1/n2,'p':(n1**+n2)}[o[+[]]]||a+' operator')

This is a good example of IJS. Short and otherwise unreadable code, unless given context.

WTF

πŸŽ“ Testing

I have written a function to test functions written with the IJS methodology. See test.js. These tests will ensure a writer is following the IJS methodology to a T. To use the test just pass your function without calling it and check the console output.

πŸ’― The Challenges

Check out the Challenges Page for some completed challenges.

πŸŽ‰ The Conclusion

JavaScript is a very quirky language and it can be written several different ways. Not all of these ways are good, but the thing to keep in mind is that readable code is always better than non-readable code. Can you use some of the stuff from above to write your code? certainly! but good luck understanding it after a week.

If you have read this far I suggest forgetting everything you have read and actually pick up a widely supported style guide and study that. Is JavaScript a bad Language? I don't think so, I think it is only as bad as you make it.

Why did you create this "thing"?

I really liked the Idea of code golfing but quickly realized that it in itself is a game and has almost no place inside of a proper workplace. I also love those 60's scifi horror movies where the evil 'thing' is just some idea taken to the extreme in an impossible situation.

So this is my version of code golfing taken to an extreme. I also really like JavaScript and all the quirks that the language contains, this was a great learning experience.

Guides on writing good code!

Thanks

Special thanks to:

  • u/MissileEngineer for the repl.it on representing numbers in js as negated expressions

Contributing

If you want to contribute please open a pull request, I am always looking for ways to improve IJS.

About

πŸ‘Ί A bit of fun, taken too far

https://stevendixondev.github.io/IJScript/


Languages

Language:JavaScript 100.0%