7 ms·
I was talking to a friend the other day about the backlash against Clippy in Office. Reading these release notes, can't help wonder if IDE's will soon need an e
by shrumm 6y ago
I was talking to a friend the other day about the backlash against Clippy in Office. Reading these release notes, can't help wonder if IDE's will soon need an equivalent.
Something like -> "Hey! it looks like your function only accepts a fixed set of strings. Would you like to use String Literals?"
I don't only code in Typescript so it's not practical for me to keep up with every language I work with.
Search works great if you know what you want, then you'll end up on these excellent release notes or a stackoverflow post and off you go. The trouble is when you don't know what you don't know.
- k__ 6y agoActually, I think it would be nice to have a chatbot in my IDE that would analyze my code and help me best practices.
- ht85 6y ago> The trouble is when you don't know what you don't know. At least the pain is a good indicator that there's something you're missing :) IRC has been somewhat useful for TS, albeit with mixed results compared to say, the gentle gods you will find in #postgresql.
- orta 6y agoThere's definitely teams at MS exploring about this problem (e.g. IntelliCode is my favorite for TS https://docs.microsoft.com/en-us/visualstudio/intellicode/intellicode-visual-studio-code https://docs.microsoft.com/en-us/visualstudio/intellicode/in... )
- presentation 6y agoThey don’t cover everything and it requires setup, but I like using linters for this kind of thing - these types of suggestions can often be standardized in a codebase and auto fixed by tools like ESLint nowadays, it’s also a good way to make people aware of features.
- mssundaram 6y agoInteresting, any examples you can share?
- agumonkey 6y agoWould be a natural extrapolation of Elm typecheck ergonomics. But it may be frowned upon in shops because the IDE does too much ?
- Serow225 6y agoJetBrain IDEs are pretty amazing at this.
- hnrodey 6y agoHow I actually learn to use the new language features ; )
- dimeatree 6y agoA good application for ML
- justatdotin 6y agoits funny cos its true, just not the way you mean.
- gorgoiler 6y agoAutomated code sniffing sounds like a fantastic idea. Perhaps we’ll look back to the 2010s as the dark ages, when all we had at our disposal was peer review of our codes? Review early and (fairly) often, lest you embark on implementing a FrobNibulatorFactory from the ground up only to be told there is one already in lib/util/frob/util/tools/misc/nibulation. Not everyone has peers, alas. The imaginary ones help (rubber ducky, you’re the one...)
- foepys 6y agoThis has been around for years in .NET and Java IDEs and I'm sure in many more places. Jetbrains' ReSharper is famous for its complex code analysis with useful hints to improve code readability and robustness. A single click can refactor your code. .NET's Roslyn compiler supports analyzers that you can write yourself which also support code fix providers to automatically refactor code. All analyzers and code fix providers are written in .NET languages (C#, F#, etc.), so the possibilities are endless.
- catlifeonmars 6y agoYes but how sophisticated is the code analysis? I’m curious if there are tools that can do things like: - detect and replace first party algorithms with third party libraries. For example, recognizing a hand-rolled binary search implementation and swapping it out. - recognize design patterns - apply suggestions based on solid principles
- jolux 6y agoWell in C# the collections have efficient searching and sorting built in :) but as for whether they can recognize design patterns — VS and R# can definitely move members and symbols around fluidly within a class hierarchy.
- foepys 6y agoFor performance you subscribe on a specific syntax kind in the syntax tree (like if, condition, operator, variable definition, etc.), the compiler calls your analyzer, and then you get a context object where you get full access to the syntax tree. After that you are only limited by your imagination.
- Anon4Now 6y agoHave you ever used Visual Studio? It sounds like you're describing the code analyzers that have been available for several years now. For example, with an opportunity for string literals, there will be a light bulb in the left border. Pressing "Ctrl ." will bring up a list of suggested fixes. You can opt to select one, hit Enter, and the changes are automatically applied. I believe there are similar extensions for VS Code.
- fy20 6y agoVS Code does this for TypeScript out of the box. For example if you have a function with Promises it will suggest it be rewritten (and rewrite it for you) using async.
- emteycz 6y agoIt's very dumb compared to what's available for C#, though. C# code helpers are able to code a simple class with their suggestions.
- smt88 6y agoThe only reason you need your IDE to write classes for you in C# is because C# has nominal typing and tons of boilerplate (ex: getHashCode()). I've written millions of lines of C# and hundreds of thousands of TypeScript, and I use JetBrains JDEs for both these days. Class generation is absolutely not something I need or miss in TypeScript.
- manigandham 6y agoThat boilerplate is automatically added by the compiler. You don’t need an IDE to do it. There are tons of examples of very lean C# that can be written in notepad.
- smt88 6y agoBefore records, the compiler did not generate code required to properly use classes (or even structs) as value types. There's a reason everyone is so excited about records. I have apps with thousands of lines of implementing comparison/equality interfaces, overloading operators, etc. for my data objects. You can definitely write it all in Notepad, but it would be a massive waste of time.
- brynjolf 6y agoFor C# there is an extension called Sharpen [0] that alerts you of new features in the new languages, it is quite nifty when you are ready to move to the next version of .net core for example and want to know where you can remove code etc. [0] https://marketplace.visualstudio.com/items?itemName=ironcev.sharpen https://marketplace.visualstudio.com/items?itemName=ironcev....
- tomphoolery 6y agoI always joked about how IntelliSense is just Clippy for your IDE. But yeah, it's pretty useful. coc.vim and tsserver save me from getting fired on a daily basis.
- manigandham 6y agoModern IDEs already have all that, it's a basic feature of being an IDE in the first place as opposed to just a text editor.
- onion2k 6y agoIDEs will make suggestions for fixes to apply after you've written the code. Clippy made suggestions a lot earlier than that.
- Matumio 6y agoAbout early suggestions: https://www.commitstrip.com/en/2020/06/11/im-watching-you https://www.commitstrip.com/en/2020/06/11/im-watching-you
- DangitBobby 6y agoI use modern IDEs exclusively, and yet I have to fish for features like this (typically by searching for an error message) all the time. I'm sure there are many instances where I've come out with sub-optimal fixes because I didn't not know about a feature and my IDE didn't either.
- cpursley 6y agoThis is exactly what the Elm compiler does: https://elm-lang.org/news/compiler-errors-for-humans https://elm-lang.org/news/compiler-errors-for-humans
- Huggernaut 6y agoRust has a tool called, you guessed it, Clippy, that does very similar things to what you suggest: https://github.com/rust-lang/rust-clippy https://github.com/rust-lang/rust-clippy The Rust compiler exposes a lot of information, so it's actually quite powerful in my experience.
- Vinnl 6y agoAnd the JavaScript/TypeScript equivalent would be eslint. (Which doesn't have as brilliant a name and has less information available to it, but it's still very helpful.)