This makes me realize: the one example I can think of where software has been "Lego-like" is Unix piping. I'm not a Unix purist or anything, but they really hit on something special when it came to "code talking to other code".<p>Speculating about what made it stand apart: it seems like the (enforced) simplicity of the interfaces between pieces of code. Just text streams; one in, one out, nothing more nothing less. No coming up with a host of parallel, named streams that all have their own behaviors that need to be documented. And good luck coming up with a complicated data protocol built atop your text stream; it won't work with anything else and so nobody will use your program.<p>Interface complexity was harshly discouraged just by the facts-on-the-ground of the ecosystem.<p>Compare that with the average library interface, or framework, or domain-specific language, or REST API, etc. etc. and it becomes obvious why integrating any of those things is more like performing surgery.
One thing I appreciate about John D. Cook's blog is that he doesn't feel the need to pad out what he wants to say.<p>Here, he had a thought, and he expressed it in two paragraphs. I'm sure he could have riffed on the core idea for another 10 paragraphs, developed a few tangential lines of thought, inserted pull quotes -- in short, turned it into a full-blown essay.<p>Given that his blog serves, at least in part, as an advertisement for his services, he even has some incentive to demonstrate how comprehensive and "smart" he can be.<p>His unpadded style means I'm never afraid to check out a link to one of his posts on HN. Whereas I will often forego clicking on links to Medium, or the Atlantic, or wherever, until I have looked at a few comments to see whether it will be worth my time.
Haskell is much closer to the lego blocks analogy than most languages I've tried due to the focus on composition and polymorphism.<p>The teetering edge that grinds some people's gears are monads which don't compose generally but <i>do</i> compose in specific, concrete ways a-la <i>monad transformers</i>. The next breakthrough here, I think, is going to be the work coming out of effect systems based on free(r) monads and delimited continuations. Once the dust settles here I think we'll have a good language for composing side effects as well.<p>In the current state of things I think heart-surgery is an apt metaphor. The lego brick analogy works for small, delimited domains with denotational semantics. "Workflow" languages and such.
And yet back in 1993, Visual Basic programmers were able to reuse software by literally snapping together controls like Lego blocks. There was a rich ecosystem of third-party controls. Competing tools such as Delphi had similar features. Since then the industry has gone backwards, or at best sideways, in many areas.
How about modding cars?<p>It's neither as bad as an organ transplant, nor as easy as LEGO.<p>It is also highly variable, dependent upon the SDKs and API choices.<p>I've written SDKs for decades. Some are super simple, where you just add the dylib or source file, and call a function, and other ones require establishing a context, instantiating one (or more) instances, and setting all kinds of properties.<p>I think it's amusing, and accurate, in many cases; but, like most things in life, it's not actually that simple.
When I’m working with Unix utilities like grep or doing stuff with xargs... it genuinely feels like I’m playing with legos.<p>I feel like this is trying to argue for more “consulting surgeons” when we need more “tooling machinists” who know how to make a good LEGO block.
This is an astute metaphor. In my experience software reuse simplicity strongly depends on the following factors:<p>* interface surface area (i.e. how much of an interface is exposed)<p>* data types of data coming in and out (static or dynamic). Static languages have an advantage here as many integration constraints can be expressed with types.<p>* whether it is a very focused functionality (e.g. extracting EXIF from file) vs cross-cutting concerns (e.g. logging)<p>The more limited surface area, the simpler the data types and invariants, the more localized it is - the more it is like LEGO as opposed to an organ transplant
For reusing software source I agree. The only current way around this is with the unix pipe system where you reuse software _executables_ instead of software _source code_<p>The reason it works is because unix softwares agree to a simple contract of reading from stdin and writing to stdout, which is very limiting in terms of concurrency but unlocks a huge world of compatibility.<p>I wonder if we will ever get software legos without the runtime bloat from forking.<p>ps: to anyone countering with examples of languages that are reusable through modules, that doesn't count because you are locked in to a given language.
IMHO conflating “systems” and “components” here. Module and package management has never been better and building “a system” from components, open source or otherwise, is extremely effective. Integrating software systems (with e.g. API’s, webhooks and event busses) is non-trivial, complex and difficult. They are not the same endeavor.
It really depends on the complexity of the software doesn't it? Libraries and packages often snap into my projects easily and without much modification at all, especially if I'm planning on using them. I can see this analogy working for more complex projects though, where you may be copy pasting code from on project to another and trying to make it fit together.
This is exactly what I'm working on right now. My approach is a little bit different. It's about building a community, where people share LEGO pieces(I call them Assets), but they also share where and how in the code they've made the connections. After some time there will be enough connections so users will just re-use them. Only time will show how well it will work.<p>I wrote about it few weeks ago: <a href="https://skyalt.com/blog/dsl.html" rel="nofollow">https://skyalt.com/blog/dsl.html</a><p>>I have a plan on how to do that on paper, but because connecting assets together can be complex, it's better If most of the users don't do that. The key thing is that users don't share only assets, but also how and where they are connected to each other. It's like when someone makes and publishes a library, but also example code for how to work with a library. But in SkyAlt, asset connections will be automated. This is also why it's very important to build and grow the community - more assets, more connections, which means easier to use.
Software re-use is limited by the primitive structures and algorithms in the language and runtime library. The more fundamental parts (queues, strings for example) that are left to the user to implement, the less likely it is that it will be possible to make compatible components.
I feel like if even on a purely technical level we eventually achieve Lego like reuse that the business and social layer of things will ensure that somebody always requires an off brand Lego block to be shoved in there. It's almost human nature.
The reason for this is that LEGO has a tightly regulated interface that each piece must adhere to. This interface regulation doesn't exist in software to that degree, nor is it necessarily desirable.
Well designed modular software is certainly like Lego. It just takes investment. It is a choice to have organ transplant software be the default. That choice is non investment.
Depends on the software. Or to torture the analogy a bit: you can build anything out of LEGO if you're willing to use a jigsaw, some Gorilla glue, a blowtorch...<p>The point of frameworks is to provide the standardization of the "shape" of various bits of software so it's a lot more like snapping together LEGO. But even then, LEGO isn't universally snappable; some blocks just don't click to other blocks in the product line. And then, of course, there's the "illegal" block hacks (<a href="https://crafty.diply.com/28429/14-illegal-lego-building-hacks-to-pass-on-to-your-childrens-chil" rel="nofollow">https://crafty.diply.com/28429/14-illegal-lego-building-hack...</a>) that work in practice but are not at all using the tool the way it's specified. When software reuse <i>is</i> like LEGO, we should expect (a) some things we want to do, we can't really do without jigsaws and glue and (b) sometimes, people <i>will</i> do things that the software technically allows but no sane person would call "desired" or "intended."<p>In fact, the LEGO-to-framework analogy works pretty great. And yeah, outside the context of a consistent (and, I'd argue, opinionated) framework, you're about as likely to have two pieces of software interoperate as you are likely to pick two random chunks of matter in the universe, slap them against each other, and have anything useful happen. I just tried it with a brick and this glass of water on my table. Now I have "wet brick in a pile of shattered glass," but I don't know anyone's going to give me a Series-A funding round for that.
Reuse of my own sloppy code is always easy. But reuse of complex code created by others is often far more difficult since context is missing. Creating god reusable software code block, are often the lower level apis The more context specific software is, the harder reuse gets. It’s the pain of generic vs context specific imho.
Fred Brooks had a similar take, in an opinionated way, with the concept of "lead surgeon". Motivation to re-read the chapter in mythical man-month.
So. Every editor has copy/paste functionality and search/replace.
Using that plus following the SOLID principle is my way to reuse code. And it is as if I would build with LEGO bricks.<p>I tell you even a secret. Every piece of software has all the code you need to work with it already - just copy/paste stuff. You only need to know where it is. Every piece of software is it's own tutorial how to make that particular piece of software.<p>I've done this for years. I call my method of working copy/paste method.<p>And by reading this, I think I know why I piss so many programmers when I say what I do. And how fast I am with it.
Someone well-known in the IT field wrote about software reuse in the large vs. in the small about 10-15 years ago. The gist was that reuse in the small is a success, i.e. it's fairly simple to write a function that developers reuse within an application. When you try to generalize use beyond a certain context it becomes significantly more complicated to be successful. I think the motivation for the post was issues in object reuse in OO development. I'm trying to find the original post.<p>John D. Cook's post shines the light once again on the difficulty of writing reusable components.
I would say software integration is more like a docking mechanism between spacestation units that were designed in isolation by different countries than like snapping LEGO blocks. At least software pieces are products of human design and failure points can be identified without the many inscrutable emergent phenomena and often-unmeasurable unknowns of biology.
Lego is general graph structure. Our programs have roughly star topology - bunch of libraries and some control logic that drives it. Good libraries _are_ like snapping Lego blocks. Those have good scope around domain, well designed API and establish abstractions that don't leak. Think sqlite, zeromq, zlib. The central controlling part is too "involved" in domain and chosen tech stack to reuse easily.<p>The software that requires organ transplant just wasn't written to be reused. It is a matter of effort and cost. You cannot just solve your problem and wrap it in a library - you need to take care of all common use cases, define edge case behavior, test, document... It costs a lot more and that price is hard to justify. In the end it's the product that makes money and library is forgotten as long as it does its job. We need to fix the open-source income ecosystem.
When reading the title I figured it would explain something different to what the author does: when doing a organ transplant (except for the liver maybe) the organ is no longer usable to the donor.<p>Translatable to software, your reusable piece of code might not be so reusable as you think, missing lots of abstractions and having lots of specific code for just one specific consumer. Taking a piece of functionality from one part of your software and using it for something else might harm the original use due to broken API's, introduced complexity latency and failures, etc. Even ending up with having 2 split versions of your reusable component for each use case that you now have to maintain seperately.
I disagree.<p>Never has it been easier to find existing code, download it and snap it into your project. Npm, nuget, etc, etc.<p>Also, on the front end there are no shortage of plug and play widget libraries.<p>Sometimes we need to take a step back and appreciate how things have improved over the years.
This is not that accurate if we talk about libraries. Those mostly have well defined scope, well defined interface, and are designed to be integrated so most definitelly feel like LEGO.<p>However, this is totally accurate when reusing the code from your previous project on your next one. I developed many large gov services, and each one reused bunch of stuff from previous ones like user management, complete areas of functionality etc. Here, the analogy is adequate, artefacts from previous projects creeep in constantly. This feels more like single project evolving (or devolving) over long period of time (years to decade).
My favourite form of software reuse is when I just use my old code as reference but import or duplicate almost none of it.<p>Feels so good to write similar software in 1/10th the time because the hard fought ideas are already won.
<a href="https://github.com/kohler/click" rel="nofollow">https://github.com/kohler/click</a> is a library that I've found has a lot of reusability built into it, and operates a lot like snapping Lego blocks together.<p>When you're talking about not being able to reuse code, I think it depends on how you've designed your system.
Design for reusability seems like it needs to be key goal in development in order to achieve software re-use.
The reason Lego works is a simple, well-defined interface. Two bricks stick together by friction because the stud pattern on one matches the hole pattern on the other precisely. Fortunately, that's a model that translates well to software.<p>The way to make software reuse more like organ transplant than building Legos is to ignore the advice to keep the interfaces simple and precise. Or worse, don't even bother defining an interface, its data types, or error conditions.
When I hear "snapping software like Lego bricks" my mind immediately goes to the Spring Framework, which must be one of the largest, most-used, and most complete (modern) attempts at this paradigm. I haven't used it for anything large, but I would say it does not deliver on that promise.<p>I'm curious to hear from those who have worked on large, sophisticated, Spring Framework apps - does it really feel like snapping pieces together?
"People have been comparing software components to LEGO blocks for a couple decades. We should be able to assemble applications by snapping together modular components, just like LEGOs. There has been progress, but for the most part we haven’t realized the promise LEGO-style software development."<p><pre><code> pg_dump -U postgres db | ssh user@rsync.net "dd of=db_dump"
</code></pre>
... looks like Legos to me ...
OK but going all like it is not worth much because it is high chance of failure is not helpful. Once I got burned on quite good interview when I went a bit to far with notion that re usability in software is fake. In the end you have to fix some things but it is not like someone is going to die. Unless you really count on it and have really constrained budget, but in such case you asked for it.
Having not used any of the following I may be wrong here, but
don't dataflow languages (eg Labview?) come close to this? <a href="https://en.wikipedia.org/wiki/Dataflow_programming" rel="nofollow">https://en.wikipedia.org/wiki/Dataflow_programming</a><p>And isn't GNU Radio effectively a domain-specific language for plugging signal processing elements together?
See also: Joe Armstrong, 'Why do we need modules at all?'<p><a href="http://erlang.org/pipermail/erlang-questions/2011-May/058768.html" rel="nofollow">http://erlang.org/pipermail/erlang-questions/2011-May/058768...</a>
As long as each single project keeps reinventing their own Lego stubs, we won't be going forward with reuse.<p>With Haskell and Scala's type-system we seem to come closer to universal Lego. Still, like Lego, it can be hard to combine larger scale composites.
I write full stack web in various functional programming languages, and I am constantly copy-pasting 'lego blocks' between projects. If the compiler is happy, I'm happy.
Is software just too easy to write that everything becomes incompatible. Everyone has the next best idea. It's XKCD 927 all the time.<p>Now if you instead look at Trucks and Campers, Rear Hitches, Fifth Wheels Hitches, Goose Neck Hitches. Every truck you can buy on the market today (with some strange exceptions Cybertruck cough) has very simple compatibility with all of these various trailer types. Yes in some cases you have to buy a mod kit, but when you look at the mod kit it literally bolts into pre-drilled holes in your truck frame. It's all plug and play.<p>I feel like the reason it's like this is because no one person can go off and design a truck in the dark. It's designed by many people and is beholden to customers.<p>Software, on the other hand, just gets built by whoever wants to build something. It doesn't have to fit some kind of standard. And it's not like there are a lot of standards that already exist in whatever it is that the software is doing.<p>In the real world however, you have Kubota tractors that need to fit a CAT bucket.<p>I mean just read this page:<p><a href="https://www.spartanequipment.com/pages/buying-tips/attachments-buyers-guide.html" rel="nofollow">https://www.spartanequipment.com/pages/buying-tips/attachmen...</a><p>Small quirks to it, but yeah, the rest of the world really is Legos, Software is organ transplant.
> <i>Software reuse is more like an organ transplant than snapping Lego blocks</i><p>Funny, but Lego fans almost interpreted "organ transplant" exactly as "snapping Lego blocks".[0]<p>[0] <a href="http://xkcd.com/659/" rel="nofollow">http://xkcd.com/659/</a>
Have you guys heard of functional programming?<p>Have you guys wondered why some people are so fanatic about functional programming?<p>Functional programming forces your program to be lego blocks by Definition.<p>A function with no side effects IS A Lego Block.<p>If I never discovered functional programming I'd be like John D. Cook, blogging about how programming is like organ transplantation.<p>Functional Programming is the answer to the question that has plagued me as a programmer for years: How do I organize/design my program in such a way that it becomes endlessly re-useable from a practical standpoint?<p>If this question plagues you as a programmer I urge you to take a closer look at functional programming. Specifically look at functions and function composition.