Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "iterable"
-
You know who sucks at developing APIs?
Facebook.
I mean, how are so high paid guys with so great ideas manage to come up with apis THAT shitty?
Let's have a look. They took MVC and invented flux. It was so complicated that there were so many overhyped articles that stated "Flux is just X", "Flux is just Y", and exactly when Redux comes to the stage, flux is forgotten. Nobody uses it anymore.
They took declarative cursors and created Relay, but again, Apollo GraphQL comes and relay just goes away. When i tried just to get started with relay, it seemed so complicated that i just closed the tab. I mean, i get the idea, it's simple yet brilliant, but the api...
Immutable.js. Shitload of fuck. Explain WHY should i mess with shit like getIn(path: Iterable<string | number>): any and class List<T> { push(value: T): this }? Clojurescript offers Om, the React wrapper that works about three times faster! How is it even possible? Clojure's immutable data structures! They're even opensourced as standalone library, Mori js, and api is great! Just use it! Why reinvent the wheel?
It seems like when i just need to develop a simple react app, i should configure webpack (huge fuckload of work by itself) to get hot reload, modern es and jsx to work, then add redux, redux-saga, redux-thunk, react-redux and immutable.js, and if i just want my simple component to communicate with state, i need to define a component, a container, fucking mapStateToProps and mapDispatchToProps, and that's all just for "hello world" to pop out. And make sure you didn't forget to type that this.handler = this.handler.bind(this) for every handler function. Or use ev closure fucked up hack that requires just a bit more webpack tweaks. We haven't even started to communicate to the server! Fuck!
I bet there is savage ass overengineer sitting there at facebook, and he of course knows everything about how good api should look, and he also has huge ass ego and he just allowed to ban everything that he doesn't like. And he just bans everything with good simple api because it "isn't flexible enough".
"React is heavier than preact because we offer isomorphic multiple rendering targets", oh, how hard want i to slap your face, you fuckface. You know what i offered your mom and she agreed?
They even created create-react-app, but state management is still up to you. And react-boierplate is just too complicated.
When i need web app, i type "lein new re-frame", then "lein dev", and boom, live reload server started. No config. Every action is just (dispatch) away, works from any component. State subscription? (subscribe). Isolated side-effects? (reg-fx). Organize files as you want. File size? Around 30k, maybe 60 if you use some clojure libs.
If you don't care about massive market support, just use hyperapp. It's way simpler.
Dear developers, PLEASE, don't forget about api. Take it serious, it's very important. You may even design api first, and only then implement the actual logic. That's even better.
And facebook, sincerelly,
Fuck you.17 -
So I tried to start learning Spring 5
How the fuck do you guys do it? Holy shit.
30 seconds in:
"Spring really isn't hard, you start with this request handler interacting with a view parser..."
Alright, sounds good
2 minutes in:
"So in order to use SpringResponseDriverActionHandlerServiceRequesterService you'll need to import com.org.java.spring.util.driver.comagain.request.response.request.drivers and include this 37 level deep nested XML property and finally extend this abstract class and implement it over an iterable list with this specific annotation aaaaaaand.... Done"
> Hello, world!
"See, spring is easy!"11 -
I'm currently rewriting perfectly clean and functioning Scala code in Java (because "Enterprise", yay). The amount of unnecessary boilerplate I have to add is insane. I'm not even talking big complicated code but two liners or the lack of simple things like a range from 5 to 10.
Why do I have to write
List<Position> occupiedPositions = placedEntities.stream()
.flatMap((pe) -> pe.occupiedPositions().stream())
.collect(Collectors.toList());
instead of simply
val occupiedPositions = placedEntities.flatMap(_.occupiedPositions)
Why on earth does `occupiedPositions.distinct` suddenly become a monstrosity like `occupiedPositions.stream().distinct().collect(Collectors.toList())` where the majority of code is pure boilerplate? And this is supposed to be the new and better Java8 api which people use as evidence that Java is now suddenly "functional" (yeah no, just no).
Why do APIs that annotate parameters with @Nullable throw NullPointerExceptions when I pass a null? Why does the compiler not help prevent such stupidity? Why do we use static typing PLUS those annotations and it still crashes at runtime like every damn dynamic, interpreted language out there? That's not unfortunate, it's a complete waste of time.
Why is a simple idea like a range from x to 10 (in scala literally `x to 10`) not by default included in Java? There's Guava's version of Range which does not have a helper for integer ranges (even though they are the most used ones). Then there's apache.commons version which _has_ a helper for integers, but is strangely not iterable (wtf I don't even...).
Speaking of Iterable: How difficult could it be to convert an abstract Iterable<T> into a concrete List<T>? In scala it's surprisingly `someIterable.toList`. I found nothing like that so I took to stackoverflow where I found a thread in which people suggested everything from writing your own ListUtils helper class, using Guava (which is a huge dependency!) to using the new Java8 features inline (which is still about three lines long). I didn't know this was such a hard problem in computer science, TIL.
How anyone can be productive in this abomination of a language is beyond me now, even though I've used it for many years while learning to code (back then I didn't know there were much better ways to do things). The only good part is that I have to endure this nonsense for only about 3 days longer then I'm free again!12 -
Java's shitshow, or why I'll never like java, the language:
The fact that you cannot read the length of an iterable at any point in time without iterating through it. Did I just read this from DB? Yes, I did. Do I know how many items I read? No. Why? Because fuck the designers of this shit language and all its shitty third-party libraries. 😠😠😠18 -
Disclamer: I don't want to give out what app I am talking about, so all names will be random to just represent the nonsense and my frustration.
So I was working with that app's API....
To begin with, some retrieved Objects have collection (iterable structure) of "Thing" objects, called "Things". But... there can be max one element in that particular collection!
Ok... I get it... I might exaggerate a bit... fine, let it be.
I had to mention it for the further part, and also got to mention that "Thing" objects are globally available and predefined, and Objects can only choose one, unused "Thing".
To the point.
Someone thought it would be good to separate representation of one structure into two classes.
We have collection of "A" objects ("As"), which have "Name", "Things" and other, mostly GUI/config related attributes.
Collection "Bs", of "B" objects, they have "Name" and rather lower-level attrs.
The "As" and their attributes can be set in the GUI, but the list where you do it is named "List of Bs" and vice versa.
Interesting, huh?
I had to use both "A" and "B" definition for given name, so I tried to map it... and things gone South.
Collecions have "Get" method with name as an argument.
But it turns out that while the "A" use its GUI name all the time, "B" uses either name that can be found in "As" or, if not all "Thing" objects are used, the "Thing" names.
Example:
global "Things" = "t0", "t1"
"As" = "a0"("t0"), "a1"("t1") -> "Bs" == "a0", "a1"
"As" = "a0"("t0"), "a1"() -> "Bs" == "a0", "t1"
"As" = "a0"(), "a1"() -> "Bs" == "t0", "t1"
That means if at least one of "A" objects have empty "Things", then the mapping will fail.
Only solution is that the app works only partially when any of "A"'s "Things" is empty, so I might raise error too, but I have to provide solution that will work even in the cases when the app don't care... so... not gonna happen.1 -
Take this how you will:
"The more experienced a respondent is, the more likely they are to say blockchain technology is an irresponsible use of resources."
Old farts refusing to budge from their ways, or old farts knowing better?
https://insights.stackoverflow.com/...4 -
[`script(x) ` for x in iterable if condition else command] [#:#]
Complex code in one line
#python
PS. That can be more complex, but I am lazy to continue with this