News for hackers. Stuff that matters.
Re:Ask HN: When do you use a library vs. implement something... by terminalcommand on Friday April 20, 2018 @01:18AM (#16882316)
I try and stick to the my language's standard library whenever possible. Because I know that the stdlibs will be maintained and it won't be a waste of time to learn them.

If I really need to use some library (for example Graphic toolkits etc.) I tend to try to understand it by looking at its source. I try to make some modifications in it, try to make them run. That way I get somewhat an understanding of the library and the problem domain itself.

Usually you only need a small part of a library. You can look at the implementation at that library and then incorporate it in your program and slowly improve it. That way your dependencies won't get bloated, you'll get a customized solution with little effort and if you encounter problems you'll know where to fix them. That's a trick I've learned over the years.

Re:Ask HN: When do you use a library vs. implement something... by sebazzz on Friday April 20, 2018 @01:26AM (#16882344)
You must be a native programmer. I have found that collegues using managed languages are much less conservative compared to collegues who program using native languages (primarily C/C++).
Re:Ask HN: When do you use a library vs. implement something... by mcepl on Friday April 20, 2018 @02:33AM (#16882606)
Or she is a programmer working with a sensible programming language with sensible standard library (e.g., Python). I would really like to like NodeJS, JavaScript is not that bad language in itself, but missing standard library is a problem for me.
Re:Ask HN: When do you use a library vs. implement something... by mort96 on Friday April 20, 2018 @04:55AM (#16883235)
Node has a pretty big standard library really (in fact that's all node.js is; a module system and a ton of modules built on top of a JS engine). What do you find is missing compared to Python's standard library?
Re:Ask HN: When do you use a library vs. implement something... by Doxin on Friday April 20, 2018 @08:27AM (#16884180)
The fact that there was a need for the left-pad module is pretty telling on how comprehensive the stdlib in js is.
Re:Ask HN: When do you use a library vs. implement something... by mort96 on Friday April 20, 2018 @02:06PM (#16887055)
I wasn't really interested in your opinion based on the lack of one 1-line utility function (and it is one line: `new Array(10 - str.length).fill("0").join("") + str`). I was interested in what significant functionality OP found lacking in node.js' standard library.
Re:Ask HN: When do you use a library vs. implement something... by Thiez on Friday April 20, 2018 @11:29AM (#16885563)
Which programming language are you using that has left-pads functionality in the standard library?
Re:Ask HN: When do you use a library vs. implement something... by mort96 on Friday April 20, 2018 @01:57PM (#16886971)
Well, python's strings have the ljust and rjust methods which left- and right-pad, and javascript has the padStart and padEnd methods (since ECMAScript 2017).
Re:Ask HN: When do you use a library vs. implement something... by scarface74 on Friday April 20, 2018 @07:09PM (#16889044)
Re:Ask HN: When do you use a library vs. implement something... by bausshf on Friday April 20, 2018 @08:01AM (#16884042)
Re:Ask HN: When do you use a library vs. implement something... by mort96 on Friday April 20, 2018 @01:56PM (#16886953)
I'm pretty sure that's talking about all the third-party libraries which exist for Python; that this "antigravity" library is available for Python, not a part of its standard library. (I might be wrong though, I'm not Randall Munroe)
Re:Ask HN: When do you use a library vs. implement something... by greenhouse_gas on Friday April 20, 2018 @03:08AM (#16882726)
I think its about which languages have good dependency management.

For example, Go, C and C++ have bad dependency management, so most programmers will try to stick to stdlib solutions, only moving to dependencies if copy-paste is an overkill (I wouldn't copy-paste sqlite wrappers, but I would copy-paste a left-pad like function).

NPM and Rust (which isn't managed) has great dependency management, so they move things out of stdlib into packages.

But, it backfired when no one is sure which packages are official, so Rust made a "nursery" of officially maintained out-of-stdlib standard functions.

Re:Ask HN: When do you use a library vs. implement something... by kazinator on Friday April 20, 2018 @09:24PM (#16889516)
Dependency management isn't a concept in C++. C++ is an ISO standard language with numerous implementations; it's not a software package. A C++ compiler from Microchip for your PIC microcontroller has nothing to do with Microsoft Visual C++ has nothing to do with GNU C++ on your Linux box, etc.
Re:Ask HN: When do you use a library vs. implement something... by greenhouse_gas on Sunday April 22, 2018 @01:02AM (#16894788)
ECMAScript is also an (ECMA) standard language. Yet it has NPM.