4 ms·
Sure, the example in the video isn't perfect. If you think you have a better way of doing things, you can always submit it as another snippet, and that's the wh
by MajorMcDoom 15y ago
Sure, the example in the video isn't perfect. If you think you have a better way of doing things, you can always submit it as another snippet, and that's the whole point. The video isn't trying to promote the specific code snippets - it's trying to promote one way to find and integrate them.
- kragen 15y agoI do think I have a better way of doing things: instead of writing snippets that people then copy and paste, write functions, methods, and modules that people can then simply call. This results in software containing ten times less code, which makes it dramatically easier to fix, maintain, and extend, than a system built by copying and pasting code snippets. Now, I am not going to claim that this is a new idea. Ada Byron, after all, invented the subroutine. What I am going to claim is that programming by pasting snippets together and editing them, which is not a new idea either, is a stupid idea. The idea is probably at least as old as the subroutine. We have something like 60 years of experience with programming by copy-and-paste. That's plenty of time to figure out that it's stupid. It's a bad idea. It makes your programs hard to understand and hard to change. We'll probably never stop doing it, because sometimes it's unavoidable. But having a search engine that makes it even easier to paste code snippets does not make pasting code snippets a better idea. It makes it a worse idea, because it means that you can screw yourself more quickly and thoroughly. I want to see a case that you think is better written using pasted-together snippets of code instead of by calling subroutines. The burden of proof is not on me; I'm just explaining the conventional wisdom. It's on you if you want to show that the conventional wisdom is wrong. I do think that a search engine for APIs would be useful, and that a lot of APIs suck.
- moondistance 15y agoInteresting point. Programmers would still need to search for methods to call. You can use CodeMatch to write snippets that call methods and CodeMatch can also auto-import libraries (or insert the classes/methods inline). Of course, this isn't featured in the video.
- jrockway 15y agoAdding the import statement is fine. Method auto-completion is something I'm not OK with; it encourages API bloat and overlyDescriptiveNamesThatJustMakeTheCodeHarderToRead. I don't program Java, but I might also be OK with having a program add type names where necessary. For example, you type "foo = new Foo()" and the software will add "Foo " in front, making the line "Foo foo = new Foo()". But, programming in terms of concrete instances is To Be Avoided, so maybe default to an interface and allow the programmer to toggle between the interfaces Foo implements. It would have to be a measurable win, though; typing FooI is not that hard, after all. I'm definitely not discouraging the use of tools to make managing boilerplate easy; but it's a very fine line, some boilerplate cannot be eliminated with clever library use (imports), but some can (finding the path to the Desktop). Once you have a super-cool boilerplate generation tool, it becomes more tempting to add a quick snippet than to fix the language or library deficiency that's pushing you in the direction of too much typing. Sometimes it's good to imagine things taken to the extreme. Imagine that C didn't have a preprocessor but it did have an editor that had really good snippets. Instead of saying #define PI 3.14 in your math.h file, the snippet would just type 3.14 in for you whenever you said "insert pi". This would produce the same object code as the preprocessor, but without another extra piece of machinery to mess up your source code. What you type is what the compiler sees! Turns out that this isn't good, because computers are really good at pushing symbols around, but humans aren't. So don't show the humans the details, show them the abstract and let the compiler push symbols around. (I've always wondered why someone doesn't add a preprocessor to Java. See also: coffeescript / javascript.)
- moondistance 15y agoHow does CodeMatch encourage "overlyDescriptiveNamesThatJustMakeTheCodeHarderToRead"? I don't think it does. Search results are not code snippets. If you're suggesting that the tool isn't useful or to be encouraged (as you seem to suggest in earlier posts), I'm interested in better understanding your rationale. As far as I can tell, you have only critiqued possible ways that CodeMatch could be used, not CodeMatch itself.
- 15y ago