Ask HN: Where do I find good code to read?
131–140 of 216 posts
Re: Ask HN: Where do I find good code to read?
#132Re: Ask HN: Where do I find good code to read?
#133Peter Norvig's Pytudes was recently posted here. I think that's some of the best code I've read, although they're only small problems and not a bigger project. Still very much worth a read, he goes through the whole problem solving through code process. https://github.com/norvig/pytudes
Re: Ask HN: Where do I find good code to read?
#134Earlier quoted context omitted.
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…
> 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 Conf…
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/
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
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.)
Re: Ask HN: Where do I find good code to read?
#135This isn't exactly a repo to look at, but the book "Clean Code" is a fantastic read for learning how to write good code. It does have a lot of examples in it, and does a great job explaining everything. https://github.com/jnguyen095/clean-code/blob/master/Clean.C...
There’s so much conflicting advice in this book (like saying functions should be immutable then also saying the ideal function has 0 arguments, apparently mutating the class doesn’t actually make the function mutable to Bob Martin!), and the code examples themselves are horrible (the prime number generator for example). I’ve heard people say it’s a good book if you just ignore all the bad stuff, but how are you suppo…
What does "functions should be immutable" have to do with mutating classes?
Re: Ask HN: Where do I find good code to read?
#136Earlier quoted context omitted.
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…
What 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…
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.Re: Ask HN: Where do I find good code to read?
#137The difference in a well structured codebase is that some of the code prevents you from having to read huge amounts of other code. All code is bad, it starts out bad just by existing, it's only redeeming quality is preventing you from having to deal with more bad code.
Everyone thinks they write good "clean" code, and it's never true. Good programmers are good because of the architecture of their code, not because a single excerpt of code in isolation looks a certain way.
What you really want to read about are good designs. Read APIs, models, concepts, schemas, etc.
Another comment mentioned the Go standard library, and I totally agree. But stop at the APIs, if you look inside, you'll see that it's also mostly garbage. It's good because the APIs are good, and you don't have to read the rest.
Re: Ask HN: Where do I find good code to read?
#138There was a blog post from Peter Seibel recently called [Code Is Not Literature)]( https://gigamonkeys.com/code-reading/ ) which pointed out that although everyone seems to agree reading code is great, very few tend to do it regularly. I feel like I get a lot more out of messing with / hacking on code than I do from reading it. I'm sure people vary, but I've got loads more out of open source contributions to sometime…
Nowadays if I want to learn some new thing I'll find the 'right' code to read. Someone who has done somthing similar to what I am trying to do. But when I was younger and still trying to understand more basic concepts I just wanted to read 'good' code. I wanted to know how to structure programming logic.
Now I don't want to know how to structure logic unless I'm really interested in learning some new fangled concept. Typically something having to do with concurrency since there always seem to be new ways to express concurrency in programming.
Most of the code I look to read these days is because I want to start using a new library and I want to see how someone else has done it.
Re: Ask HN: Where do I find good code to read?
#139Earlier quoted context omitted.
I would rather write “bad” code that lasts long enough to be inherited than write perfect code that sits idle in a repo because I missed the market.
it's strange seeing someone with absolutely no pride in their craft.
Re: Ask HN: Where do I find good code to read?
#140There was a blog post from Peter Seibel recently called [Code Is Not Literature)]( https://gigamonkeys.com/code-reading/ ) which pointed out that although everyone seems to agree reading code is great, very few tend to do it regularly. I feel like I get a lot more out of messing with / hacking on code than I do from reading it. I'm sure people vary, but I've got loads more out of open source contributions to sometime…