TECH | Stop using JPA/Hibernate · Blog de Laurent Stemmer

Here an example of a JPA entity (using Lombok for “simplicity”): <sarcasm quotes mine>

@Entity
@Table("offer")
@EqualsAndHashcode
@NoArgsConstructor // for Hibernate
@Setter // for Hibernate
@Getter
public class BankAccount {
    @Id
    @Column("id")
    private String id;
    @Column("opened")
    private boolean opened;
    @OneToMany(fetch = LAZY) // ...simplified
    private Set ownerIds;
}

Source: TECH | Stop using JPA/Hibernate · Blog de Laurent Stemmer

Through a very long series of unfortunate circumstances, I was backed into using Java/Spring/Hibernate/Angular in a doomed project. This page had me nodding my head in agreement, and this code reminded me of the Lombock portion, which was its own special nightmare. I just went looking for what I had written for that project, and it would appear that I’ve totally deleted it. I normally keep everything, so I can go back and refresh my mind when I recall some particular technique I’ve used in the past, so this should tell you something about the brain damage using this stack will incur.

I’m going to digress to setup a point. I used gvim for many years, with a complicated setup, using NerdTree and several other plugins, to give me a UI with my project’s directory on the left side, and tabs of open files on the right. At some point, I got tired of fiddling with the configuration, and finally started using someone’s massive-but-well-integrated ~/.vim configuration from a GitHub repo. Finally, I realized that I was spending all this time and effort on making gvim work just like Sublime Text did out of the box, and I could just start with that. So I did. While I’ve flirted with other editors (notably, Visual Studio Code, and the excellent IntelliJ, while working on Java), I’ve basically stuck with it for about 7 years now.

Here’s the parallel. The thing that fans of the Java ecosystem can’t admit to themselves is that this whole stack: Java, Spring, Hibernate, Lombock, Javascript, AngularJS, etc., et. al., ad naseum… is all just a terrible pile of Jenga blocks which putatively exist to give you a functional environment like… wait for it… Ruby on Rails! Lock, stock, and out of the box. It seems to me that the motivation of people who still like to use gvim when Sublime Text and Visual Studio Code exist is the same sort of motivation of people who like to use a Java stack over something like Rails. Maybe they’ve done it so long, they can bang out the boilerplate with their eyes closed. Maybe they like the way you have to do everything explicitly. Maybe it makes them feel like a hacker.

All of the code above reduces to this in Rails:

class BankAccount < ApplicationRecord
    self.table_name = 'offer'
    belongs_to :owner
end

In an absolutely brilliant display of one of the biggest problems with using this Java stack, I went to remind myself what the @Table("offer") directive does. I am pretty sure it specifies the actual SQL database table name storing the instances of this object, but I literally can’t find any references to this pattern in the Lombok documentation. It is only through inferring it from a StackOverflow question that I am reasonably confident that this is, in fact, what it is doing. And if it weren’t for Spring and Hibernate and Lombok, there’d be about a hundred more lines of boilerplate code in that single class file.

The top comment thread on the HN discussion about this blog post points out just how bad of an ORM Hibernate actually is. With 15 years of experience with Rails under my belt, I can assure you that almost none of those issues apply to ActiveRecord. Of course, I’ve seen people complain about AR, but I think their arguments are always exaggerated, and probably come from a place of general discontent with having to use Rails at all. People like to complain that Ruby is “slow” because it is interpreted, but it’s precisely that on-the-fly reflection/interpretation that allows ActiveRecord to be so good at being an easily-programmed and powerful ORM. It’s trading machine time for ease of development and readability, and I have yet to see a situation where that was a bad tradeoff. When I encounter speed problems with using Ruby, I do something else. Either I optimize the loops, or push more processing to the database, or write the heavy-duty computation in something else entirely, like R.

