Ask HN: Comment here about whatever you're passionate about at the moment
Hello,<p>Apart from my family and some minor health issues, I currently am focused on 2 things: learning Luxembourgish&#x2F;Luxembourgian and develop a deep understanding of functional programming.<p>About the former one: that should help me find a job in some Luxembourgish administration (I really wish I&#x27;ll be able to find one soon).Luxembourg might be a small country, but I think it&#x27;s managed well, CTIE (Luxembourgish administration that manages most of the IT infrastructure and software used by the state) has quite smart and competent people (also some dumb ones, but where&#x27;s that not the case?), and I think I like the culture, which is almost my own, as I grew up close to Luxembourg and even went to a german-speaking school, while speaking family-native French  (I&#x27;m as fluent speaking German as French, no accent).<p>Regarding the latter one, I started applying functional programming principles early this year, almost as obstinately as I can (and as much as possible using Java 8 then now 17) (I&#x27;ve got more than 16 years of professional experience using Java, both as a developer and software architect).<p>This was just the beginning of a more insightful journey into new coding practices, which result from one principle I discovered this year: source code should never lie. 
This became an evidence once I implemented and started to use my self-made &quot;Maybe&quot; type (a better Optional - Optional is quite weak if you want to avoid procedural programming). While using Maybe, it struck me that what I did was just explicitly forcing my code to say the truth. So I started to dig into types and have types represent various states (this may be seen as a better use of object orientation - this is not relevant, what&#x27;s relevant is the improvement in the quality of my code). Using the multiple types (usually sub-classes) and combining with &quot;fold&quot; methods make a lot of if-else unnecessary and force the developer to handle each case: one can&#x27;t just forget one case. What one may do is not handle a case, but it remains explicitly visible in the source code, with as much importance as the other cases. Then, the removal of the if-else usually means that the logic is much simpler to read and reason about. Using adequate types also means that only functions of the actual type are available, so we also reap the benefits of OO design. Also, while it is stated that Optional was not made to be serialized, I made my Maybe type so that it may be used in serialized objects and thus accurately reflect the state of affairs.<p>I&#x27;m still discovering FP patterns (for example, I still have to read about how to properly manage IO&#x2F;side-effects&#x2F;state. Once I&#x27;ve learned FP patterns, I&#x27;ll focus on the synthesis of my knowledge of Java, DDD and FP in order to find out how to best apply FP and DDD principles to professional Java projectes, given the constraints of the language, it&#x27;s modularity (Java 9 modules, Maven modules) and the JVM. I already have the intuition that the Spring framework (which is the de facto standard in Luxembourg businesses) might not be a good fit to serious FP programming - at least not without appropriate abstractions on top of it. This probably already starts with the dependency injection&#x2F;inversion of control, which, I think (to be confirmed, though), does not make sense if a purely functional approach.<p>Regarding a Maybe type (I&#x27;m picky about naming - remember, code shouldn&#x27;t lie): I firmly believe that Optional and Option are bad names for this type. As the user of an API&#x2F;function that may return something or nothing, I don&#x27;t get a choice about what I receive. Maybe I receive something, maybe I receive nothing. It&#x27;s not like I receive some option from which to choose. As the one who implements the API, I have indeed the choice to provide something or nothing, so yes, I have some option, but what I&#x27;ll return may be something or may be null. Thus I strongly recommend to stick with the name Maybe. Option&#x2F;Optional is just lying to the user of the API&#x2F;function.<p>It might just be an anecdote, my own, but I think that using lambdas and a few other FP principles with Java &gt;= 8 for more than 9 months really opened doors in my mind about functional programming and types (way more than following Martin Oderski&#x27;s FP courses on Coursera), to the point that I now really feel comfortable reading and understanding more advanced literature about FP, even stuff in Haskell. I&#x27;m not saying it&#x27;s easy&#x2F;simple. But if I focus, I think I&#x27;m now able to understand, which might not have been the case just last year. So Java provides, I think, a good enough environment to learn more than the rudiments of FP.<p>The most important lesson learned this year about programming is: source code must not lie. Replace nullable stuff with Maybe, when a Boolean may be null, don&#x27;t just use a Boolean, but (for example) reimplement a NullableBool interface that has three types: TrueBool, FalseBool and UndefinedBool&#x2F;NullBool. To represent two-valued booleans, I have Bool with subclasses TrueBool and FalseBool. Don&#x27;t hesitate to use multi-valued booleans in cases where you have to represent probabilities (I, for example, have used a TetraValuedBool, which has the types False-Improbable-Probable-True). All these Bool types come with various static functions (&#x27;of()&#x27; to get&#x2F;construct an instance) and non-static functions (&#x27;fold()&#x27;). To allow functions to return results that may represent anomalies, don&#x27;t hesitate to use a Result type, which has two sub-types, one wrapping anomalies and one wrapping the actual legit result, and, again work with a &quot;fold&quot; function to handle both cases explicitly. Use strong types whenever possible, even if it&#x27;s just some wrap around a String. Nothing is just a String.<p>This takes some time to implement, but once you have, it just makes your code easy to read and understand, nothing is hidden anymore: no implicit consequences. Once your code does not lie anymore, it becomes self-documenting, especially given FP is rather declarative (one does rather state what one wants than how to do it). This is rather cool, as you won&#x27;t have to maintain separate documentation (at least not for developers).<p>Now, I&#x27;m not sure I recommend you do the same: my client will stop my contract by the end of this year because they don&#x27;t understand the benefits of this higher code quality. They&#x27;d have preferred &#x27;simple&#x27; procedural code, with which they believe I would have been able to deliver more features faster. Even my developer colleagues don&#x27;t recognize the beauty of it. This, of course, is utter BS, because their problem is scope creep and they need to designate some responsible for being late. They just decided it&#x27;s me. I&#x27;ll be sacrificed on the altar of bad project management. I&#x27;m still making up my mind about defending myself and telling my point of view to their superiors: Luxembourg is small, it&#x27;s not a place where one wants open conflicts, but at the same time, do I have to allow being made responsible for bad PM choices?<p>The intellectual challenge of combining FP, DDD and Java is absolutely great and quite huge. I couldn&#x27;t do it just after-work (my wife and I are raising two little boys), because the deeper understanding of these needs regular, almost daily practice and reading about these topics. Doing this at work clearly made me vulnerable in a way I didn&#x27;t see coming when I began this path, so I definitely can&#x27;t recommend it to everyone. But I can&#x27;t wait reaping the results of my deeper understanding of these topics, and I&#x27;m really happy to still be a programmer instead of doing some management (that is also an option - I have both experience and university degrees in engineering and in management), it&#x27;s been a long time since I&#x27;ve had so many interesting intellectual opportunities.<p>Some references I used this year to improve my programming skills or just enjoyed reading (I consider these to be a good intro into FP and DDD):<p>- [0] Pragmatic Functional Java: <a href="https:&#x2F;&#x2F;dzone.com&#x2F;articles&#x2F;introduction-to-pragmatic-functional-java" rel="nofollow">https:&#x2F;&#x2F;dzone.com&#x2F;articles&#x2F;introduction-to-pragmatic-functio...</a> ...<p>- [1] ...and it&#x27;s related source code (cf. the &quot;core&quot; module), which I used as a reference (no direct dependency), in order to be able to make some changes: <a href="https:&#x2F;&#x2F;github.com&#x2F;siy&#x2F;pragmatica" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;siy&#x2F;pragmatica</a><p>- [2] Functional programming made easier: <a href="https:&#x2F;&#x2F;leanpub.com&#x2F;fp-made-easier" rel="nofollow">https:&#x2F;&#x2F;leanpub.com&#x2F;fp-made-easier</a> (that one is quite easy to ready)<p>- [3] <a href="https:&#x2F;&#x2F;dusted.codes&#x2F;the-type-system-is-a-programmers-best-friend" rel="nofollow">https:&#x2F;&#x2F;dusted.codes&#x2F;the-type-system-is-a-programmers-best-f...</a> (posted a few days ago on HN)<p>- [4] <a href="https:&#x2F;&#x2F;fsharpforfunandprofit.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;fsharpforfunandprofit.com&#x2F;</a> (I&#x27;d really like to do some project in F#)<p>- [5] <a href="https:&#x2F;&#x2F;www.cambridge.org&#x2F;core&#x2F;books&#x2F;purely-functional-data-structures&#x2F;0409255DA1B48FA731859AC72E34D494" rel="nofollow">https:&#x2F;&#x2F;www.cambridge.org&#x2F;core&#x2F;books&#x2F;purely-functional-data-...</a><p>- [6] <a href="https:&#x2F;&#x2F;www.amazon.fr&#x2F;Implementing-Domain-Driven-Design-Vaughn-Vernon&#x2F;dp&#x2F;0321834577" rel="nofollow">https:&#x2F;&#x2F;www.amazon.fr&#x2F;Implementing-Domain-Driven-Design-Vaug...</a><p>- [7] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Functional-Programming-Java-Harnessing-Expressions&#x2F;dp&#x2F;1937785467" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Functional-Programming-Java-Harnessin...</a>