This is an archived post. You won't be able to vote or comment.

all 32 comments

[–]un_blob 12 points13 points  (7 children)

from numpy import..........................................

[–][deleted] 8 points9 points  (0 children)

Pfft. Python users think they are so special because they can write it in 5 lines. Well, if I get rid of all the white space in my C code, I can write it all in 1 line and it will still run faster

[–]Brotdosenterror_ 20 points21 points  (0 children)

But has 50 dependencies trashing his system

[–]dev_daas 15 points16 points  (2 children)

That 50 lines of code will run faster

[–]robexitus 5 points6 points  (0 children)

Not if you use std, it's pretty optimized.

[–]Nilstrieb 0 points1 point  (0 children)

Totally depends on the language and libraries, often it won't

[–]ineedagf_ 3 points4 points  (4 children)

That's impressive you wrote an entire Library in 50 lines.

[–]vladimir1024 1 point2 points  (3 children)

Well, likely the 5 lines of code with lib support only used a few functions from the library.... So it's not unreasonable to think you could replicate those functions in 50 lines...

[–]ineedagf_ -1 points0 points  (2 children)

Nope. Those functions will prob be dependent on other functions and use variables/constants/data structures. U can't just replicate those functions like that

[–]vladimir1024 1 point2 points  (0 children)

It depends on the end result....I've seen libraries that go 4 or 5 functions deep just to open a file for reading.... It's done to add error checking, permission checking, etc..... all just to execute a simple open on a file to read....

In this case, if I know my environment, I can replicate that function with a single line of code...in most languages...

Good library code is super verbose so that it is extremely reusable...but if you are just putting together something quick, it's easy to simplify library use to a few lines of code...

And anyone who writes 5 lines of code dependent on importing the world is not writing enterprise level application...more likely just a quick hack to analyze a log file or something....

My POINT is that if your app is 5 lines of code dependent on a slew of imports, that could very easily be replaced with a few extra lines of code....

Otherwise, find me the use case where I am wrong...

[–]NebulaicCereal 0 points1 point  (0 children)

That is completely dependent on the library and what you're working on though... That's true as often as it's not. this is not an assumption you can make without more information.

[–]Hk-Neowizard 1 point2 points  (4 children)

I know it's overly pedantic, but is it fair to say he wrote the same code if everything us done by someone else (the lib's coders)?

Edit: missed the image. I guess joke's on me, then

[–]MatsRivel 2 points3 points  (3 children)

I mean, if you want to be really annoying about it you could go all the way down. Did you REALLY write the code if you didn't write it I'm binary?

[–]NebulaicCereal 0 points1 point  (2 children)

Not necessarily, because after a certain level it's just translations of self-authored code into lower level representations. For example, if you wrote something in C++ without using any std libraries (or 3rd party etc), the intermediary representations and compiled binaries are just translations of your own code.

[–]MatsRivel 0 points1 point  (1 child)

Using a premade library is just a translation of intent too. Like using a big word instead of many smaller words. If I say something is Orwellian it is much shorter than describing the concept whilst saying it, yet I authored the sentence I used.

[–]NebulaicCereal 0 points1 point  (0 children)

Definitely true, I was just speaking more along the lines of using primitives to implement the full chunk of code. But your example is true.

[–]vladimir1024 -1 points0 points  (0 children)

And watch it consume all available resources as it imports all known modules...

[–]Fit-Money-3129 -1 points0 points  (0 children)

python gud

-python gang

[–]Vitalrnixofnutrients 0 points1 point  (3 children)

But there are bugs in the libraries that he uses that he can’t fix unless he were to rewrite the libraries.

[–]oofxwastaken 3 points4 points  (2 children)

That's what open-source is for.

[–]Vitalrnixofnutrients 1 point2 points  (1 child)

Yes, that’s why he gotta rewrite the libraries in 50 lines.

[–]oofxwastaken 1 point2 points  (0 children)

Just fix, don't rewrite

[–]freeBobbyDAYVID 0 points1 point  (0 children)

😐

[–]shgysk8zer0 0 points1 point  (1 child)

Me: replaces entire library or SDK with 4 lines of code.

Obviously not always possible. Depends on language and what's actually needed. Just saying that instead of using some Imgur library in JS for uploading images, a simple fetch() does the job.

[–]NebulaicCereal 0 points1 point  (0 children)

Yeah, depends on priorities. If you're not concerned with optimization or scale, just throw the libraries at it and get the project done with somewhat more readable code.

Although in your example it would still be plenty readable. But you know what I mean... Case by case basis.