While I’m on the subject of ORM’s, I find EntityFramework just as bad as Hibernate. I suppose it’s just the nature of an ORM in the context of a compiled language. After giving it a real college try, I gave up on it. I wrote a serious application in Visual Basic and C# which accessed the database through a library of functions wrapping raw SQL, and called them from the WinForms side, and it worked out very well. I’m glad I didn’t try to force EF to work.

So, sure, rag on Rails. Call it slow. And, yes, compiled Java will always be “faster” than interpreted Ruby, but all the Java web sites I have to interact with are noticeably laggy and sluggish, compared to my apps, so there’s something to be said about the actual implementation, over the theoretical concept. While whole teams of “Java” devs are still writing class files in Java (and Javascript), for their object models, I’m done with my app, and moving on to the next one.

So, yes, by all means, please stop using JPA/Hibernate, but, I would go one step further, and advise people to just stop using Java for web apps entirely. That horse got passed 15 years ago. Even if you don’t like Rails, there are at least a few other stacks that would be far more productive than Java for web apps these days. Heck, I’d try to do Javascript on the frontend and backend before I’d try doing Java again. <shiver>

And that’s my “2 minutes of hate” for today.

Posted in Programming | Tagged , , , , , | Leave a comment

Build Your Own Database Driven Website

I don’t remember what prompted me to remember this book, but it was, perhaps, the biggest influence which has shaped my career. I had already been a programmer since I was a kid, and I had already written a couple of well-received programs on my job by the time I bought it, but I had actively avoided learning about databases, in order to focus on other Windows and Visual Basic, and I hadn’t gotten long-enough arms to break into web programming until then. Thank goodness, too, as it was all cgi-bin Perl stuff leading up to PHP. Yuck!

Reading books on programming is never fun for me. I’ve tried to read a couple on Ruby and Rails, and I just can’t get through them. The problem is that the ratio of stuff I already know to the stuff I don’t is so high, I can’t slog through it. I get too bored while trying to get to something new to me, and put it down. This book, however, hit me right between the eyes. It was the perfect book for me at the time. It was very thin, and there was zero fluff. I rewrote my FrontPage blog site in PHP in a week with the help of this book, and I was off and running. I’ve been doing primarily web app programming ever since.

Anyway, I just am fond of the memory of this book, Kevin Yank, who wrote it, and SitePoint, which was started around these books. This version is old and out of print, of course, and he seems to have retired now. If so, good for him. Thanks, Kevin.

Posted in Programming | Tagged | Leave a comment

The College Admissions Scandal

I didn’t pay any attention to the recent college admissions scandal, because I just didn’t care. It affected a strata of society that I can’t even smell. It didn’t affect me. At all. I thought it was ridiculous that so many people got collectively upset about it, because it’s just the way the world works. The documentary points out that it’s always been possible to give an indecorous amount of money to a university to get a placement. $50M to Harvard will get your kid in, but do you realize how little money $50M actually is when you’re a multi-billionaire?

I think the public backlash was so significant because it brought the pay-for-play action down by an order of magnitude. Instead of being the realm of billionaires, it made it accessible to the $100-million-aires. It involved people who were D-list celebrities and popular YouTubers. Combined with the fact that people feel entitled to get incensed by anything and everything on social media these days, this scandal led to an out-sized reaction.

Parents went to jail for being conned into a payola scam, when they didn’t even make checks out to the coaches. The guy at the center of it all flipped immediately, sang like a bird, and is still free. The colleges kept all the money. What about the athletic directors who looked the other way, while their coaches accepted bribes? Making Lori Laughlin-types go to jail for a few months might make the Twitter rabble feel better, but it is not justice.

