is it considered cheating if i use a library to simplify messy and huge JSON and data structures into a simplified object, rather than inventing an algorithm that is optimised for O time and is "beautiful"?
Posted by Intrepid_Witness_218@reddit | learnprogramming | View on Reddit | 17 comments
perhaps you already can tell my position on the matter, but if you disagree, then why? why does coding need to be something so discrete-math proofy thing?
TechBriefbyBMe@reddit
Using a library that solves your problem is literally what every working programmer does. The "beautiful algorithm" era ended when we realized shipping code matters more than impressing computer science professors.
heisthedarchness@reddit
This is a strawman argument.
Ok_Option_3@reddit
I'd take clean simple code over "optimised" code every time!
As a rule of thumb, if it's not worth implementing metrics to see how fast / efficient something is then it's not worth "optimistic" for performance.
Having said that, it's far from clear in your question how a library will help here. It could be you're reinventing the wheel and a library would eliminate a bunch of code, or it could be that a library brings unnecessary complexity and risk.
Intrepid_Witness_218@reddit (OP)
like getting one value from a json file that matches with another, pretty big, pretty nested, put in the same route as an api call, it can take pretty long to load up on the client's side if you patch up a o(n) algorithm, but a log time algorithm or anything faster using the vanilla version of a language can get extremely more complicated to just make up yourself
Ok_Option_3@reddit
With data structure work, if the set is small (i.e. less that a million records), the best strategy is to flatten the data into a table using something like python's pandas.
The advantage is that the in built join algorithms are efficient, and if you need to change the input / output structures, or add more data, it's usually a very small code change.
HashDefTrueFalse@reddit
Usually in the world of work people mostly care about the results and the costs to get them. Part of my work involves performance optimisation, and I say "part" because we don't bother to optimise things that are not slow and/or expensive to run. There are tons of considerations before rolling up your sleeves. If you're just using common dependencies to speed up development of software that doesn't need to pass any safety and/or security scrutinisation then nobody minds. However, if you don't actually have the ability to make anything useful happen without needing to pull in the kitchen sink then you'll obviously be more limited in the work that is available to you. Some software requires mathematical rigour and ideas, lots doesn't. There's no "cheating" and it has nothing to do with who coding is for (everyone who is interested).
sch0lars@reddit
You will always use some level of abstraction in programming. Even writing to standard output is abstracted by the OS.
Is using a library cheating? Absolutely not. There’s no point in reinventing the wheel.
Should you understand what that library is doing? Absolutely.
Are there times when you would be better off writing your own solution? Definitely. I worked with embedded systems for a time and we used third-party libraries for some things and wrote our own libraries for others because things needed to be absolutely optimal.
A good programmer should know when to use a pre-existing solution and when to write their own.
tmtowtdi@reddit
Premature optimization is the root of all evil. Use the library first and optimize later if you need to.
99.9% of the time, you won't need to.
Savings-Cry-3201@reddit
Yeah, it is. And you should feel bad about. What are you thinking, saving time like that and not reinventing the wheel? We need another wheel! More wheels!
zedeloc@reddit
Depends on why you are doing it. If this is an assignment, there's probably a good reason to jump through this hoop. If you're literally just coding your own tools, are at work, etc... it's probably wasteful to be rewriting something that's already been done well and packaged in a neat little library
joranstark018@reddit
Use libraries if they suit your needs and requirements.
If you really need a better optimized implementation of some algorithm and you think you can implement it properly, go ahead. You need to make a judgement call if it is worth the cost of maintaing your own implementation in the long run.
Beregolas@reddit
Okay, who are you cheating? If you are still in school, there are rules. If you are in my DSS class, I expect you to come up eith your own Algorithms.
If you are building software, there literally is no one you can cheat. Reinventing the wheel, while fun, ist also a bad move if you actually want to build something complex. There are always two things you need to wheigh against each other:
If you import a library, your code will be simpler and easier to maintain. It will also be easier for others to understand when they join the project, because it's generally easier to understand a well documented libraries API tham self written code. Especially if you already used that library before, which is not an option with cudtom code.
If you build it yourself you have ghe option to make it more specific to your usecase. You also have one less dependency, which is also an advantage in simplicity and security.
It's always a trade-off, and the "better" option changes from case to case.
Also, please don't attempt to gate keep programming. Intelligence definitely helps, but there is no "you must be this big to ride" check lole a rollercoaster before you are allowed to program. Except for severely disabled people, I don't think that anyone is inherently unable to program.
Programming is just a trade, lile carpentry. Nothing special, nothing magic. You can do the most complicated and fancy shit, or you can just build a chair, that is nothing special, but works. No need to be a genius.
Sea-Cell5315@reddit
nah using libraries is literally what they're made for. like why would you reinvent the wheel when someone already solved that problem and probably did it better than most of us could in reasonable time
the whole "beautiful algorithm" thing is nice for learning but in real projects you want code that works, is maintainable and gets shipped. i've seen so many projects get stuck because someone wanted to write the "perfect" solution instead of just using existing tools
also that edit question is kinda weird - coding absolutely is for everyone, using libraries doesn't make you less of programmer. some of best developers i work with are amazing at knowing which tools to use rather than building everything from scratch
Intrepid_Witness_218@reddit (OP)
i'm a bit salty cz this discord server saying i'm not a real programmer cz idk and i dont like discrete math
Wolfe244@reddit
You gotta grow up man who the fuck cares about random people in a discord
johnpeters42@reddit
The importance of optimization depends on how slow the simpler alternative is, and how often it runs. If it's a difference of half a second ten times a day, then men. Five seconds a million times a day, on the other hand--
cgoldberg@reddit
I don't really understand the question, but most people will use an existing library rather reinventing the wheel... and that's fine.