News for hackers. Stuff that matters.
Re:Printf(“%s %s”, dependency, injection) by fredrikholm on Tuesday October 19, 2021 @06:26AM (#28916634)
Always happy to see my articles (or in this case, rant!) posted on HN :)

This was written after comparing a ~300K SLOC Go project to it's original ~800K SLOC Java project at work, that we've rewritten over the course of a year or so.

In the Go version, test coverage is floating around 90-95%. Performance, and memory use especially, is drastically better. This is from lessons learned, where a large part of those lessons meant reducing this type of 1990s XP/Agile/SOLID style of constant indirections and pass through classes.

Yes, the main files where startup allocation happens are huge, but it's all in one file (per service) and can be easily grokked with IntelliSense and general code navigation features.

In the Java version, every folder had a large section of subfolders with files that pointed to other files that perhaps did something besides calling other objects. Startup was horrible, memory consumption was high and tests were somehow more verbose than Go (which are already a mouthful).

I want to point out that I love SmallTalk, and feel that this style makes sense in that environment. For Java/Microsoft Java, this style is IMO not worth the effort for neither developers nor codebase.

Interesting discussions in this thread already, thank you <3

Re:Printf(“%s %s”, dependency, injection) by Traubenfuchs on Tuesday October 19, 2021 @11:57AM (#28919579)
I wonder what would have happened if you had rewritten your Java project in... Java. Maybe with better/faster/less/more frameworks?

How much of the improvement is attributable to the rewrite and lessons learned and how much is attributable to using the backend language du jour?

Re:Printf(“%s %s”, dependency, injection) by fredrikholm on Tuesday October 19, 2021 @03:53PM (#28922862)
Getting to start over is the scret sauce, no doubt!

It also helps if the language idiomatically nudges you in the right direction.

Indirection tends to be minimized in Go, similar to C, and encourages solving your immediate problem.

Comparatively, Java and C++ encourages you to design/grab for reuse first, opting for flexibility.

IME Java devs will write idiomatic OOP in this style, just like Lispers will fiddle with macros. For us, picking Go helped signal that we wanted people who wrote procedural, direct-first code.

Re:Printf(“%s %s”, dependency, injection) by cheradenine_uk on Wednesday October 20, 2021 @03:53AM (#28927961)
Shout out for asp.net core projects, where every frickin' class looks like:

class MyService {

  ILogger<MyService> _logger

  MyService(ILogger<MyService> logger) {
    this._logger = logger;
  }
}

Making it a monumental PITA to use without the associated Jungle: The chosen DI framework. Why is the ILogger generic? Because of the DI framework, so it can create a logger that corresponds only to this type.

We're literally writing code to keep the framework happy.

Re:Printf(“%s %s”, dependency, injection) by cheradenine_uk on Wednesday October 20, 2021 @03:56AM (#28927983)
Oh ,and while I'm at it, literally everything is defined twice, once in an interface, once in an implementation.

Even though there are no other implementations.

Why? Seems to boil down to "our language / environment / DI system / mocking framework is incapable of working unless you do it this way.

Yet more cognitive and implementational waste.

Re:Printf(“%s %s”, dependency, injection) by bobmaxup on Tuesday October 19, 2021 @06:34AM (#28916670)
How is any of this particular to Java or Go?

What does eXtreme Programming or Agile have to do with how you pass messages in code?

Re:Printf(“%s %s”, dependency, injection) by fredrikholm on Tuesday October 19, 2021 @06:36AM (#28916682)
I've yet to be in a large, enterprise Java/C# project that doesn't subscribe to this style (seen roughly 10 of these projects at 3 companies).

Perhaps it's something about my area, but this style is standard idiomatic Java/C#.

EDIT: And the opposite statement is (perhaps more) true for Go. Adopting IBeanProxyFactory-type of stuff in there is beyond unidiomatic.

Re:Printf(“%s %s”, dependency, injection) by xh-dude on Tuesday October 19, 2021 @04:10PM (#28923107)
Because passing messages still means dispatch on concrete types - something concrete sends a message, something concrete receives a message. That’s the whole ballgame - get one concrete type to talk to another. Even if ‘concrete’ is in a seemingly typeless language, we can Hindley-Milner our way down to this.

I think it’s telling that Go, Rust, as well as more inspired stuff in later editions of C++/Java/C# all seem to be demonstrating that nominal inheritance-first polymorphism is not the only or always the best maze of abstraction for getting to a concrete dispatch from type A to type B in imperative-feeling languages.

Re:Printf(“%s %s”, dependency, injection) by igouy on Tuesday October 19, 2021 @12:57PM (#28920402)
> … 1990s XP/Agile/SOLID style of constant indirections and pass through classes. …

> I want to point out that I love SmallTalk, and feel that this style makes sense in that environment.

Seems like 2 different things are being conflated, possibly because much of that XP TDD stuff was done by some prominent Smalltalkers.

Re:Printf(“%s %s”, dependency, injection) by fredrikholm on Tuesday October 19, 2021 @03:35PM (#28922596)
The SmallTalk I was taught (Pharo) was written very much in this style:

Test first, send a messages to objects, or inject something smarter.

... and I loved it. Talking to a living thing via messages felt a lot like Erlang or Lisp. I don't get that vibe from Java/C#, despite similarities.

I should probably pick up SmallTalk again. Any recommendations?

Re:Printf(“%s %s”, dependency, injection) by igouy on Tuesday October 19, 2021 @06:41PM (#28924657)
Any recommendations for what?
Re:Printf(“%s %s”, dependency, injection) by eyelidlessness on Tuesday October 19, 2021 @09:10PM (#28925673)
> > I should probably pick up SmallTalk again. Any recommendations?

I don’t want to assume your reply was intended to be rude. I think they’re asking for recommendations on anything that might help/guide them picking up SmallTalk again.

Re:Printf(“%s %s”, dependency, injection) by igouy on Wednesday October 20, 2021 @01:58AM (#28927273)
If that was the question; my recommendation would be first find something in the world you want to effect, and then what you need from technology to succeed.
Re:Printf(“%s %s”, dependency, injection) by eyelidlessness on Wednesday October 20, 2021 @02:18AM (#28927364)
My goodness I quoted the question, it’s not ambiguous. They were looking for directed advice. Clearly. Don’t be a jerk. You don’t have to provide advice but you don’t have to be mean about dismissing the request either.
Re:Printf(“%s %s”, dependency, injection) by igouy on Wednesday October 20, 2021 @12:42PM (#28932836)
Wow.

First you imply my question was rude, and then you call me a jerk, and then you call me mean.

I did not dismiss the request, I gave a recommendation.

Re:Printf(“%s %s”, dependency, injection) by fredrikholm on Wednesday October 20, 2021 @03:04AM (#28927649)
That was the question. You often comment about SmallTalk here on HN, so I figured that perhaps you had any learning resources as you previously pointed out that I might have things mixed up.

In this case, I would want to learn more just for the fun of it, like learning to play an instrument, holding off effecting the world for now.

Re:Printf(“%s %s”, dependency, injection) by uksmalltalk on Wednesday October 20, 2021 @04:22AM (#28928139)
Hi Fredrik, if you're based in Europe or America I would suggest joining one of the online UK Smalltalk User Group meetings and have a chat with us. You can check out our website or drop us an email - details are in our profile.
Re:Printf(“%s %s”, dependency, injection) by igouy on Wednesday October 20, 2021 @01:10PM (#28933182)
As a matter of history, I have some experience with Smalltalk.

The first Smalltalk implementation I used was bought because I had already implemented a proof-of-concept prototype on a spreadsheet (Lotus 123 iirc).

As-it-happens I have no experience with Smalltalk-as-a-hobby.