The DOJ held press releases about this case, because they want “us” to feel that they “did something,” but do you realize how few spots were actually affected, and how little shutting this down matters? Singer admits to helping 750 families over 25 years. There are 7 universities listed in the Wikipedia page on the scandal. I quickly searched for the enrollment number for each, divided by 4, and added them up into a back-of-the-napkin estimation of what must have been around 1,175,000 possible admission slots over this timeframe. We’re talking maybe 1-5 slots at one of these schools in a year, out of 1,000, 5,000, or even 10,000 freshmen. People are starting to sue about this, but if you didn’t get into one of those schools during this time, it’s pretty hard to blame Singer’s involvement unless you can specify which particular non-athlete took a slot for your prospective sport.

So nothing really changes here. These elite schools continue to be untouchable. The costs of higher education continues to rise at three times inflation. The athletic directors still run the schools. People will continue to try to find cracks in the process, and games will still be played in athletic recruiting. And, as the last line of the documentary pointed out, the “back door” is still open to the billionaires. The DOJ hasn’t actually done a single thing of significance here.

This is what aggravates me about the scandal. Not the fact that it existed, but the fact that when it blew up, nothing that matters to anyone has changed, and I knew this would be the case. In fact, if you want to get really cynical about it, I almost see this as the billionaire-class whipping the government into action to stop the 100-million-aire class from encroaching on what they perceive as their territory. This is why I didn’t give a crap about it before, and why I care even less about it now. All the wrong things are being addressed here, and there’s literally nothing I can do about it.

Posted in Politics | Tagged | Leave a comment

The Gervais Principle II: Posturetalk, Powertalk, Babytalk and Gametalk

Finally, Sociopaths and Losers speak rarely to each other at all. One of the functions of the Clueless, recall, is to provide a buffer in what would otherwise be a painfully raw master-slave dynamic in a pure Sociopath-Loser organization. But when they do talk, they actually speak an unadorned language you could call Straight Talk if it were worth naming. It is the ordinary (if rare) utilitarian language of the sane, with no ulterior motives flying around. The mean-what-you-say-and-say-what-you-mean stuff between two people in a fixed, asymmetric power relationship, who don’t want or need to play real or fake power games. This is the unmarked black triangle edge in the diagram.

Source: The Gervais Principle II: Posturetalk, Powertalk, Babytalk and Gametalk

I am re-reading the whole series, because it came up as a response to something I said on HN. Basically, I had reinvented this 3-layer dynamic from first principles, based on my observations of the past few years of my career. Now that someone pointed me back to it, I remember reading it originally, but this was written twelve years ago now.

Anyway, this passage really resonates with me. Every time I’ve gotten face time with a serious power broker in a company, this has been true. No games. No BS. Just straight down to business. I have something to say that will help the organization, and they’re ready to hear it and incorporate it. It never accomplishes the full intention, but I understand that they have a lot more pressures that I can see from my vantage point.

… for Sociopaths, conditions of conflict of interest and moral hazard are not exceptional. They are normal, everyday situations.  To function effectively they must constantly maintain and improve their position in the ecosystem of other Sociopaths, protecting themselves, competing, forming alliances, trading favors and building trust. … They never lower their masks. In fact they are their masks. There is nothing beneath.

Though distant from our worlds, criminal worlds have the one advantage that they do not need to maintain the fiction that the organization is not pathological, so they are revealing to study.

For me, as a non-sociopath, this is a source of continual failing: to recognize that the the people pulling the levers of power in the organization are, in fact, sociopathic, and out for their interests, without regard for anyone else’s feelings or fortunes, not mine, or even necessarily the organization’s. Forgetting this base and simple fact has bitten me in the rear end more times than I can count.

Posted in Technology | Tagged | Leave a comment

Harvey Weinstein, Again.

I watched Untouchable the other night. I thought it was closer to its 87% rating on Rotten Tomatoes than the 71% at Metacritic they list on the IMDB page. After reflecting on what I saw, what struck me about it was how depraved Harvey is, and I don’t mean about all the obvious rape and assault. The problem is actually much worse than it appears, and it’s already pretty bad. “They” say rape isn’t about the sex, it’s about power. At least, in this case, “they” are exactly right, and spectacularly so.

