3 ms·
Eh, lol? Setting up new applications in Java or .NET is by far easier than Node.JS. It's Node.JS where you need 400 dependencies just to use the latest versio
by kuschku 10y ago
Eh, lol?
Setting up new applications in Java or .NET is by far easier than Node.JS.
It's Node.JS where you need 400 dependencies just to use the latest version of the language.
That said, there's many easy to use and simple frameworks for Java, and you can try also other JVM languages such as Kotlin, Clojure, Scala or Eta.
The JVM hosts the most powerful and fastest managed languages at the moment (via eta and clojure also allowing haskell and lisp on the JVM).
.NET is nice, but there's quite a few reasons why Java is used everywhere.
- dagw 10y agoSetting up new applications in Java or .NET is by far easier than Node.JS I'm far from a node fan, but that is simply not true. When it comes to going from zero to a "Hello World" webapp (super simple rest api that grabs data from db and returns as JSON) nothing really beats node in my opinion. Install npm, npm install express (or restify), npm install database-driver (and there are drivers for everything), type a dozen lines of code into a single file and you're done. Sure npm is probably doing some crazy things with dependencies in the background, but you don't have to worry about it to just get started. Doing the same with Java or C# is much more involved. Of course going from there to a large complete application is far from equally trivial and I definitely prefer working in something else in most cases, but node has the whole getting started experience down pat and that's probably the reason it's become so popular.
- kuschku 10y agoMuch more involved? With Java and co it’s literally the same. You add two dependencies to your gradle, write a dozen lines of code, and you’re done. Even if you go full enterprise it’s not much more. Let’s go full Java Enterprise: // Enterprisify everything! compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '1.5.0.RELEASE' compile group: 'org.springframework.data', name: 'spring-data-jpa', version: '1.11.0.RELEASE' compile group: 'org.springframework.data', name: 'spring-data-commons', version: '1.13.0.RELEASE' // persistence framework compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final' // database driver compile group: 'org.postgresql', name: 'postgresql', version: '9.4.1212' // to auto-generate getters, setters etc. compileOnly "org.projectlombok:lombok:1.16.16" Now we’ve imported spring, our database driver and an ORM. Let’s write the code. First, let’s config: // application config spring.application.name=ourapp server.port=8090 // database config spring.datasource.url=<our database url> spring.datasource.username=<username> spring.datasource.password=<password> spring.datasource.driver-class-name=org.postgresql.Driver Then add the database layer, defining our model: @Entity @Table // To auto-generate mapping for the ORM @Getter @Setter // To auto-generate getters and setters public class Book { @Id private long id; @Column private String name; @Column private String description; } And our access layer: public interface BookRepository extends CrudRepository<Book, Long> { Optional<Book> findById(long id); } And our application: @RestController @SpringBootApplication @EnableJpaRepositories public class OurApplication { @Autowired private BookRepository books; @RequestMapping(path = "/{id}") public Optional<Book> getBookById(@PathVariable long id) { return books.findById(id); } public static void main(String[] args) { SpringApplication.run(OurApplication.class, args); } } So. This is if you go full insanely Java Enterprise, want full Spring, and everything. If you choose sanely, it’s obviously far less code. Notice how I don’t have to use any transpilers, etc, and still get typing and the latest language features.
- deleted 10y ago[deleted]
- kuschku 10y agoYou can downvote this, sure, it’s now so far down that most users can’t see it anymore. But that doesn’t change the facts. Good luck getting modern JavaScript or TypeScript, without using any templates, in equal or less LOC, and easier to understand for a newbie, than my Java Spring Enterprise example below. JavaScript is easy if you want to do tiny things, but as soon as it gets to larger projects, it has the same issues as PHP and other similar languages. Every language has some things it can do better, and some it does worse. Until JavaScript development slows down, and the compilation pipelines standardize, and there’s simpler ways to handle that, setting up a node.JS project will always be more work than a language where that has already happened.
- tracker1 10y agoI've done some relatively large projects in Node... though I tend to break things down into discrete components either based on deployable assets, or reusable assets. Node pipelines are pretty nice, not quite as nice as go's channels, but nice none the less. There are different options depending on libraries. I don't find it to be significantly more cumbersome than C#/.Net (which I have more experience than with Java). Also, your "example" has a LOT of assumed knowledge, more than a relatively simple express app, that's for certain. It really depends on the approach.
- kuschku 10y agoWell, I don’t think so. I had never worked with Spring or Java Enterprise, and could write the example after 1 hour of reading docs. After years of working with vanilla JS, and weeks of reading docs, I still can’t get a typescript compilation and CSS/SCSS compilation and minification pipeline right. Seriously, I still can’t get it working.
- tracker1 10y agoI've had better luck with flow over typescript, though frankly, I don't use either... I used flow instead of typescript for an angular 2 project a while ago. Not sure if the webpack story for typescript has improved. I've managed to get webpack + babel + sass working pretty readily, in about the same time you mention above.