Reverse Engineering One Line of JavaScript
alexkras.com
alexkras.com
Take the simple, quick initialiser:
foo ||= 1
Instead of the more verbose if foo.nil?
foo = 1
end
Undoubtedly, the first line is a much cooler version, but like skinny jeans was once cool - getting in and out of them far outweighed the cool factor.It's like saying F1 racing is cool but it does highlight a trend of reckless driving in highways.
cyberferret explicitly said it's a good idea to avoid shorthand methods because new programmers don't understand them, and you're making the argument that they're OK because experienced programmers will understand them. The essence of your argument is that if you've used the language enough to know what the or-equals statement means then you'll know what it means. I'm not convinced that's a good reason.
Working on emulation software I commonly run across snippets such as `res = !!iRegisterVal` which results in some C newbies scratching their heads as to why a useless double negation would be there. But for more seasoned developers its intent can pretty easily recognized...
For example,
def user_signed_in?
!!current_user
end
This returns "true" or "false", instead of a (truthy) User object or a (falsy) nil.So rather than write `foo ? TRUE : FALSE` or being more explicit `(foo != 0) ? 1 : 0`, you can just do `!!foo`.
foo = 1 if foo.nil? my_fancy_named_variable = my_array.map{|x| do_processing(x)}.sort_by{|x| x.value} unless some_very_long_conditional_that_breaks_readability
This is not very readable, and I would actually use multiple lines to format a call like this.This is different from huge one-liners, which I think are almost always inappropriate.
That's the cynical way of looking at it (also sounds like you haven't read or written much go code). As someone who has written go code full time for 2 years, here's another perspective.
It's not about "the programmer is too dumb", it's about people of varying skill levels working on really, really large code bases. A junior, mid, and senior can all work on the same business problems. Conversely, if you have a senior ruby dev, they will write these terse, elegant, functional-chained methods that require much time to digest and conceptualize. This leads to wasted programmer time. All the elegance and terseness I have seen in the wild, it has never once saved anyone time, minus the few 10's of seconds it saved the programmer who wrote it who thought they were being "clever" because they wrote that if statement in one line instead of three. Code is maintained and read more than it is written. Go encourages writing code for the reader.
Also, "piles of error handling" is preferred. Go treats errors as values that you can program around. It took a while for me to shed the bad habits of languages prior (ruby, python, javascript, java and c#) but afterwards I fell in love. Handle your errors -- right there where they happen. Never again do I have to deal PokeMon try/catching.
It's much cleaner, doesn't pollute the code with extra stuff not pertinent to the problem (if, end), and keeps it straight to the point.
It's not at all different to tons of other constructs, like:
x += 1;
or: i++;The construct in parent assigns 1 if foo is "falsey", not strictly if it is nil. Even if foo is already initialised but contains a "falsey" value it will be assigned 1.
I bet there are a myriad frameworks to do it aswell.
Deobsufucizer.js Reverse-sj.io
IMO, deobfuscation is a subset of reverse engineering - which at a push I would define as "taking a program from the form it is distributed into a preferred form for modification/understanding".
Q: Whats that math/graphing app you have screenshots of?