Look at his second wife. Smokeshow! And not just a trophy; a successful woman on her own. He had 2 kids with her, so they had sex at least twice. She seemed honestly taken aback when the scandal broke. This activity is something, given his schedule, I can credibly believe that he could hide from her. In my estimation, she spoke from a place of relative normalcy about the marriage, so I’m relatively sure he could have been getting at least some sex at home.

Hugh Hefner built a media empire on the “backs” of some of the most beautiful women in the world. In the process, he had scores of willing, live-in girlfriends for decades, even though he wasn’t a great-looking guy. He was rich. He was connected. He could give these women a boost in finding fame and fortune. I watched The Girls Next Door, and read about what happened afterward, because it was fascinating to see how all of this worked. The “naked” trade of a consensual sex life for access to money and other rich people. As I understand how the system worked, most of these girls found other boyfriends at the parties Hef threw, and moved on naturally, of their own accord, and everyone involved seemed to feel this system was a good trade.

Given Harvey’s empire, and the enormous wealth and influence he wielded in the movie business, it would seem to me that he could have done essentially the same thing as Hef, and on an even grander scale, given the larger and more-reputable business. It would have been nothing to him to keep a bevvy of beautiful women on hand, put up in nice places, for him to visit on his whim. It’s clear that women who want to work in movies are a little different than women who want to pose naked in magazines, but, for purposes of this discussion, you can leave them out of it entirely. With his wealth and connections, he could have kept a stable of pure, gold-digging girlfriends. But he didn’t do that. He coerced women. Aspiring actresses. Assaulted them. Raped them. For decades.

It wasn’t about the sex. It was most definitely about the power and the subjugation. To me, this doubles the horror of the scandal.

And don’t give me the BS that people didn’t know. Everyone knew.  Everyone. By the time the scandal finally broke, even I had seen and heard enough rumors to know he was a monster. The fact that his brother, the people in his company, and the entire industry looked the other way for 40 years triples the horror.

 

Posted in Politics | Tagged , , | Leave a comment

Congress, in a Five-Hour Hearing, Demands Tech CEOs Censor the Internet Even More Aggressively – Glenn Greenwald

We are taught from childhood that a defining hallmark of repressive regimes is that political officials wield power to silence ideas and people they dislike, and that, conversely, what makes the U.S. a “free” society is the guarantee that American leaders are barred from doing so. It is impossible to reconcile that claim with what happened in that House hearing room over the course of five hours on Thursday.

Source: Congress, in a Five-Hour Hearing, Demands Tech CEOs Censor the Internet Even More Aggressively – Glenn Greenwald

Glenn brilliantly sums up what’s been bothering me lately. For a long time, liberals have ducked-and-covered in the Free Speech debate, saying that online censorship was a private matter, and therefore did not run afoul of the First Amendment. But Congress has been applying more and more pressure to get Facebook (in particular) to censor their content in a way they find acceptable.

Once a platform becomes as ubiquitous as Facebook, Twitter, or Google (or Amazon), it should be regulated as a “common carrier,” and not censor at all. They have become de facto services of the public, like water or electricity, and should be treated as though they were. We don’t allow the water or electric companies to dictate who can be served, or what those resources are used for.

Libel and threats can still be prosecuted as the illegal acts they are. We lose nothing in preserving freedom of speech on these platforms. All the incitement and insurrection in the Capitol that was facilitated by social media is being prosecuted, and hard. That’s precisely how the system should work: Say whatever you like, but be prepared to suffer the legal ramifications if you cross over into illegal speech.

We are letting these companies redefine what it means to live in America. Congress is encouraging them to redefine it. At this point, I guess there are two kinds of people. Those that think that the First Amendment is, perhaps, the purest written form of freedom ever written down, and feel we should do ever more to preserve it, and those that think this was a Bad Idea, and feel it’s time to repeal the notion of it.

