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 - "closures"
I was interviewing a candidate for a senior UI dev position and I began to ask him stuff about closures, contexts, design patterns and others.
At some point, after failing to respond to most of the questions, the candidate looked at me and said something like: ‘I am amazed. You didn’t have a lot of toys when you were a kid. The PC was your only toy when you were a kid, right??’.
I looked at my junior colleague that was shadowing the interview and we couldn’t believe what the guy was asking. He was extremely serious and he was looking for a way to find an explanation for his failure.12
When you have over 10 years experience... and nothing to show for it due to closures, redesigns and private work.
It’s not making my job hunt any easier.8
Is it just me who sees this? JS development in a somewhat more complex setting (like vue-storefront) is just a horrible mess.
I have 10+ experience in java, c# and python, and I've never needed more than a a few hours to get into a new codebase, understanding the overall system, being able to guess where to fix a given problem.
But with JS (and also TS for that matter) I'm at my limits. Most of the files look like they don't do anything. There seems to be no structure, both from a file system point of view, nor from a code point of view.
It start with little things like 300 char long lines including various lambdas, closures and ifs with useless variables names, over overly generic and minified method/function names to inconsistent naming of files, classes and basically everything else.
I used to just set a breakpoint somewhere in my code (or in a compiled dependency) wait this it is being hit and go back and forth to learn how the system state changes.
This seems to be highly limited in JS. I didn't find the one way to just being able to debug, everything that is. There are weird things like transpilers, compiler, minifiers, bablers and what not else. There is an error? Go f... yourself ...
And what do I find as the number one tipp all across the internet? Console.log?? are you kidding me, sure just tell me, your kidding me right?
If I would have to describe the JS world in one word, I would use "inconsistency". It's all just a pain in the ass.
I remember when I switcher from VisualStudio/C# to Eclipse/Java I felt like traveling back in time for about 10 years. Everyting seemd so ... old-schoolish, buggy, weird.
When I now switch from java to JS it makes me feel the same way. It's all so highly unproductive, inconsistent, undeterministic, cobbled together.
For one inconveinience the JS communinity seems to like to build huge shitloads of stuff around it, instead of fixing the obvious. And noone seems to see that.
It's like they are all blinded somehow. Currently I'm also trying to implement a small react app based on react-admin. The simplest things to develop and debug are a nightmare. There is so much boilerplate that to write that most people in the internet just keep copying stuff, without even trying to understand what it actually does.
I've always been a guy that tries to understand what the fuck this code actuall does. And for most of the parts I just thing, that the stuff there is useless or could be done in a way more readable way. But instead, all the devs out there just seem to chose the "copy and fix somehow-ish" way.
I'm all in for component-izing stuff. I like encapsulation, I'm a OOP guy by heart. But what react and similar frameworks do is just insane. It's just not right (for some part).
Especially when you have to remember so much stuff that is just mechanics/boilerplate without having any actual "business logical function".
People always say java is so verbose. I don't think it is, there is so few syntax that it almost reads like a prose story. When I look at JS and TS instead, I'm overwhelmed by all the syntax, almost wondering every second line, what the actual fuck this could mean. The boilerplate/logic ration seems way to off ..
So it really makes me wonder, if all you JS devs out there are just so used to that stuff, that you cannot imagine how it could be done better? I still remember my C# days, but I admin that I just got used to java. So I can somehow understand that all. But JS is just another few levels less deeper.
But maybe I'm just lazy and too old ...5
And today in Laravel-land, how to take fluent APIs to the utmost consequences.
Better...? Seriously? All your lines got longer and you know have closures to run.10
Some time ago, I asked DevRanters if you would use US or UK version of word.
Most of you said, whatever.
I just found case for using both :D7
My definition of hell?
Being forced to debug nested callbacks abusing global variables & closures generated from from reflection...6
I'm really bad at this 😓1
I'm a C++/Obj-C programmer finding it ludicrously hard to switch to Swift.
I find that the constant ability (leading to very poor programmer code) to reduce syntax and add tokens reduces readability and nowhere is this more apparent that with closures.
I'm working through (to my shame) Ray Wenderlich's Swift course and the closure chapter has this:
PS I loathe K&R as much as I do Swift so it's all in Allman formatting for clarity.
let multiply: (Int, Int) -> Int =
(a: Int, b: Int) -> Int in
// do Something else
return a * b
Why oh why isn't this more simply and elegantly written as:
let multiply = (a: Int, b: Int) -> Int
// do Something else
return a * b
The equals sign shows clearly that it's a closure definition assignment, as does the starting 'let'. But this way all of the stupid excesses, like the 'in' keyword, the repetition of the params / return type only this time with useful labels and additional tokens are removed and it looks and reads much more like a regular function and certainly a lot more clearly.
Now I know that with the stupid ability of Swift you can reduce all this down to return $0 * $1, but the point I'm making is that a) that's not as clear and more importantly b) if this closure does something more than just one line of code, then all that complicated stuff - hinted to by the comment '// do Something else' means you can't reduce it to stupid tokens.
So, when you have a clousure that has a lot of stuff going on and you can't reduce it to stupid minimalism, then why isn't is formatted and syntactically better like the suggestion above?
I've mentioned this on the Swift.org (and got banned for criticising Swift) but the suggestions they came up with were 'use type inference' to remove the first set of params / return type and token.
But that still means the param list and return type are NOT on the same line as the declaration and you still need the stupid 'in' keyword!5
My god, I just had to use a very ugly hack involving HTML generation via string concatenation, passing a function as a parameter and closures.
Now I appreciate languages that achieve such things naturally even more.2
You can say you know a computer language to a decent level when you can in fact make useful programs with it.
- it manipulates the DOM, the DOM has Element, Nodes, TextNodes (all to be found on W3C documents with its own specs)
- useful functions are:
Also knowing that these return either HTMLElementCollection or NodeCollection because you have to iterate over it differently then
- == and ===
- dynamic typing
- avoid global variables
- nodes have parentNodes
- isNaN, undefined
- arguments don't have explicit types defined
Using this knowledge I built an antispam script for a particular server. It's good to know the model of a language, that it sits in your head and that you can use and understand the constructs when you want and how you want.1
Note : He gets paid more by his photoshooting jobs on the weekend, he's only at this job for his future citizenship application. That fucker. He's the type of fucker that will definitely gets rich but gets hated by everyone.
A funny quote and almost a true fact.
"Understanding closures, is like when Neo sees The Matrix for the first time".
YDKJS 'scope & closures'
How dense do you have to be to argue against "it creates additional closures" and "creating functions for built-in operators is an anti-pattern".
Come on!!! At least it's my last week here, I'll be done with this soon enough.1
Anonymous functions in PHP can be quite verbose, even when they only perform a simple operation. Partly this is due to a large amount of syntactic boilerplate, and party due to the need to manually import used variables. This makes code using simple closures hard to read and understand.
Opinion | According to you, how impressive is it for a high schooler to submit a "general purpose scripting language that supports Object Orientation, closures, higher-order funcs." as a project for college admission given that the applicant implemented it from scratch and you know that hard work!!! ?9
Explained my boss what callbacks are
Kudos for me because i showed this as well