If anyone is curious (or lazy), FuckIt works by opening up the AST [0] and wrapping almost every statement (except those that declare functions) in a silent try-catch block [1].
I tried doing something similar with Perl, which as I understand matters does not actually have an AST. It does have something called "source filters", which I gather are almost entirely unlike Lisp macros; despite that seeming like the best available option (the filter, in this case, being one which wraps the whole script containing 'use fuckit' in a quoted eval whose $@ is ignored), the closest I got with it was segfaulting the Perl interpreter, which certainly counts as some sort of result.
There's something to be said about the quality of programming API-kids do these days, if FuckIt.lang projects are so popular. Not to jab this project itself by any means, but hiding defects "on your way to doing that million dollar demo to investors" makes my skin crawl. How many con men are in this industry? This is damn sad. If you need a tool like this beyond your private debugging needs, you don't understand what you're doing and should step back and take the time to reason things out.
I don't think this is so much a tool as a "because I can and it's funny" project. Like Edison -> Serial "adapters" and various other hilariously, uselessly malicious things it's possible to create.
Putting aside the fact that this project is probably satire, how is this a "these days" thing? Code in the bad old days was just as littered with ON ERROR RESUME NEXT, if (err) {/*this cant happen*/ return;} and catch {/*do something here*/}
I can't help but facepalm when I read things like this. Even if it works, the name of the project should have given the commenter some clue that it was a joke.
As for the "these days" comment, why is it that people are repeatedly convinced that human habits have changed that drastically in their lifetimes? This "change" is the result of perspective, no more, no less.
OTOH, I would actually say that things have improved of late.
Just in the last couple of decades we've seen what I think are the first serious approaches to error handling. Think about things like the Abrahams Guarantees, or all those fun category-theoretic analyses that the functional folks keep generating.
And then the stakes have gotten higher. Thirty years ago, if a user gave a program messed-up data, then we could shake our heads and say, "Stupid user." Today, large companies put mission-critical functionality on the web, opening it up to people with both the time and the inclination to generate messed-up data in an attempt to bring the system down.
The result of all this is that, just in the last one or two decades, we've finally seen a significant number of large software packages that actually work.
There are a lot more computer software jobs today than there were 30 years ago, and this caused an influx of clueless gold-rushers trying to get in. There always were bad programmers and buggy software, it's just that today there's a lot more of both (both in terms of percentage and total), simple as that.
They are popular to get cause they are funny. They are popular to make because they let you experiment around with metaprogramming magic in the language to some extent.
I plan on using this next time I have to do some quick and dirty python hacks at work.
Sometimes the effort involved in "properly" initializing someone's module far outweighs whatever potential benefit you get out of the module - this seems to subvert that quite nicely.
This module is not satire, and the existence of this module does not indicate anything about the quality of programmers of this generation.
For those who think so, try doing some machine learning, data handling code, or even web crawlers. Error tolerance is much needed.
For scientific experiments, sometimes the results of the experiment is still valuable even if there's a trivial bug (malformed row). A partially-correct execution is still more information than an unhandled exception causing an early exit.
Having worked on all of those, this module is satire and foolish to use in normal code. The rule is protect your boundaries and whenever data comes in it requires
careful handling and thoughtful error policies. The entire notion of taint from Perl comes to mind.
If anything, your error messages are more important then.
Definitely accurate. I've spent some time working on a web crawler with a friend, and eventually you just realize that no matter what you do, requesting pages is going to break, hyperlinks lie, content is borked, ect ect ect. After countless hours debugging you just say "FUCK IT, WE'LL JUST GO THE NEXT PAGE". And really, that's what you would have done anyway if you had filtered the page out...
At one point in a previous life, I was the administrator for HP Quality Center at my company. On the good side, HP exposes the entire workflow in VBA (ok, I guess that isn't that good actually, but still better than black box).
On the horrible side, EVERY SINGLE FUNCTION in that application began with the line "On Error Resume Next". I quite nearly quit on the spot the first time I looked at the code. A couple years later, I would regret that decision.
This gave me an idea which is probably terrible. Instead of eating errors or ignoring them, use genetic programming on the code until it passes all your tests and doesn't give any errors. It would still be terrible to actually use, but it might actually get the code to work.
import fuckit
from string import ascii_lowercase, digits
from random import choice, randint
def defuckify(test_fn, fn_name, n_arguments):
''' Randomly generate functions until the test passes
'''
defuckified_fn = ('def %s(' % fn_name)
for i in range(n_arguments):
arg_name = ('arg%d,' % i) if i != n_arguments else ('arg%d' % i)
defuckified_fn += arg_name
defuckified_fn += '):'
exec('def '+ fn_name + '():\n pass\n')
while not test_fn():
for i in range(randint(100,10000)):
defuckified_fn += choice(' \n,[](){}\'"=+-*/%:'+ ascii_lowercase + digits)
with fuckit:
exec(defuckified_fn)
print(defuckified_fn)
Edited to use fuckit instead of try/catch
Edited again to add that it has been over an hour and it hasn't been able to make a function that returns 3
If anyone's interested, the likelihood of a string with a length between 100 and 1000 characters which contains characters randomly selected from digits, lowercase letters, spaces and the following characters: \n,[](){}'."=+-*/%: is valid python is something like 0.015% (determined empirically)
I just ran the part that generates a function with a random string as the body and called the function that it generated, and counted the calls that didn't throw anything. As I threw it together in all of 5 minutes I'm sure there are flaws in the methodology
Also the defuckify code I posted is not exactly right, as it was sort of a joke but it's pretty easy to fix
Awhile back I tried to make a markov chain generator that consumed a bunch of source code of javascript (or whatever language) and then spit out random code to execute with fuckit.js.
You could try something similar to easily produce random python code that will be correct a much higher percent of the time.
The problem was comments screwed it up since it would randomly put comments in code and comment out actual code.
I use this on one of my servers for storing gpg encryped mails. I wanted to make a FUSE module out of it but was too lazy. Of course you do read the data at one point but on a different system.
yes, there is. Imagine yourself on an airplane on your way to doing that million dollar demo to investors. And some bozo decided to do a last minute change to log something inconsequential that actually started throwing an error. Now your demo page looks like "Oops! We screwed up!". You have no time to debug this. So you just plugin in this module and see if it still good enough for your demo. If it does, you saved yourself a million dollars. If it doesn't...
Git? We're hustling out our MVP to disrupt the industry paradigm, we don't have time for version control! Next you'll tell me hacking on our live server is a bad thing...
I'm kinda tempted to use it in a script I'm making to scrape one of my government's databases, because they have a lot of malformed data I don't want to deal with, and because fuck it.
Prototyping - you just made an interface change that normally would have to be plumbed though hundreds of files just so you can experiment with one of them.
That's the licence for the license, not the license for the code itself.
The licence for the code itself is "0. You just DO WHAT THE FUCK YOU WANT TO." The license for the license is similar, with the caveat that you're required to change the name if you change the content. Which makes sense; we wouldn't want confusion about what the WTFPL refers to.
i've used this for a while now--really useful debugging tool in my workflow. Does exactly what it says on the tin.
just wrap the offending module and get on with your life; and in those rare (for me) instances where you still get errors, this module supports chaining syntax--declarative syntax, to say the least:
Because we're all adults with functioning senses of humor, where 'all' is defined as a 'mostly' whose exceptions tend to be both immediately obvious and unbearable in social settings.
[0] http://en.wikipedia.org/wiki/Abstract_syntax_tree
[1] https://github.com/ajalt/fuckitpy/blob/master/fuckit.py#L70-...