Orwell’s depiction of Oceania has already become reality in China. Even further, they have already implemented a social scoring system like the one depicted in the Black Mirror episode, Nosedive. What’s so utterly disappointing is to see all of this taking shape in the United States, the very last place it should, by the ideals of our founding. There’s a reason why the US has fallen to 27th place on the list of free countries.

Posted in Politics | Tagged , | Leave a comment

*The* Suicide Squad

So DC has finally figured out how to get some of that famous Marvel movie success: hire a (possibly disillusioned) Marvel director to make a movie for you. Oh, and poach 2 of the most-popular franchise character actors while you’re at it.

Oh, and, uh… also keep featuring one of the two most-compelling characters ever created in the universe, starring one of the most beautiful women in the world. That can’t hurt.

Posted in Humor | Tagged , | Leave a comment

Imgur. Again.

I think Imgur is currently running 40% on the liberal programming right now. I know I’ve talked about it before, but I’m convinced it’s a sociological experiment, no different than the Cambridge Analytica scandal that drove the liberals out of their minds in the 2016 election.

Months ago, I stopped looking at the site, because every 3rd or 4th post was a “thirst” post. Those are gone. Completely. I’ve scrolled through everything on the front page over the past couple of days, and I don’t think I saw a single one. They have been replaced by reposts — almost always from Twitter — which contain liberal talking point hot takes. I don’t even necessarily disagree with the content of most of them, but the ones that gloss over logical fallacies irritate me, and there are a lot of those.

Someone there made a conscious choice to change the algorithm. You have to watch these things over months to notice, but it’s very real. Either the voting membership at Imgur has changed demographics entirely in the past several months, or someone’s running an experiment on the public through that site.

Now all of those thirst-y posts are at 9gag. I wonder if, in 6 months, they too will be replaced with liberal talking point posts.

Posted in Technology | Tagged , , | Leave a comment

I Like That The Boat Is Stuck

I know it’s bad that the boat is stuck, but I like that the boat is stuck.

Unsticking the boat will require making the boat not be stuck. It won’t take a year or more of isolation, or new heights of handwashing, or phone calls to legislators. It won’t require the courage to face down militarized police forces or the gumption to get a shot that I know will make me feel a little bad before it makes me a lot safe. Nobody can tell me that if I just work a little harder or stop spending money on avocados or get a side hustle, the boat will get unstuck. If I did all of those things, perfectly right, right now, on tiptoes, there would still be a big stuck boat! Because those things aren’t the things that need to happen. What needs to happen is: someone unsticks the boat.

Source: I Like That The Boat Is Stuck

This is the blog post the world needed, precisely when it needed it.

OK, maybe it was just me that needed it, but it resonates very strongly with me.

Posted in Politics | Tagged | Leave a comment

Amazon Denies Workers Pee in Bottles. Here Are the Pee Bottles.

“You don’t really believe the peeing in bottles thing, do you?” Amazon tweeted. Drivers say they’re being gaslit.

Source: Amazon Denies Workers Pee in Bottles. Here Are the Pee Bottles.

This is America, where the biggest, richest companies on the planet can’t even pay workers enough to let them take proper bathroom breaks. It would be funny if it weren’t so extensively documented for years, and yet our captured government does nothing about it.

This sort of unfettered capitalism is making me a liberal. We bail out companies, time after time, while they give their executives obscene bonuses, and let people fend for themselves, to try to make a living like this. This is not the sort of thing the United States should be about.

I can’t, in good conscience, continue to support an economic system like this. We’re watching a new feudalistic society take shape, in which there is an aristocracy of business owners and executives, and a proletariat of peasants that work their “fields” for subsistence. Modern-day America has all but wiped out all the middle-class economic progress of the post-war boom. The “American dream” is dead.

People are getting angry about it. I know, because I’m one of them. I think the Republicans are going to be out of power for a long time, especially if another Trump is the best they can do.

Posted in Politics | Tagged , , , , | Leave a comment