News for hackers. Stuff that matters.
Re:I've Just Liberated My Modules by maxaf on Tuesday March 22, 2016 @08:17PM (#11341051)
Taking an idea to the logical extreme is an effective means of invalidating said idea. How many UNIX utilities are 17 silly lines long?

A bit of code duplication would go a long way towards bringing sanity to JS land.

Re:I've Just Liberated My Modules by joshmanders on Tuesday March 22, 2016 @08:20PM (#11341075)
Quite a bit are pretty small.
Re:I've Just Liberated My Modules by cballard on Tuesday March 22, 2016 @08:22PM (#11341083)
Re:I've Just Liberated My Modules by akkartik on Tuesday March 22, 2016 @08:38PM (#11341175)
Erm, that's not a very good example. You're pointing out some ancient source file from back when unix had no package management. These days echo.c is part of coreutils, a large package which is economic to manage dependencies for at scale.

It's interesting to think about the distinction between promiscuous dependencies (as pioneered by Gemfile) and the Unix way. I like the latter and loathe the former, but maybe I'm wrong. Can someone think of a better example? Is there a modern dpkg/rpm/yum package with <50 LoC of payload?

Edit: Incidentally, I just checked and echo.c in coreutils 8.25 weighs in at 194 LoC (excluding comments, empty lines and just curly braces). And that doesn't even include other files that are needed to build echo. Back in 2013 I did a similar analysis for cat, and found that it required 36 thousand lines of code (just .c and .h files). It's my favorite example of the rot at Linux's core. There's many complaints you can make about Unix package management, but 'too many tiny dependencies' seems unlikely to be one of them.

Re:I've Just Liberated My Modules by voltagex_ on Tuesday March 22, 2016 @10:12PM (#11341639)
What on earth is cat doing that it needs 36KLoC (with dependencies)?

I'm starting to see where http://suckless.org/philosophy and http://landley.net/aboriginal/ are coming from (watch Rob's talks, they're very opinionated but very enjoyable).

Re:I've Just Liberated My Modules by akkartik on Tuesday March 22, 2016 @10:17PM (#11341650)
Yup! In fact the only other data point I have on cat is http://landley.net/aboriginal/history.html which complains about cat being over 800 lines long back in 2002 :)

I didn't dig too deeply in 2013, but I did notice that about 2/3rds of the LoC were in headers.

Re:I've Just Liberated My Modules by voltagex_ on Wednesday March 23, 2016 @12:36AM (#11342188)
>"When I looked at the gnu implementation of the "cat" command and found out its source file was 833 lines of C code (just to implement _cat_), I decided the FSF sucked at this whole "software" thing. (Ok, I discovered that reading the gcc source at Rutgers back in 1993, but at the time I thought only GCC was a horrible bloated mass of conflicting #ifdefs, not everything the FSF had ever touched. Back then I didn't know that the "Cathedral" in the original Cathedral and the Bazaar paper was specifically referring to the GNU project.)"
Re:I've Just Liberated My Modules by GFK_of_xmaspast on Wednesday March 23, 2016 @08:16AM (#11343713)
The version of cat.c here: http://www.scs.stanford.edu/histar/src/pkg/cat/cat.c has 255 lines in the source, and brings in these headers:

#include <sys/param.h> #include <sys/stat.h> #include <ctype.h> #include <err.h> #include <errno.h> #include <fcntl.h> #include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h>

which are needed for things like memory allocation, filesystem access, io, and so on.

One can imagine alternative implementations of cat that are full of #ifdefs to handle all the glorious varieties of unix that have ever been out there.

Re:I've Just Liberated My Modules by maxaf on Tuesday March 22, 2016 @09:26PM (#11341417)
The main point in support of your argument is the fact that Unix utils are bundled in larger packages instead of shipping in single-command packages. Think of Fileutils, Shellutils, and Textutils... which got combined to form Coreutils! Ha! That leaves only Diffutils, for the time being anyway.
Re:I've Just Liberated My Modules by akkartik on Tuesday March 22, 2016 @09:40PM (#11341476)
But none of Fileutils, Shellutils and Textutils was ever as tiny as many npm or gem modules.

I thought how commands are bundled into packages was the entirety of what we were discussing. That was my interpretation of larkinrichards's comment (way) up above. Packages are the unit of installation, not use. Packages are all we're arguing about.

My position: don't put words in God's mouth :) The unix way is commands that do one thing and do it well. But the unix way is silent on the right way to disseminate said commands. There you're on your own.

Re:I've Just Liberated My Modules by larkinrichards on Wednesday March 23, 2016 @01:49AM (#11342394)
Underscore/lodash is a great bundle of functions that do simple things well. And it's a tiny enough library that there is really no need to split it into 270 modules.

I support packages of utility functions. Distributing them individually is a waste of resources when you have tree shaking.

I trust a dependency on lodash. I don't trust a dependency on a single 17 line function.

Re:I've Just Liberated My Modules by joshmanders on Wednesday March 23, 2016 @08:54AM (#11343945)
While I agree with you, tree shaking is relatively new in the JavaScript world thanks to Webpack 2 and Rollup.js before that, if you had a dependency you brought it's whole lib into your project whether you used one method or all of them. So just including Lodash wasn't an option for people who cared about loading times for their users. A 17 line module was.
Re:I've Just Liberated My Modules by larkinrichards on Wednesday March 23, 2016 @06:33PM (#11348807)
Closure Compiler's advanced mode (tree shaking) has been around since 2010.
Re:I've Just Liberated My Modules by jdd on Friday March 25, 2016 @12:55AM (#11358552)
Lodash has been modular since 2013.
Re:I've Just Liberated My Modules by swang on Tuesday March 22, 2016 @08:32PM (#11341132)
yes, let's blow up the entire concept that's worked fine for the ~5 years of node's existence because one dude did something extreme.
Re:I've Just Liberated My Modules by dham on Tuesday March 22, 2016 @09:52PM (#11341538)
Woah woah. Hold on there. Lets not throw around strong words like "worked", "concept", "entire", "fine", "did" when discussing NPM.
Re:I've Just Liberated My Modules by Maarten88 on Wednesday March 23, 2016 @05:57AM (#11343141)
This. I'm on Windows. Npm never worked for me, like not at all. Npm has cost me lots of wasted time, I know I should be thankful for this free product, but, but, Grrrrr...
Re:I've Just Liberated My Modules by joshmanders on Wednesday March 23, 2016 @08:55AM (#11343954)
Windows has always been a problem for Nodeland, thankfully Microsoft is working on making that better.
Re:I've Just Liberated My Modules by bryanrasmussen on Wednesday March 23, 2016 @07:03AM (#11343380)
is unpublishing a module extreme?
Re:I've Just Liberated My Modules by smsm42 on Tuesday March 22, 2016 @11:18PM (#11341887)
I wonder how long /usr/bin/true source is.
Re:I've Just Liberated My Modules by cjs2 on Wednesday March 23, 2016 @03:31AM (#11342703)
Re:I've Just Liberated My Modules by Havvy on Wednesday March 23, 2016 @02:54AM (#11342599)
On Linux, it's 30ish lines, with half of those there to make false.c able to reuse some code. (I know, it's stupid.)

In OpenBSD, it's 3 LoC IIRC.

Re:I've Just Liberated My Modules by dalke on Wednesday March 23, 2016 @05:56PM (#11348583)
On at least one OS I worked with, it was 0 bytes long because /bin/sh on an empty file returns true. (I think that was IRIX 4.x.) OTOH, that's slower than the executable from a 3 LoC do-nothing program.