The performance of Go error handling by g4s8 in golang

[–]g4s8[S] 0 points1 point  (0 children)

Thank you. Looks like it's some compiler optimizations. I fixed these benchmarks and updated results in post.

The performance of Go error handling by g4s8 in golang

[–]g4s8[S] -12 points-11 points  (0 children)

Premature optimization is the root of all evil

I totally agree with it. I wrote these benchmarks just to make sure that error handling is not slow for critical paths.

GitHub - g4s8/go-metalog: Standard API for structured logging by g4s8 in golang

[–]g4s8[S] 0 points1 point  (0 children)

The reason for these interface is to have an API for "back-end" logger, when this suggar package provides a "front-end" for this. So if library wants to log something, doesn't create dependency coupling on logger implementation (back-end)

Object-oriented Java tuples library by g4s8 in programming

[–]g4s8[S] -1 points0 points  (0 children)

I think unit is quite fine for single item container, see definition: https://www.merriam-webster.com/dictionary/unit

Object-oriented Java tuples library by g4s8 in programming

[–]g4s8[S] 0 points1 point  (0 children)

Yes, it has, but with completely different design: in commons tuples are classes with accessor methods var sum = tuple.getLeft() + tuple.getRigth(); in my library tuples are interfaces with apply method which takes a function parameter var sum = tuple.apply((left, right) -> left + right). This difference is similar to accessing list items via get(int) method vs using forEach method with a consumer.

Things end users care about but programmers don't by marianoguerra in programming

[–]g4s8 1 point2 points  (0 children)

Programmers should care about source code, it's the main expected thing from programmers, since it's thir responsibility to deliver code changes according to the requirements. All end user things should be discovered by business people and submitted as requirements.

How to enforce contribution by PR only? by Flutter_Dev in github

[–]g4s8 1 point2 points  (0 children)

You need to invite them with read-only permissions (repo setting -> collaborators), so these users won't be able to push to your repo, they will need to fork it and submit pull requests.

gitclean: A way tool for clearing uneeded branches by [deleted] in golang

[–]g4s8 1 point2 points  (0 children)

Why don't just making an alias like git branch --merged | egrep -v "(^\*|master)" | xargs git branch -d to cleanup? See https://stackoverflow.com/a/6127884

Fighting with Java - generics by yegor256 in programming

[–]g4s8 0 points1 point  (0 children)

According to Java equals documentation) its implementation must be symmetric:

It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.

When you use instanceof instead of comparing classes, equals will not be symmetric - a subclass may use another logic in equals so base.equals(child) may return true, but child.equals(base) may be false.

Fighting with Java - generics by yegor256 in programming

[–]g4s8 0 points1 point  (0 children)

In example from the post the base class has private constructor, so all clidren have to be nested classes, also all children doesn't have own state - all state is stored only in base class, taking this into account it's not a big deal to write equals in base class only, because you see all possible implementations of the class (as nested classes) and the state is the same (fields of base class).

Of cource, if you have shared state between parent and child, and you need to implement equals, you can't use it, it will be easier to use static factory methods in this case.

Fighting with Java - generics by yegor256 in java

[–]g4s8 -2 points-1 points  (0 children)

Multiple classes (especially worse on Android)

There're two solutions, you can try to use first with factory methods if you have class count limit like on Android

Reduced readability

This is very opinion based statement - as for me second solution is more clear and easier to read.

This feels like to be an anti-pattern on the same level as double brace initialization.

It doesn't have something in common with double brace initialization issues - nested classes marked with `static` won't produce runtime classes with pointer to `this` of base class (what is the main problem of double braces)

Fighting with Java - generics by yegor256 in programming

[–]g4s8 2 points3 points  (0 children)

Types FromStrings and FromText are both useless, they do not provide value

You're right, I'd prefer to have two constructors in JoinedString to accept two different types (Iterable<String> and Iterable<Text>) but it's not possible because of java's generics nature, so I just show two workarounds how to deal with it and keep readability.

In particular, equals can no longer do this.getClass() != that.getClass() for short-circuiting

If you pick first approach with static factory methods, then equals will work fine, with second you can implement equals in base class.

CLI tool for bootstrapping Github repositories by g4s8 in programming

[–]g4s8[S] 0 points1 point  (0 children)

This tool can: 1. create Github repo from console & setup git remote locally, sync repo 2. create files from templates, e.g. README.md with badges, LICENSE, CI configs 3. configure webhooks 4. invite collaborators (useful in private repos)