2 ms·
I've met a few young programmers who heard somewhere that object-oriented programming was bad and they want to get the enlightenment of functional programming t
by PaulHoule 3y ago
I've met a few young programmers who heard somewhere that object-oriented programming was bad and they want to get the enlightenment of functional programming that they've heard about. Frequently they travel from job to job like itinerant martial artists always looking for somewhere where they practice the true technique but they always seem disappointed as it is just as easy if not easier to screw up handling errors with monads than it is with exceptions and they find analogies like "a monad is like a burrito" just get them more confused.
As for something profound I'd point you to
https://github.com/cerner/clara-rules https://github.com/cerner/clara-rules
which many people will struggle with because like many other production rules engines in LISP (and many other examples of simple compilers), there is hardly any code! Contrast that to the orders of magnitude larger rules engine Drools
https://github.com/kiegroup/drools https://github.com/kiegroup/drools
which is so crazy-complicated primarily because the Drools language is Java-based so you need all sorts of things that Clara or CLIPS don't need. Note that both of these systems use variations of this algorithm
https://en.wikipedia.org/wiki/Rete_algorithm https://en.wikipedia.org/wiki/Rete_algorithm
where a set of rules can be compiled to a network of transitions that can happen when facts are added to the knowledge base so it is very much an example of compiler technology. (That said, Drools supports a lot of features that Clara doesn't and also supports a very advanced RETE-like algorithm that can exploit parallelism that early versions couldn't.)
- eternityforest 3y agoWhat are these iternant code students trying to achieve with all this? Performance? Productivity? Lower defects? Safety critical code seems to still be usually in C/C++, for reasons having nothing to do with the language being safe. Why are these people not studying Erlang, MISRA C, Rust, some kind of formal proof solver language, or OpenCL? What do people aspire to one day work on that would make the Haskell or LISP more appealing than a more locked down, static checking, kind of language? Programming culture is more confusing than the code itself!
- PaulHoule 3y agoAt risk of sounding like Peter Thiel I think a lot of this thinking is driven my mimesis rather than thinking. That is, there is a lot of talk about how functional >> OO and "OO sux" and all that. I think most of these people hadn't worked in the industry enough to have a clear picture of what better productivity and lower defects would look like but instead they were looking for a movement to join.
- johnnyanmac 3y agoMastery, perhaps. They see some sort of role model and figure the tools they use are a roadmap to becoming a distinguished engineer themselves. If only it was that easy. It is interesting how functional programming has to consider data organization completely differently, but sometimes it is just that, a tool or methodology, not a philosophy to subscribe to. Ideally, the good (or future good) engineers realize this and try to understand the less talked about soft skills needed to succeed.
- eternityforest 3y agoI guess that's probably a lot of why I don't get it, I never had any programmer role models. I looked up to Adam and Jamie, and I never saw them doing serious code.
- n6h6 3y agoWho are Adam and Jamie? Mythbusters?
- eternityforest 3y agoYep! For a while when I was really little I thought maybe I wanted to make video games, but... that's really hard. The stuff I was really excited about was mostly "tech in the physical world" related. Although with the AI boom, and how I'm too clumsy for jobs involving driving... I might be making a lot more if I'd at least tried to focus on the pure programming stuff instead of embedded, even though I never had any real talent for advanced algorithms...
- _a_a_a_ 3y ago> which is so crazy-complicated primarily because the Drools language is Java-based so you need all sorts of things that Clara or CLIPS don't need from drools website "Drools is a Business Rules Management System (BRMS) solution. It provides a core Business Rules Engine (BRE), a web authoring and rules management application (Drools Workbench), full runtime support for Decision Model and Notation (DMN) models at Conformance level 3 and an Eclipse IDE plugin for core development." No expert here, but it doesn't come across as a fair apples-to-apples comparison.
- PaulHoule 3y agoSomething like Drools ought to have a relatively small core and then additional systems built on top of it. Drools even has some projects like OptaPlanner and jBPM that are in different source code repositories. The core in Drools really is dramatically more complex than the core of Clara and some of that really is the higher level of functionality (Drools supports both hash-based and ordered indexes for data because you need that for complex event processing, Clara has only hash indexes) but a lot of it is that the syntax of Drools is much more complex because it mixes Java expressions and statements with the rules languages thus it needs a real parser. I was working on a project with Drools and had extreme difficulty because Drools error messages didn't make a lot of sense to me so I did a lot of looking at the Drools source code, running the compiler in the debugger and such and still didn't get very far. I switched over to the Jena Rules engine https://jena.apache.org/documentation/inference/ https://jena.apache.org/documentation/inference/ which still emits lousy error messages but I quickly was able to understand everything about the Jena Rules Engine, get really good at writing extensions, and use it for things the developers said were unsupported such as using it as the control plane of a data processing engine that bridged stream and batch processing: I'd use Jena rules to control the process of setting up and tearing down reactive streams that would do a data processing job. That is, I got good at the Jena Rules Engine that I kept discovering new things I could do with it. Clara is very similar to the legendary CLIPS rule engine from the golden age of ai https://www.clipsrules.net/ https://www.clipsrules.net/ and if you find Clara is too small to understand, CLIPS is even smaller. The massive reduction in code size comes from being able to lean on the affordances of LISP to develop a DSL for writing rules, if you have to write a parser and all the stuff that comes with defining an external DSL rules language your code starts to get much more complex. Jena Rules Engine is written in Java and I think it is very nice code and you'll learn a lot about RETE engines and other advanced programming concepts by studying it, you might even get more out of it than you get out of Clara. It was common at the tail end of the golden age of A.I. for people to write a first draft of a system in Common Lisp and then end up re-writing in it C++ for performance. Many of the ideas you get out of Lisp programming apply just well to other programming languages but require a huge amount of elbow grease and in-depth understanding of compiler technology whereas you can frequently use macros and similar affordances in Lisp to implement very sophisticated ideas with postage stamp size coded (that granted many people find challenging to understand.)
- vore 3y agoIsn’t this just a case of right tool for the right problem? If you were writing, say, an IntelliJ plugin I think you would much rather prefer Java over Clara rules, and not a subjective opinion of profoundness. Also, having asked about Haskell, I'm not sure why you brought Java into this!