8 ms·
I touched Java in school and rarely since. Is it the kind of language where you can be production-level productive with just a text editor and CLI, or do you ne
by Waterluvian 4y ago
I touched Java in school and rarely since. Is it the kind of language where you can be production-level productive with just a text editor and CLI, or do you need an IDE to manage everything?
The last time I poked at it, there were just so many config and generated files and so much complexity that it felt like I must use an IDE that hides a layer of “magic”.
Or am I just confessing ignorance and this isn’t a thing and it’s no more complex and magical than Rust or JavaScript or Python?
Edit: thank you all for the helpful responses.
- RHSeeger 4y agoUsing an IDE for Java will, in general, make you orders of magnitude more productive. Not because of generated files or anything like that, but because it can recommend methods, auto-fill in details, add imports, etc. That kind of things saves a lot of time over the long run.
- Waterluvian 4y agoAh. I mean that’s somewhat true for any language. Is Java still super boilerplatey?
- papercrane 4y agoDepends on when you last touched Java. Lambda's (Java 8) have significantly reduced the ceremony needed to do things you'd use anonymous inner classes for. Java 14 introduced records, which makes building simple immutable data objects trivial. It's still a fairly verbose language, but it's miles from where it was 10 years ago.
- Waterluvian 4y agoMy textbook says Java 6. So I guess so! I’m kind of excited now to try it again.
- xahrepap 4y agoThe language has definitely evolved a lot from then. But so have the major frameworks. While not perfect, building a web app in spring boot is a whole world better than doing the same using Java-6 era frameworks.
- jjfoooo4 4y agoThe strong typing system in Java means the recommendations and general code assistance is much more accurate and powerful than that if scripting languages
- speed_spread 4y agoJava's libraries, coding conventions and culture made it verbose more than the core language itself ever required. Starting from scratch and eschewing "good practices" it was always possible to write much leaner code. Get rid of getters and setters, make every field public and final, use anonymous classes to implement interfaces inline, that sort of thing. Obviously wouldn't pass a code review at any "serious" shop ten years ago. But look at Java 20 now, with immutable records and closures and type inference? Well now that code style is now ok! But obviously my ten year old PR is still not approved...
- kaba0 4y agoJava is much much shorter than Go, which oddly enough never gets this “complement”. So, take these boilerplate claims for Java with a grain of salt. But to actually provide an answer, records shorten the language to a great degree in my opinion, there is also type inference with `var`, so on a local scope you can write really short code. The main method is still chatty, but it’s not like you actually have to write all that many times, plus it is just psvm for most IDE users.
- peterashford 4y agoYes! I work programming in Go. I like it a lot - its a very pragmatic language. But I couldn't believe that people who derided Java for verbosity were raving about Go. It's pretty good, but the boilerplate is extreme
- jayd16 4y agoThere's never magic in computing. Its always ignorance. ...Although I will admit that whether its feasible or useful to demystify the magic varies from case to case. As for Java, an IDE helps a lot for Java because the build landscape is quite tedious otherwise.
- simpsond 4y agoYou can use a text editor. I’d look at the hello world Java application to see how simple it can be. It’s the frameworks that are responsible for config files, generated code, etc. That said, it’s much easier to manage large applications with an IDE.
- dr_faustus 4y agoWell, you certainly can use it with just an text editor. However, due to the maturity of the language and platform, the IDE support of Java is pretty much unsurpassed and you would certainly be quite a bit more productive if you used an IDE like IDEA or Eclipse. In terms of complexity, it really depends on what you want to do. Using a powerful framework like Spring can entail some config (albeit much less than it used to). Also you would typically use a build tool like maven or gradle to manage dependencies, build artifacts, etc.. Especially maven can be a little arcane. But another major upside of the aforementioned maturity is that there are reams of docs and stackoverflow answers which will almost certainly contain solutions for any problems you might encounter.
- TedDoesntTalk 4y ago> reams of docs and stackoverflow answers which will almost certainly contain solutions This is both a blessing and a curse. Some answers and docs are decades old and although still work, are not “fashionable java” (think streams, for instance).
- code_runner 4y agoI’m new to Java so I just want to confirm… are you saying streams are or are not fashionable? Is there a better api out there?
- yCombLinks 4y agoNo, there are pre-streams answers, but streams are now fashionable.
- erik_seaberg 4y agoAnd streams are part of the reason checked exceptions are now unfashionable. Java doesn’t infer that a generic function arg should affect the caller’s exception signature.
- 4y ago
- frant-hartm 4y ago> Or am I just confessing ignorance and this isn’t a thing and it’s no more complex and magical than Rust or JavaScript or Python? This is it. There are things which are better in Java than in the other ecosystems you mentioned (e.g. dependency management) and there are things which are worse (the language is more chatty, maybe the designs tend to be more convoluted, but this differs project to project). Even enterprise Java has come a long way, it's different to what it has been a decade ago, it's definitely more lean. Every sane developer uses either Jetbrains' product for JS, Python or Rust, or they use VS Code, which, after installing all plugins to reach the same productivity as with Jetbrains, becomes an IDE as well.
- dysarray 4y ago> Every sane developer uses either Jetbrains' product for JS, Python or Rust, or they use VS Code, which, after installing all plugins to reach the same productivity as with Jetbrains, becomes an IDE as well. You seem to vastly overestimate the usage of IDEs with scripting languages. In my experience, the vast majority of developers working with scripting languages such as JavaScript, Python or Rust, still use plain text editors such as Vim or Sublime Text. They find these editors to be more convenient and faster than IDEs. Even people who are on VS Code seem to be using only the built-in language support for scripting.
- estebank 4y ago> scripting languages such as JavaScript, Python or Rust one of these, is not like the others :) > They find these editors to be more convenient and faster than IDEs. FWIW, survey responses from 2021 imply that 54% of Rust devs use VSCode, 28% use a vi variant and 21% use IntelliJ[1]. [1]: Page 19, https://raw.githubusercontent.com/rust-lang/surveys/main/surveys/2021-annual-survey/2021-annual-survey-summary.pdf https://raw.githubusercontent.com/rust-lang/surveys/main/sur...
- mat_epice 4y agoThey counted 103% of users and couldn’t find a single one using emacs!!! /s
- jfengel 4y agoJava doesn't require any config files, and the only generated files are .class files that are equivalent to .o files in C. There are all kinds of things that you can pile on top of it, usually for managing big projects. Those can seem arduous when you're at the Hello World level. If you got introduced to those it will seem daunting and unnecessary (and for many projects, it is). But basic Java is no more onerous than Python or JavaScript. About the only difference at that scale is that Java requires type notation, but no more so than C. And I wrote Java for over a decade with vi. IDEs make it better, but they are not necessary. (And good ones are free anyway.)
- narrator 4y agoYou will need to use an IDE to be productive in Java. One thing that Java does better than just about any other language though is it's maintainable. A codebase in Java can exist for decades and not become unmaintainable no matter what lowest bidder IT services contractor works on it. That's because the language makes it hard to write obfuscated spaghetti code and the static typing allows for deterministic refactoring of bad code. That's something you can't easily do in JavaScript.
- throwaway2037 4y agoThis is an interesting comment. When you say "maintainable", I would agree but for different reasons. It would say a single owner for most of the ecosystem (Sun->Oracle) makes it exceedingly stable. (Yes, I know IBM has a parallel universe, but little used compared to Oracle's.) Think about it: A single vendor provides the whole stack: compiler, debugger (including remote!), standard library (immense, well-documented), virtual machine, and IDE (NetBeans). There is also a small army of well-paid, highly skilled developers employed by Sun->Oracle constantly working to improve this ecosystem. Probably, the only thing they don't provide is a build system. They originally wrote Ant, but then let free in the wild. Also, no segmentation faults, full exception stack traces, and mature decompilation tools make it incredibly simple to debug -- even the hairiest legacy libraries. With the exception of Microsoft's C#/.NET, I cannot think of any mature equivalent. Note: Above, I never mentioned the open source community (Maven Central Repo, etc.). I won't touch that because the quality varies wildly. And, yes, I agree 100% about your reference to low cost developers. From an enterprise view, it is cheap and easy to find (low quality and) low cost developers to maintain legacy Java software. You also wrote: <<... static typing allows for deterministic refactoring of bad code. That's something you can't easily do in JavaScript.>> Most JavaScript devs would immediately reply: "Oh, use TypeScript for that." As I understand, you can incrementally upgrade a legacy JavaScript project to TypeScript, then slowly add types. Also, I have refactored lots of Java code that uses Object as a substitute for C's void*. That type of code is so difficult to understand without a debugger. Also, very difficult to refactor due to limited typing.
- kaba0 4y ago
- gavinray 4y agoJava after JDK 17 is a completely different language, almost like the difference between Javascript pre-ES6. It got: - Pattern matching - Sealed types - Records (immutable, succinct data-classes) - Multiline strings Among other things. It's almost as nice to use as Kotlin, and I say this as a huge Kotlin fan. Its pattern matching in most recent releases is actually more powerful than Kotlins, since it allows deconstruction-bindings in patterns.
- oangemangut 4y agoI feel like this is going to be to kotlin's disadvantage going forwards as languages features are slowly added into Java, they will be more 'complete'.
- Alupis 4y agoJava can never be Kotlin without breaking a lot of backwards compatibility. That is the "edge" a newer JVM language like Kotlin enjoys. Since Java's history is very focused on not breaking things (and folks got really grumpy on the few occasions something has been broken), Java cannot ever match the feature pace of languages like C# either. But the folks writing Java code (most of you here on HN by all metrics), mostly don't care. They enjoy backwards compatibility and stability far more than new features. The overwhelming majority of newly written Java code is targeting Java8 still - which doesn't use any of these new features anyway. Backwards compatibility is also why things like lambda's and streams are the way they are in Java (and most FP folks would sneer at), and things like Records took years to release (still technically in the Preview stage). The advantage Kotlin has, and the reason it's growing in popularity in backend development is you get all the FP tasty features you want right now, but maintain near drop-in compatibility with existing Java libraries and frameworks. This was the most brilliant move by the Kotlin designers in my opinion...
- zaphirplane 4y agoAdding features doesn’t mean breaking backwards compatibility, I can only think of modules since Java 8 that can maybe be. What Kotlin features are possible because of that freedom ? Genetics can be an example I can’t say it’s impossible for Java to add in out refied keywords
- ramranch 4y agoAs a Rust fan, it is not a great experience without an IDE
- speed_spread 4y agoStatically typed languages gain a lot by having an editor that understands the code at hand.
- foolfoolz 4y agousing a text editor instead of an IDE is actively sabotaging your own productivity in any language
- throwaway2037 4y agoWhat languages do you normally use? And what editor/IDE? It might help to have points of reference for comparison.
- kelnos 4y agoI do know people who write Java in vim, with some plugins installed to give them IDE-like features. I've tried it, but, frankly, it's just so much easier to use something like IntelliJ IDEA, that it feels silly not to. The non-IDE ways of doing things are still pretty unpolished and missing features, while the IDEs are incredibly polished at this point. I think the whole config/generated files thing is for old-school J2EE "enterprise Java". Most of the frameworks I've used have just involved writing code. Sure, sometimes you need a config file, but that's pretty normal -- most of the time I'd rather specify things like port numbers and logging configuration in a separate config file, rather than hard-code them in the app themselves. If you stay away from the old-school Java Servlet frameworks -- or use a framework that builds on top of servlets and hides the complexity -- then you don't have to deal with that crap. The build ecosystem is a bit more fragmented than Rust (maven or gradle or sbt or...), and the build tools do require a bit more boilerplate to configure, for the most part (especially maven), but it's not too bad. JavaScript, IMO, has some of the most inscrutable build systems I've ever seen, so I don't think that's comparable to Rust, or even Java. Maybe the complexity of Java build systems is similar to Python, though in different ways. The recent releases of Java have added a lot of quality-of-life improvements to the language, so it's a lot more pleasant (and less verbose) to write Java than it used to be. I still prefer something like Scala (2; haven't tried 3 yet), but it's a lot easier to build a team around Java than Scala.
- therealeskaton 4y agoOf course you can use Java with an editor like Vim or Emacs for simple projects but I would advise to use an IDE like IntelliJ IDEA for bigger projects, e.g. for its support for refactoring. As a statically typed language the benefit of an IDE will be much better than for Python or JavaScript. The same is true for Rust. An IDE helped me to get much more productive because it can show the inferred types without invoking the compiler all the times.
- exabrial 4y agoSpeaking language agnostically… If you’re developing prod projects without an IDE, you are likely not being as productive as you could be. Can you frame a house without a framing nailer? Sure. But why? You’ll spend 30x the time and the quality won’t be as good. I worked take a second look at IntelliJ and Eclipse; learn the keyboard shortcuts. Modern Java is incredibly well put together.
- tonto 4y agoJust a random note but LSP (language server protocol) support in e.g. vim/neovim allows IDE-like features in a "plain old text editor"
- jasmer 4y agoJava compilation and packaging is actually probably the most clear, well documented of all languages. Most of the tooling is provided, and it's coherent and robust. Ultimately - both Maven and Groovy, which are used for production level build and packaging, are a 'weird'. But getting going with them is relatively easy. Java has introduced the concept of 'Modules' - which if you don't get straight in your head, can be confusing, but ultimately it's not that bad. Compilation is relatively fast as well. The 'IDE' tends to 'hide a lot of things' in ugly ways - that is true. All of the JAVA IDEs are weird about that. However - because Java is a well maintained language, the IDE's can be powerful and are actually worthwhile. Jetbrains being one of them. Sadly, Java on VSCode is a bit of a mess. On Android, Google has introduced a bunch of odd conventions and complexities which I feel are unnecessary.
- yedava 4y agoOnce a code base gets big enough to be larger than a handfuls of files, a text editor just won't be able to keep up with the refactoring/reorganizing capabilities of a statically typed language managed by an IDE. This feature of Java alone makes it well worth it (over say JavaScript or Python), despite whatever other issues the language has.
- plandis 4y ago> Or am I just confessing ignorance and this isn’t a thing and it’s no more complex and magical than Rust or JavaScript or Python? If anything I’d say JS has a more complex configuration story than Java.
- kitd 4y agoThere's a project called JBang that aims to provide a much simpler DX when working with Java projects. For basic projects, the experience is almost Go-like. https://www.jbang.dev/ https://www.jbang.dev/
- sonicgear1 4y agoJava is just a painful language. At that level of abstraction you would expect to work purely on business logic, yet Java makes you just focus on the boilerplate and lacks completely basic features such as tuples, real generics, async/await, anonymous types and more. Spring is another huge pain point, it's slow and verbose in comparison to Go or even .NET. Java is not even close to Kotlin, that's why it was invented in the first place, to not make you want to shoot yourself in the head. Needless to say, I don't see any real use of Java in 2022 and beyond.
- BenoitP 4y ago> lacks [...] async/await I'll take that a a major plus. Sometimes things are improved by what is taken away. > I don't see any real use of Java in 2022 and beyond. Well, you see what you see; and the cloud infrastructures sees what it sees.
- kaba0 4y agoSo decide, if you want to work on business logic, why do you want to further dig your grave with async/await, which is by definition an implementation detail? Also, sprint is not slow at all, especially that servers are very famously IO-heavy. Nonetheless, you can expect better performance for these with project loom.