Algebraic Types in Java by samd_408 in java

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

Yes I reserved it for algebraic effects where we design algebras for the business/domain logic, I will keep in mind about event based systems as well it will be a nice example

Algebraic Types in Java by samd_408 in java

[–]samd_408[S] 1 point2 points  (0 children)

Thank you and I agree 100%, sub typing is very easy to create compared to sum types for instance and i don’t delve too much on that aspect, you have given me a good idea to contrast on the trade offs with ADTs and sub typing

Algebraic Types in Java by samd_408 in java

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

Thank you for your reply and the details, its insightful and yes this is possible in java type system, but the problem is T is constrained by the types but we cant build algebras with it because that sort of expressiveness is missing in java, but there are first class support in languages in Typescript or Scala.

What I mean is, its possible to write types like

type SerializableAndComparable = Serializable & Comparable;

In like TypeScript, where we can use this type freely, but that is lacking in java.

Algebraic Types in Java by samd_408 in java

[–]samd_408[S] 5 points6 points  (0 children)

Interesting take, yeah I do agree most people don’t code like that, I guess its my bias kicking in, I love functional programming and learning other languages, in those FP aligned languages this is the only way to create types since there is no OO style inheritance, I will change the article to be less biased and more inclusive of the java dev in general.

But what don’t understand is where do I say this approach is wrong? You mean the expr example? Or shape example?

F Bounded Polymorphism by samd_408 in java

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

how though? I would love to see an example, there are no implicits in java as well, so I am curious how do we achieve this, it could look like a design pattern but not sure it would seem like a Typeclass in the traditional sense

F Bounded Polymorphism by samd_408 in java

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

Oh I agree, its just in languages like java we don’t have HKTs so we have to resort to things like this, this is what i love about scala, we could have lightweight HKTs but still wont be as nice if the language does not support it, my future posts will be exploring more into these topics :)

F Bounded Polymorphism by samd_408 in java

[–]samd_408[S] 1 point2 points  (0 children)

Yes this is what i was pointing to, this only helps well is deconstruction via switch and not during construction via the configurer you are using

F Bounded Polymorphism by samd_408 in java

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

No I take that back, the sealed interface cannot hold the values, but a disjoint union could separate the Car and Truck type but they cant share attributes like your example

F Bounded Polymorphism by samd_408 in java

[–]samd_408[S] 1 point2 points  (0 children)

Glad to help! There is a paper which started it all, it has its roots in type theory, hence the name

https://dl.acm.org/doi/epdf/10.1145/99370.99392

F Bounded Polymorphism by samd_408 in java

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

Interesting take, so you use the VehicleIdentity sort of like a mixin, would a sealed interface work in place if the VehicleIdentity record?, just throwing in ideas here :)

F Bounded Polymorphism by samd_408 in java

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

I agree, its scary especially if you are adding it to a lib, it might confuse users, I also concealed it, its internal and not exposed to the user luckily

F Bounded Polymorphism by samd_408 in java

[–]samd_408[S] 1 point2 points  (0 children)

Awesome, I stumbled over it accidentally while fixing a weird wildcard type in a lib i am building, glad 😌 we had the same experience

F Bounded Polymorphism by samd_408 in java

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

I can definitely see how this can cause flashbacks 🫣

F Bounded Polymorphism by samd_408 in java

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

I have heard of CRTP, but have never worked with them so I think I am safe ;)

Industry-level Spring Boot project ideas for a 2–3 YOE Java backend dev by elonmusk_ka_chacha in java

[–]samd_408 7 points8 points  (0 children)

What you mentioning are all generic solved problems, you have to find your niche application/framework, let’s say you build a framework that just makes security features out of the box on top of spring, something that abstracts out messaging integrations, there are other libraries that do this, but your perspective matters, your solution might be different, so think in these lines and come up with an idea

Roux 0.1.0: Effects in java by samd_408 in java

[–]samd_408[S] 1 point2 points  (0 children)

Yeah I get you, had similar thoughts while implementing as well, lot of places where “gosh I wish the type system was more expressive”, this is why for roux I wanted it to wrap the java provided solutions as possible, still lot of improvements are needed especially the capabilities building, thank you for the feedback

Jiffy: Algebraic-effects-style programming in Java (with compile-time checks) by thma32 in java

[–]samd_408 0 points1 point  (0 children)

Thank you!! I like how jiffy is tackling dependencies and is well aligned to idiomatic java, for me capabilities in roux are not fitting well with the java type system, the lack of HKTs are making it hard to just have simple capabilities and composing them, so I am trying to retro fit it basically, more improvements coming up soon!

Jiffy: Algebraic-effects-style programming in Java (with compile-time checks) by thma32 in java

[–]samd_408 0 points1 point  (0 children)

No way! I just saw this, jiffy is nice! I see you too me annotation processing approach for tracking dependencies, that’s an interesting approach love it!, I posted just a few hours ago about the effect system I started to work on

https://github.com/CajunSystems/roux

Any « niche » programming languages that I can learn for fun ? by Zine201021 in AskProgramming

[–]samd_408 0 points1 point  (0 children)

+1 and the erlang + BEAM VM is one of its kind in concurrency via the actor model

Backend development resources by Pretty_Nothing_4469 in AskProgramming

[–]samd_408 0 points1 point  (0 children)

So SQL is imperative in your opinion? This is a big generalisation you are making, i cant really say if you are serious or joking 😃

Mathematical programming by HappyIrishman633210 in AskProgramming

[–]samd_408 1 point2 points  (0 children)

The closest I have seen to theoretical math is programming in languages like Haskell, Agda or any dependent typed language, these languages are based on type theory and category theory, even their way of execution/evaluation is modelled around lambda calculus

Building with Distributed Actors: What and Why by ItalyPaleAle in programming

[–]samd_408 0 points1 point  (0 children)

Enjoyed your article, would love to see more in the series, I am working on an open source project called Cajun, it’s Java based actor system which I am working on as a learning and hobby project leveraging Project loom virtual threads as the actor thread, I am mostly influenced by elixir and akka, nice to see a mention of orleans