functionaljava
lispx
| functionaljava | lispx | |
|---|---|---|
| 4 | 1 | |
| 1,619 | 109 | |
| 0.0% | 0.0% | |
| 0.0 | 7.6 | |
| about 3 years ago | about 2 years ago | |
| Java | JavaScript | |
| - | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
functionaljava
-
Algebraic Data Types for C99
Kotlin is JVM compatible and has ADTs.
Java has https://github.com/functionaljava/functionaljava
which is unsupported but stable.
-
How to write this (3) Java lines in a functional style?
A few side-notes about this code: - you need some sort of "wrapper" or "container" in order to use functional methods like map/flatMap/filter/etc on some object - here I used Optionalfor testing because it's available in standard Java: Optional describes an object that may or may not be available. - A more suitable "wrapper" for this use-case could have been Try which describes the result of an execution that may succeed or fail, see vavr has a Try for example, functionaljava has Either - map transforms A -> B (would make sense for your mapToUser) whereas flatMap transforms A -> Optional (or whichever "wrapper", would make sense for your userService.save if suppose the saving operation can fail) - Here is a working example for you :) - practise exercises: 1- replace the "wrapper" Optional with List, there is almost no change of code, this now gives you the ability to process lists of users 2- import vavr and replace the "wrapper" Optional with Try, there is almost no change of code, this now gives you the ability to process operations that may fail - Enjoy functional programming, you'll find java is rather verbose and quickly gets clunky for FP, consider switching to another language
-
Show HN: Pidove, an Alternative to the Java Streams API
? Sometimes passing a lambda (or other function) as an argument is a simpler approach to specialization than defining a subclass. That I think is mainstream and accepted in Java today.
There is a lot more to "functional programming" than that, such as the use of persistent collections. In some cases (such as managing the symbol table in a compiler) those methods lead to good efficiency and great simplification, in other cases they are ways to make easy problems punishingly hard.
pidove builds on top of ordinary Java Collections and doesn't push more exotic approaches as does
http://www.functionaljava.org/
-
OCaml modules vs C#/Java OOP
We can simulate using type components in modules in Java by using parametrized classes, the type parameters correspond to type declarations in a ML signature. I found an example monoid definition in Java if you want to see how that looks. You can see that the "functors" are kept inside the class definition, though I don't know if it's necessary, I don't really know Java. You probably get weaker abstraction, because you can't have some monoid with an unknown carrier type, you always know the carrier type - it's just the type parameter A in Monoid.
lispx
-
Algebraic Data Types for C99
Many people don't care for it, and I made peace with that many moons ago; personally, I'm quite fond of what I'd call 'applications perl', which at least when I write it tends to be a mixture of OO and function composition type code with as much of the state as possible pushed to the outer edge (plus async for I/O if applicable), etc.
It barely feels like the same language as sysadmin scripts are written in, it just happens to share a compiler and a VM.
... and it doesn't exactly even share syntax since perl supports libraries defining their own keywords, e.g. while I won't be surprised if somebody makes it a feature of the VM eventually, our async/await is currently provided by https://metacpan.org/pod/Future::AsyncAwait and as you can see at https://metacpan.org/pod/Future::AsyncAwait#WITH-OTHER-MODUL... there's quite a few other useful ones out there.
Of course, many people complain vociferously about the idea that you have to use *libraries* to get syntax, but as somebody who still loves scheme I regard the ability to build the language up towards the problem to that extent to be a feature.
My first ever cpan release was making continuations pass back out to perl as a subroutine reference from Guile so I could write linear top level logic in scheme and use continuation capturing to sit that atop an event driven I/O stack - axisofeval.blogspot.com's lispx (https://github.com/lispx/lispx/) provides an fexpr based lisp that does similar for JS.
(trying to think of a good example of perl code of mine that shows an example of this is annoying me because I don't have any public code right now that's new enough for me to not have already decided I don't like it anymore ;)
What are some alternatives?
property-based-matrix-testing-tutorial - Property-based matrix testing in Java
ableC-template-algebraic-data-types - ableC extension for algebraic data types with C++-style templating
purefun - Functional Programming library for Java
delimgen - Delimited Generators - Minimal Delimited Control for JS
JFXShader - Allows custom effect shaders in JavaFX
libsum - Automatically exported from code.google.com/p/libsum