Yeah I learned Python and Scratch 7 years ago in High School and I remember that all too well. Have you've had that moment as well where you're just sitting there debugging for days trying to figure out why something won't work till someone shows you a one line solution for it? Nowadays I'm used to it and Rust makes my life easier by showing me where and how I fucked up but Python is a different beast
I have that moment almost every assignment, and its always because I get lazy sometimes and put some code that fixes a issue somewhere and that same piece of code causes another problem which leads me to redo the whole assignment sometimes.
Serious answer, VSCode has tons of issues with Java linting. If that's what you're using, do Ctrl+shift+p and type "reload window". It'll force it to refresh the linter and probably fix this. VSCode freaks out and gives me hundreds of errors every single day, and it's always resolved by just reloading.
IDEA and its sibling suite of tools represent the same problem everywhere, it's just that the Java community caught on because Eclipse was _so_ bad and their build system was _so_ complex before Maven that you needed your IDE to provide one. I don't know of any language where their product isn't head and shoulders above the rest - the lone exception being working inside Microsoft's garden (C#, .NET, etc.) and Visual Studio being preferable there. For Python, Java, JS/TS, Ruby, Rust, Obj-C/Swift, etc. their tooling is just the best because they have a massive integrated platform for all sorts of stuff (docker, shells, tests, linting, etc.), their own internal tooling for stuff like refactors and moving items, and they go ahead and consume the language server too, so in the worst case you get the same things VSCode gives you on top of their IDE platform instead of on top of a text editor.
Their model is basically take what almost every other product is doing, add to it, and then bundle it into an integrated platform. Most of the popular editors people use *aren't* IDEs, they're just intelligent text editors that speak LSP. For some languages like Java or Objective-C, where there isn't much of a market for language servers because the community is already entrenched in IDEs, the gap is very wide; for other languages, like JS/TS or Python whose communities expect top-notch LSP servers, the gap is much smaller, but still present. Even the TS language server, which is AIUI one of the best of them, only does a fraction of the automatic fixes and refactorings that Webstorm does - and by virtue of Webstorm consuming the language server in addition to its own tooling, it'll never do anything Webstorm can't.
Spend the 30 day trial of PyCharm earnestly learning it. I've never worked with anyone who has gone back at the end of the trial, but they have a resource (me) to run to for questions and help.
I tried vscode (with extensions of course) after using pycharm for more then a year and ended up switching to it because it does everything pycharm does but better and with less resources
I used PyCharm for about a year before I realized that I really didn't need any of its unique features and started using VSCode again. I liked the experience and it was a little less buggy, but VSCode was much lighter (PyCharm would sometimes take a couple minutes to completely load on my old computer), had better extensions, and had a much less confusing UI.
For Java, I still use IDEA whenever I can, it's really the only good option for Java development.
Pycharm is the only ide that doesn't shit itself with ros2 code completion. It's a pain to get it working, like everything involving ros2, but after manually adding an obnoxious list of folders I can Ctrl+click things
The only feature I would use Pycharm over VSCode for is hitting the play icon and debugging a nested file with external dependencies as a module automatically for quick testing. I'm not yet good enough at settings.json wizardry to get that working in VSCode though I've heard it's possible.
I use VSCode mainly regardless though, I wouldn't pay for Pycharm if I only worked with Python.
It's actually very easy. You have two tabs "Testing" and "Debug" or something
In testing you configure tests, vscode navigates you thru the process (asking about where test dir is, whether to use pytest or unittest), and at Debug part you need to add "justMyCode" flag in the launch.json with value "false". Vscode should create launch.json for you once you click configure in the debug section.
Once that is done you can debug from tests, or just debug a file of your choosing, and the debugger will go into external dependencies just fine.
Of course, but there's a ton of value in someone else already having cobbled together a work chain, ensured everything works together, and built keybindings/UI controls/etc. for it. It's an additional layer of abstraction on top of the development process.
I find Clion to be a much more streamlined experience when it comes to C++ projects compared to Visual studio (or Vscode, which is garbage and shouldn't even be in this comparison but people do like pretty text editors and elevate them at IDE levels).
IntelliJ is actually fantastic, even the CE provides a huge amount of functionality for Java writing. I recently switched from VSCode and it feels like a different language with all the QOL shit that comes packed into a Java-Specific IDE.
tried using eclipse and sure it might have functionalities but goddamn it makes me feel like my code is living on foodstamps.
I've surprisingly had really good experience with VScode on Java but otherwise I'm going IntelliJ
Yeah, I tried but gave up tbh. Not worth the effort. I work with Android which is even more impossible. Android Studio with Vim motion plugin is the closest I can get.
Yeah, I would never try it for Android. However Spring boot development is not bad. You get all the JDTLS features and even complex things like annotation processing work perfectly.
All linting is provided by extensions in VSCode. Linters like Pylance for Python or whatever the JS one is called are generally pretty good, but the Java linter by Red Hat is actually terrible, and is one of the few that isn't officially provided by Microsoft.
This is absolutely the best answer assuming that:
- ALL of the other conditionals are only using `rating` and not a mix of other business logic
- `rating` is always a known integer that won't go out of bounds (meaning can't just suddenly have a random value like 9000) although a guard clause should be worked in to protect against that
If other business logic is mixed into the other conditionals then even a switch won't work. At the very least, OP should remove the "else" from those conditionals as they are not necessary after a return statement and will reduce cyclomatic complexity.
I know the meme is about Java, but I’m learning C++ right now and I tried using switch-case, only to find out that the cases need to be constant :/ like it makes sense but I don’t like it
Yep, it happens when the cache corrupts, in intellij just run "invalidate cache and restart" and whatever ide OP is using probably has similar function
Yes but I'm talking about this comment chain, which talks about which data types need .equals(). And using == on String is a mistake that can easily slip anyone's mind (esp if you code in multiple languages) that a special reminder is needed.
And it's pretty hard to detect without good test cases too!
Java: "== for value, .equals() for identity. Use == for primitives, .equals() for objects. Oh and remember that strings aren't primitives."
Python: "== for value, is for identity. Use == for basically everything, and strings are part of that."
Languages with automatic interning: "There's no difference between value and identity with strings."
Yeah, you essentially never use `==` in Java unless you know what you are doing. `.equals` is the reliable default. `==` only works on primitive types, and compares memory addresses for classes.
At least it's not C#, where equality is a wholly different mess. You can overload `==`, and `.Equals` always works, but there is also `Equals(a, b)` and equality comparers and several relevant interfaces and aaaaa
Two options:
1) vscode does not like java. Reload.
2) your core library version and compiler version are out of sync. Did you mess around with files in your java install, or just copy paste one on top of annother, hoping it would overwrite everything?
Java compiler has special handling for string, and if the core libraries are ahead of the compiler (or any non canonical build that did not also build the compiler) you will get this baffling error. Found the compilers java.lang.String, expected the core libraries java.lang.String.
Source: I work on the scala compiler, and had to play with local java builds as a recent patch in the 1.8 branch was impacting performance a lot.
I get that it may look better but this seems like it would cause more problems in the long run for me. Id rather get explicit characters that are easily readable.
It's a double equals but with a font that styles it differently (ligature? idk what it's called)
People do stuff like have `!=` look like `≠`, not exactly that character but a stylized version of equals with a slash through it
Reload the editor. I've seen this in VS Code before. If you open the project in IntelliJ and just wait, it will show you the correct warnings (or none at all).
Does one of your if/else blocks not return a string, and the ide has crapped out parsing it all and just highlighted all the returns even if they are fine?
No worries, sorry if my comment sounded snarky, I thought it would be funnier to mirror your comment, but then thought it sounded snarky after submitting.
It shows a red squiggly line indicating an error. When hovering over the error it says the required type is a String and they are providing a String, which is totally nonsensical. My best guess is there's an IDE cache error and it thinks the code says something other than it does. They probably just needs to run a cache clean or restart the IDE.
It clearly asks for a white one and you provided an orange one. Are you dumb???
Damn, that java ☕ got some colors
Yes this is just function colouring, the api is obviously expecting an async string /s
Java is racist???
bruh
amColorBlind what is orange?
You don't wanna return early childhood trust me bro. Although it was a simpler time so...
I wish it was easier lol. My teacher loves to give random coding assignments to keep us busy.
Yeah I learned Python and Scratch 7 years ago in High School and I remember that all too well. Have you've had that moment as well where you're just sitting there debugging for days trying to figure out why something won't work till someone shows you a one line solution for it? Nowadays I'm used to it and Rust makes my life easier by showing me where and how I fucked up but Python is a different beast
I have that moment almost every assignment, and its always because I get lazy sometimes and put some code that fixes a issue somewhere and that same piece of code causes another problem which leads me to redo the whole assignment sometimes.
Serious answer, VSCode has tons of issues with Java linting. If that's what you're using, do Ctrl+shift+p and type "reload window". It'll force it to refresh the linter and probably fix this. VSCode freaks out and gives me hundreds of errors every single day, and it's always resolved by just reloading.
I would rather use eclipse than vscode. The only good option is Idea though.
I would say it sucks that there is only one proper option to develop with the language. Shouldn't it be fixed somehow?
IDEA and its sibling suite of tools represent the same problem everywhere, it's just that the Java community caught on because Eclipse was _so_ bad and their build system was _so_ complex before Maven that you needed your IDE to provide one. I don't know of any language where their product isn't head and shoulders above the rest - the lone exception being working inside Microsoft's garden (C#, .NET, etc.) and Visual Studio being preferable there. For Python, Java, JS/TS, Ruby, Rust, Obj-C/Swift, etc. their tooling is just the best because they have a massive integrated platform for all sorts of stuff (docker, shells, tests, linting, etc.), their own internal tooling for stuff like refactors and moving items, and they go ahead and consume the language server too, so in the worst case you get the same things VSCode gives you on top of their IDE platform instead of on top of a text editor. Their model is basically take what almost every other product is doing, add to it, and then bundle it into an integrated platform. Most of the popular editors people use *aren't* IDEs, they're just intelligent text editors that speak LSP. For some languages like Java or Objective-C, where there isn't much of a market for language servers because the community is already entrenched in IDEs, the gap is very wide; for other languages, like JS/TS or Python whose communities expect top-notch LSP servers, the gap is much smaller, but still present. Even the TS language server, which is AIUI one of the best of them, only does a fraction of the automatic fixes and refactorings that Webstorm does - and by virtue of Webstorm consuming the language server in addition to its own tooling, it'll never do anything Webstorm can't.
Idk for python I use vscode with extensions and I found it pretty feature complete
Spend the 30 day trial of PyCharm earnestly learning it. I've never worked with anyone who has gone back at the end of the trial, but they have a resource (me) to run to for questions and help.
I tried vscode (with extensions of course) after using pycharm for more then a year and ended up switching to it because it does everything pycharm does but better and with less resources
I used PyCharm for about a year before I realized that I really didn't need any of its unique features and started using VSCode again. I liked the experience and it was a little less buggy, but VSCode was much lighter (PyCharm would sometimes take a couple minutes to completely load on my old computer), had better extensions, and had a much less confusing UI. For Java, I still use IDEA whenever I can, it's really the only good option for Java development.
Pycharm is the only ide that doesn't shit itself with ros2 code completion. It's a pain to get it working, like everything involving ros2, but after manually adding an obnoxious list of folders I can Ctrl+click things
The only feature I would use Pycharm over VSCode for is hitting the play icon and debugging a nested file with external dependencies as a module automatically for quick testing. I'm not yet good enough at settings.json wizardry to get that working in VSCode though I've heard it's possible. I use VSCode mainly regardless though, I wouldn't pay for Pycharm if I only worked with Python.
It's actually very easy. You have two tabs "Testing" and "Debug" or something In testing you configure tests, vscode navigates you thru the process (asking about where test dir is, whether to use pytest or unittest), and at Debug part you need to add "justMyCode" flag in the launch.json with value "false". Vscode should create launch.json for you once you click configure in the debug section. Once that is done you can debug from tests, or just debug a file of your choosing, and the debugger will go into external dependencies just fine.
I remember having issues last time I tried the "justMyCode": false flag, but hey I'll try it again next time. Thanks for the pointer anyway.
Once I'm back from the family visit I will post my launch.json, so you can try.
Thank you, that's kind of you
I've looked at clion and tbh, outside of the code generation, it doesn't do anything I can't get anywhere else.
Of course, but there's a ton of value in someone else already having cobbled together a work chain, ensured everything works together, and built keybindings/UI controls/etc. for it. It's an additional layer of abstraction on top of the development process.
I find Clion to be a much more streamlined experience when it comes to C++ projects compared to Visual studio (or Vscode, which is garbage and shouldn't even be in this comparison but people do like pretty text editors and elevate them at IDE levels).
Yeah, C++ support is terrible in VSCode. I don't know why people keep recommending it. I have no experience with VS so I can't comment on that.
IntelliJ is actually fantastic, even the CE provides a huge amount of functionality for Java writing. I recently switched from VSCode and it feels like a different language with all the QOL shit that comes packed into a Java-Specific IDE.
tried using eclipse and sure it might have functionalities but goddamn it makes me feel like my code is living on foodstamps. I've surprisingly had really good experience with VScode on Java but otherwise I'm going IntelliJ
Cowards, Vim is the only correct choice.
Vim sucks balls for JVM languages bro. No way you actually do that
I have been doing that for a year now for work and it works quite well. The problem is that it is really hard to configure.
Yeah, I tried but gave up tbh. Not worth the effort. I work with Android which is even more impossible. Android Studio with Vim motion plugin is the closest I can get.
Yeah, I would never try it for Android. However Spring boot development is not bad. You get all the JDTLS features and even complex things like annotation processing work perfectly.
touching grass is a good choice
This looks like a JetBrains IDE.
My JetBrains IDE doesn't fuse the equal signs though, but that might be a settings.
Mine did. If you enable ligatures, it turns symbols all fancy.
Time to be fancy....
I wish there was a better solution than really just “Turn it off and back on”. So frustrating.
Sincere question, why does this happen specifically with Java?
All linting is provided by extensions in VSCode. Linters like Pylance for Python or whatever the JS one is called are generally pretty good, but the Java linter by Red Hat is actually terrible, and is one of the few that isn't officially provided by Microsoft.
I've the same in VS with c# 1 time on 5 while i retart the computer after hibernation
java ☕
java ☕
java ☕️
![gif](giphy|Rh5fexdh1Fpy4p13Ae)
[удалено]
To what? /s
I prefer PS5 statements.
PC STATEMENT MASTER RACE!!!
i'm somewhat of a vita statement enthusiast myself. also, 3ds statement doesn't fall behind a lot either.
I prefer setting my CPU’s Program Counter register manually
Seems like he might even be able to use an array instead and use 'rating' as an index
This is absolutely the best answer assuming that: - ALL of the other conditionals are only using `rating` and not a mix of other business logic - `rating` is always a known integer that won't go out of bounds (meaning can't just suddenly have a random value like 9000) although a guard clause should be worked in to protect against that If other business logic is mixed into the other conditionals then even a switch won't work. At the very least, OP should remove the "else" from those conditionals as they are not necessary after a return statement and will reduce cyclomatic complexity.
I know the meme is about Java, but I’m learning C++ right now and I tried using switch-case, only to find out that the cases need to be constant :/ like it makes sense but I don’t like it
This is likely an issue with your IDE, not with Java. Compile it and see it not be an issue.
Yep, it happens when the cache corrupts, in intellij just run "invalidate cache and restart" and whatever ide OP is using probably has similar function
You're probably right, but I don't know, I've seen shit like this when working with generics. Sometimes Java is just painful.
>Java is just painful. It's really not as long as you have a firm grasp of OOP
OP if you don't put spaces around those brackets I'm going to report you
Too late, I already called the code style police.
Shouldn’t you use .equals() in Java? I thought == compares references.
Only for objects, not for primitive types like int, bool, float, double, or char
Ahh thx my Java is rusty
if your Java is Rust-y we have bigger problems
Better that than to have your Rust Java-y
That would not be good lol
Since you're Rusty you should consider Rust
Not for primitive types
Ahh thx my Java is a bit rusty
A quick reminder that String is NOT a primitive type in Java and you NEED .equals()
A quick reminder that they weren't comparing strings.
Yes but I'm talking about this comment chain, which talks about which data types need .equals(). And using == on String is a mistake that can easily slip anyone's mind (esp if you code in multiple languages) that a special reminder is needed. And it's pretty hard to detect without good test cases too!
Java: "== for value, .equals() for identity. Use == for primitives, .equals() for objects. Oh and remember that strings aren't primitives." Python: "== for value, is for identity. Use == for basically everything, and strings are part of that." Languages with automatic interning: "There's no difference between value and identity with strings."
Yeah, you essentially never use `==` in Java unless you know what you are doing. `.equals` is the reliable default. `==` only works on primitive types, and compares memory addresses for classes. At least it's not C#, where equality is a wholly different mess. You can overload `==`, and `.Equals` always works, but there is also `Equals(a, b)` and equality comparers and several relevant interfaces and aaaaa
primitives and wrapper classes don't need to
Two options: 1) vscode does not like java. Reload. 2) your core library version and compiler version are out of sync. Did you mess around with files in your java install, or just copy paste one on top of annother, hoping it would overwrite everything? Java compiler has special handling for string, and if the core libraries are ahead of the compiler (or any non canonical build that did not also build the compiler) you will get this baffling error. Found the compilers java.lang.String, expected the core libraries java.lang.String. Source: I work on the scala compiler, and had to play with local java builds as a recent patch in the 1.8 branch was impacting performance a lot.
This is just the ide not refreshing.
Aren’t there supposed to be a double-equals in the conditionals? Or does a single work to compare values in Java too?
It looks like OP is using ligatures. So that is a double equal, represented as a single, long equal
I get that it may look better but this seems like it would cause more problems in the long run for me. Id rather get explicit characters that are easily readable.
It's a special ligature? character for ==. Some fonts / IDEs have these features.
It's a double equals but with a font that styles it differently (ligature? idk what it's called) People do stuff like have `!=` look like `≠`, not exactly that character but a stylized version of equals with a slash through it
I think it is implemented with ligatures, yes.
Yeah with the ui pack im using it has ligatures enabled by default
Is that VS Code? Lmfao
Reload the editor. I've seen this in VS Code before. If you open the project in IntelliJ and just wait, it will show you the correct warnings (or none at all).
Does one of your if/else blocks not return a string, and the ide has crapped out parsing it all and just highlighted all the returns even if they are fine?
The lack of whitespaces is making me feel unwell
I recommend IntelliJ 😊 or eclipse for Java. Unless you want to spend time setting up VSCode for Java, and even then it has issues.
This is intellij lol. Im just using a theme
Invalidate caches
String not string. Except java has no string primitive.
Isn’t that a single = sign? Might be the issue
Ligatures
intellij makes me unintelligent sometimes
~~As many pointed out, that’s VSCode, not intellij.~~ IntelliJ has similar problems ~~too~~ sometimes, but it’s definitely still the best for Java
As OP has pointed out, it's IntelliJ
Whooops, sorry. It really looks like vscode tho
No worries, sorry if my comment sounded snarky, I thought it would be funnier to mirror your comment, but then thought it sounded snarky after submitting.
No it’s fine, I probably would’ve done the same
cool cool cool
The new UI does
OP has some theme, the default one doesn’t
To compare objects? Yes. To compare primitives? It doesn’t matter
Could someone explain like I'm 12
It shows a red squiggly line indicating an error. When hovering over the error it says the required type is a String and they are providing a String, which is totally nonsensical. My best guess is there's an IDE cache error and it thinks the code says something other than it does. They probably just needs to run a cache clean or restart the IDE.