Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "js callback"
TABLE BASED WEB DESIGN
I was surprised there were no rants about this topic before I realized it was more than a decade back 😳
We've never had it better! So to help add a little perspective for all those ranting about what is unarguably the golden age for web developers... let me fill you in on web dev in the late 90's;
HTML was simple and purely a markup language (with the exception of the marquee tag). The tags were basically just p,ul,ol,h*,form inputs,img and table and html took 10 minutes to learn. Any style was inline and equally crude - anything that wasn't crude could not be trusted and probably wouldn't render at all in most browsers (never mind render correctly).
There were rumors of a style TAG and something called a cascading style sheet which were received with much skepticism since it went against the old ways and any time saved would be lost writing multiple [IE version specific] style sheets for each browser just to get it to work - so we simply didn't.
No CSS meant the only tags you had to work with to create a structured layout were br, hr and table... so naturally EVERYTHING was in nested tables! JS callback hell can't touch this! - it was not uncommon to have 50+ nested tables all with inline style in a single page which would be edited without any dev tools or linting.
You would spend 30 minutes scanning td tags until your eyes bled to find something, make a change, ftp the file to the server, reload the web page and then spend 10 minutes staring at the devastation on your screen convinced you broke
the internet before spotting an un-closed td tag with your bloodshot eyes.
Tables were not just a silver bullet - they were the ONLY bullet and were in the wild west!
Q: Want an inline form or to align your inputs left?
A: Duh table!
Q: Want a border with round-corners, a shadow or blur?
A: That's easy! Your gonna want to put that table in the center cell of another table then crop a image of the border into 6 smaller images to put in the surrounding cells... oh and then spend 10 minutes fucking with mystical attributes like cell-padding and valign to get them flush.
...But hey at least on the bright-side vertically & horizontally centering stuff was a breeze!23
We're using a ticket system at work that a local company wrote specifically for IT-support companies. It's missing so many (to us) essential features that they flat out ignored the feature requests for. I started dissecting their front-end code to find ways to get the site to do what we want and find a lot of ugly code.
So i dig farther and farthee adding all the features we want into a userscript with a beat little 'custom namespace' i make pretty good progress until i find a site that does asynchronous loading of its subpages all of a sudden. They never do that anywhere else. Injecting code into the overcomolicated jQuery mess that they call code is impossible to me, so i track changes via a mutationObserver (awesome stuff for userscripts, never heard of it before) and get that running too.
The userscript got such a volume of functions in such a short time that my boss even used it to demonstrate to them what we want and asked them why they couldn't do it in a reasonable timeframe.
All in all I'm pretty proud if the script, but i hate that software companies that write such a mess of code in different coding styles all over the place even get a foot into the door.
And that's just the code part: They very veeeery often just break stuff in updates that then require multiple hotfixes throughout the day after we complain about it. These errors even go so far to break functionality completely or just throw 500s in our face. It really gives you the impression that they are not testing that thing at all.
And the worst: They actively encourage their trainees to write as much code as possible to get paid more than their contract says, so of course they just break stuff all the time to write as much as possible.
Where did i get that information you ask? They state it on ther fucking career page!
We also have reverse proxy in front of that page that manages the HTTPS encryption and Let's Encrypt renewal. Guess what: They internally check if the certificate on the machine is valid and the system refuses to work if it isn't. How do you upload a certificate to the system you asked? You don't! You have to mail it to them for them to SSH into the system and install it manually. When will that be possible you ask? SOON™.
At least after a while i got them to just disable the 'feature'.
While we are at 'features' (sorry for the bad structure): They have this genius 'smart redirect' feature that is supposed to throw you right back where you were once you're done editing something. Brilliant idea, how do they do it? Using a callback libk like everyone else? Noooo. A serverside database entry that only gets correctly updated half of the time. So while multitasking in multiple tabs because the performance of that thing almost forces you to makes it a whole lot worse you are not protected from it if you don't. Example: you did work on ticket A and save that. You get redirected to ticket B you worked on this morning even though its fucking 5 o' clock in the evening. So of course you get confused over wherever you selected the right ticket to begin with. So you have to check that almost everytime.
Alright, rant over.
Let's see if i beed to make another one after their big 'all feature requests on hold, UI redesign, everything will be fixed and much better'-update.5
Boss comes in and gives me some js code for syncing data (he hacked it together the other day, really messy with like 5 callback lamdas stacked into each other)
Boss: Make it faster and more reliable and add some progress indicator
So i look at the code and he literally pulls all the data as one json (20+ MiB). Server needs multiple minutes to generate the response (lots of querys), sometimes even causing timeouts....
So i do what everyone would do and clean up the code, split the request into multiple ones, only fetching the necessary data and send the code back to my boss.
He comes in and asks me what all this complexity is about. And why i need 5 functions to do what he did in one. (He didn't -.-). He says he only told me to "make it faster and show progress" not "to split everything up".
So I ask him how he wants to do this over HTTP with just one request...
His response: "I don't care make it work!".
Sometimes i hate my job -.-11
FUCK THE RECRUITERS WHO ASK US TO MAKE AN ENTIRE PROJECT AS A CODE TEST.
Oh you need to scrape this website and then store the data in some DB. Apply sentimental analysis on the data set. On the UI, the user should be able to search the fields that were scraped from the website. Upon clicking it should consume a REST API which you have to create as well. Oh and also deploy it somewhere... Oh I almost forgot, make the UI look good. If you could submit it in one week, we will move towards further rounds if we find you fit enough.
YOU KNOW WHAT, FUCK YOU!
I can apply to 10 others companies in one week and get hired in half the effort than making this whole project for you which you are going to use it on your website YOU SADIST MOTHERFUCK
I CURSE YOUR COMPANY WITH THE ETERNITY OF JS CALLBACK HELL 😡😤😣9
Dont get me wrong. I have to use angularjs and nodejs in my work so I am quiet familiar with them. Js csn be usefull and make things easier and simpler but it comes with a price... You can do someting in third amount of effort but you have to debug three times more. Yes you can use typescript but thats not an option always. What about single threaded design yes you can use callback and promises but really? Thats the way it is should be working? And what about that if you need one functionality than you dowbload a module but with that you are started to depend from other 737373737 packages.
I am just simply not getting this hype around JS.25
Php array methods, all of them, or should i say hash methods
They should fix them. I mean they should fix placing of callback and subject params, because.
Or they should make array a object like js4
Just got my first callback for a technical interview in JS tomorrow morning.
"That's cool fam, but you just lost any ability to write anything in it."
You know you have chosen the wrong JS library when you read a function definition like this:
validateSync(schema, options, callback)
Related to https://www.devrant.io/rants/838679
I guess I have accidentally found how "Async" library really works. This is how you use async:
As you can always see <array-of-functions>'s length, what you need to do is create a global counter, and wrap the <final-callback> in something named <wrapped-callback>
Whenever any function in <array-of-functions> executed, call that <wrapped-callback>.
The <wrapped-callback> works as follow:
if the global counter is less than <array-of-functions>'s length, simply increase the counter value.
If the global counter is equal to <array-of-functions>'s length,
execute the original <final-callback>
Proud of myself, somehow :v
And yes, there is easier way to do this.3
My brain used to be normal and I used to think callback is bizarre.
Now I understand callback and my brain has become bizarre.
"Let me just call this function"
"Oh I need to do something with the return value. Callback"
"Oh I need to do something with that value too. Another callback..."
"Oh, again. Another callback"
"I should have thought about this more beforehand..."1
One of my greatest personal challenges has always been to try and balance "good enough asap" and "but I know how to do this better if I spend a few more days on it". I like to think I've gotten better at it; Leaving things be if they are to spec and keeping my implementations consistent with existing work even if I disagree with it being ideal.
Which makes this new project we're taking over my trial of fire. The combination of the codebase - a Vue app from a previous rant where Vue is mostly used as a callback function to alter the dom using the document api in plain js - and the expectation for us to implement new features and minor tweaks to a user base of literally 4 people is like a charicature of the type of work I struggle with.
Even writing all this I'm evaluating if I'd be able to remake it all from scratch fast enough to sneak it in without anyone noticing.
It's an uh, "opportunity" for me to learn how to handle these situations, I suppose. Have mercy.1
JS' array function forEach. Why. Why does it exist? How is a function with a callback better than a freaking simple language feature like for of? If I recall correctly, forEach is older than for of, but people still use it nowadays, and too frequently...
Hate it, definitely.
Also, talking about enumeration in JS, Object's "static" method entries. I can't see how it can't be an instance method. Same for keys and values, but I usually don't care about them.12
Sometimes I forgot which one is which.
So I decide to make all of my functions has double-edge functionality by creating calling "runCallbackAndReturnValue"
Do you think this is a good idea or not?
Why, or why not?18
I'm porting an OpenGL project to work with WebAssembly, I'm using emscripten to compile/generate the 'glue' to JS. Sofar I'm able to render my gl code properly through the glfw3 framework. I know you can use emscripten callbacks for input, however I was hoping to keep my existing glfw3 callback setup, that said the only callback that seems to be working properly is mouse position, window resize, keyboard, etc never get called. If anyone knows how to enable these I'd be super greatful!1
Hey my bros. I’m trying to create a simple messenger bot just for fun using this tutorial:
But it seems that I’m kinda stuck with setting up the webhook on the fb page, it displays an error
“the url couldn’t be validated, callback verification failed...”
I googled for answers but it seems that it doesn’t work for me. Can you please help me? Thank you so much.4
I got to a point where I have a multi-level recursive promises within loops and my mental map is by far not enough to process this. I wish there were some visualisation tools for this - though I don't even know how it could look like. All I know is that at some point I'm returning a wrong promise and the recursion is not correctly handled.7