Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 21:44

    danieldietrich on v1.0.0

    Fixes malformed .travis.yml (#2… (compare)

  • Jan 31 2019 21:44
    danieldietrich closed #2369
  • Jan 31 2019 21:31
    codecov-io commented #2369
  • Jan 31 2019 21:31
    codecov-io commented #2369
  • Jan 31 2019 21:31
    codecov-io commented #2369
  • Jan 31 2019 21:18

    danieldietrich on v1.0.0

    Simplification (#2367) (compare)

  • Jan 31 2019 21:18
    danieldietrich closed #2367
  • Jan 31 2019 21:18
    danieldietrich closed #2368
  • Jan 31 2019 21:18
    danieldietrich labeled #2368
  • Jan 31 2019 21:14
    danieldietrich labeled #2369
  • Jan 31 2019 21:14
    danieldietrich labeled #2369
  • Jan 31 2019 21:14
    danieldietrich milestoned #2369
  • Jan 31 2019 21:14
    danieldietrich opened #2369
  • Jan 31 2019 21:14

    danieldietrich on travis-yml-fix

    Fixes malformed .travis.yml (compare)

  • Jan 31 2019 21:10
    codecov-io commented #2368
  • Jan 31 2019 21:10
    codecov-io commented #2368
  • Jan 31 2019 21:10
    codecov-io commented #2368
  • Jan 31 2019 21:10
    codecov-io commented #2368
  • Jan 31 2019 21:10
    codecov-io commented #2368
  • Jan 31 2019 20:51
    danieldietrich opened #2368
Daniel Dietrich
@danieldietrich

Personally, I think the most confusing part of Java is that it does not allow us to formulate concepts using structures. Java requires us to formulate concepts using names.

For example, a functional interface might have the apply method. But it could be also foo, bar or baz. But it really is just an application of arguments, like we do it with methods (arg1, ..., argn). That is really evil and makes Java hard to read.

In the above example, I would prefer this notion:
var e = fn(e1)(e2)(e3)(e4)(e5)
The reason for having the bad syntax in Java is: (surprise, surprise): Java is object-oriented, not functional. Every method is called on an object, including apply methods on functions.
QP
@theqp
if someone can understand flatMap, then he can understand functor, applicative monad, etc if it is well documented
in fact, I learned those smoothly unlike OOP design patterns, I am still struggling with those
Daniel Dietrich
@danieldietrich
Yes, but you shrink your target audience. There are more Scala developers that Cats developers. I started with Scala 2008/2009 I think. The was always a bad vibe within the community, something along the lines „You need a PhD in math“ to understand certain concepts. If you talk about algebra, you will attract mathematicians, even if the knowledge isn‘t required. And than the discussion slowly moves in direction of morphisms, theorems etc. You will need to understand these topics in order to be able to decipher certain source code repositories. Programmers lift their abstractions to an algebraic level. That‘s the point where most people will turn you their back and leave the room. Recruiters would need to find people with algebraic know-how for dev positions...
I think that Scala chose the right way. It is powerful enough, even when not providing an algebraic abstraction level.
QP
@theqp
do you think Kotlib would be preferable if it had for comprehension?
Łukasz Michniewicz
@LukeKeywalker
Thanks for you responses, there are some good ideas there. That's right, what I need is something like Scala's For. Eventually I think I'll go with nested flatMaps, as it doesn't look too bad and does the short circuiting on intermediate errors, which is the most important thing to me in this case
Daniel Dietrich
@danieldietrich
Yes, the shortcut circuiting is definitely a benefit!
t-tang
@t-tang
I'm converting an application to Vavr, there is a data structure with a fine granularity of updates, so I am wondering which of the Map / List data structures are persistent, in the sense that an updated data structure would share most of it's nodes with it's older version. (As opposed to immutable which, to me, implies a copy)
1 reply
t-tang
@t-tang
@LukeKeywalker Just saw your Either example, there is another way to do it without using nested flatmaps, which is to map the result into a tuple which contains the result from the previous cmd...only really viable for a few results
JunHyung Im
@EntryPointKR
@danieldietrich Can I ask any particular reason why the prepend is not in TupleN?
Daniel Dietrich
@danieldietrich
You are right, we could add it!
JunHyung Im
@EntryPointKR
I can't see the prepend in 0.10.3, can I open a PR for this?
Daniel Dietrich
@danieldietrich
Yes, I would appreciate a PR! The Scala generator templates need to be changed, changing the src-gen/*/ files directly will break the build
QP
@theqp
@danieldietrich are you sure the update function is "const" time in Array?
https://docs.vavr.io/#_performance_characteristics
I think that would be linear
Daniel Dietrich
@danieldietrich
I think you are right, because the internal Java Array needs to be copied. Maybe the JVM/CPU is able to copy memory block faster somehow - need to double-check that
QP
@theqp
i think jmh is the right tool for this
Gerard Bosch
@gerardbosch

Hi @danieldietrich I found these ideas interesting
http://blog.vavr.io/opinionated-database-access-in-java/

Did it have any continuity? Just for curiosity :)

QP
@theqp
I think the best alternative for JDBC if you program in java is JDBI
it even has vavr support
Gerard Bosch
@gerardbosch
Thanks @theqp , I will check it out!
Gerard Bosch
@gerardbosch

But I see JDBI still uses String to describe DB queries, which is not safe:

jdbi.withHandle(handle -> {
    handle.execute("CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR)");

while the Daniel's post shows an API to do it programatically in a safer way:

            cust.insert(
                cust.NAME.set(name),
                cust.NUMBER.set(number)
            );
Daniel Dietrich
@danieldietrich
@gerardbosch it don’t plan to further invest into another SQL library. The idea was nice but there already exists a bunch of libraries. @lukaseder wasn’t that amused to hear about another SQL lib in Java and I can understand him. He saw parallels to the development of jOOQ - everyone wants to start easy and small but when creating a typesafe DSL of SQL9x, users will ask for more features and you will end in abstraction hell. Please check the comments section of the article.
Gerard Bosch
@gerardbosch
Thank you Daniel! -I can't see any comments in the blog post, but I understand
Daniel Dietrich
@danieldietrich

Sometimes the comments 'plugin' seem to need a manual reload ...

It should look like this:

The comments should show directly after the end of the post.
Gerard Bosch
@gerardbosch
image.png
Oh, sorry, I didn't realize, one of browser plugins had banned (maybe a false positive, I don't know), thanks!
Gerard Bosch
@gerardbosch
Long discussion BTW, hehe
Daniel Dietrich
@danieldietrich
oh yeah, that was a long one :)
Gerard Bosch
@gerardbosch
It's good, I'm learning from it :) :)
Daniel Dietrich
@danieldietrich
there already exist excellent alternatives to JPA, Hibernate, plain JDBC and the good old Spring JDBC Template. QueryDSL for example: http://www.querydsl.com
Gerard Bosch
@gerardbosch
Is this similar to jOOQ?
Daniel Dietrich
@danieldietrich

I think it has a similar approach like jOOQ but Lukas Eder once talked about differences - years ago, I can’t remember it. But I think it had to do with dialect support. jOOQ supports them all. But Oracle support for example is a paid feature, which is ok!

In fact, it would be tempting to create a SQL DSL with tight Vavr integration. The same applies to GraphQL and Neo4j.

But such libs would require much design and maintenance effort.
Currently I do not have the resources for that. On Feb 1st, I’m starting a new adventure that will require all of my attention 🤗
More on that on Twitter in two weeks...
Gerard Bosch
@gerardbosch
That sounds really good, congrats!
I'm trying to figure out which DB access framework or library is more convenient for Java, but I'm also at my last days of Java, I will switch to Kotlin very soon :) Not very expert on databases BTW.
Daniel Dietrich
@danieldietrich

Congrats, Gerard :))

Kotlin also seems to have pretty mature solution, like https://github.com/JetBrains/Exposed

s/solution/solutions/
Gerard Bosch
@gerardbosch
Thanks! Daniel.
I've just heard about it today by chance, and now read it again at the start of the blog discussion, so I will check it out too
Daniel Dietrich
@danieldietrich
👍
S.Kasani
@srinivaskasani
I'm very new. Try to get ride of if/else block for the following syntax
SomeObj obj1 = Fun1(arguments)
if (obj1.getAttribute1 != null || obj1.getAttribute1.size < 1) { save(obj1)
} else { update(obj1)
}
Daniel Dietrich
@danieldietrich

There is nothing wrong with if/else. Your save method returns nothing, we say it performs a side effect (otherwise it would do nothing). Using if/else is the Java way.

Functional programming is about values and expressions. A ternary operator we be fine solution then. Or you refactor your logic to a function.

Also take a look at the new switch expression of Java 14+ version!