News for hackers. Stuff that matters.
Re:Don't make me think, or why I switched to Rails from Java... by coffeefirst on Friday February 04, 2022 @10:00AM (#30207553)
Sure. And I think what makes Rails and Django shine is they have sound default answers.

I’ve yet to see anything in Node that feels like a stable 1:1 replacement. Next.js is excellent, but you still need to sort out a lot of pieces on your own.

Re:Don't make me think, or why I switched to Rails from Java... by pmontra on Friday February 04, 2022 @10:37AM (#30208118)
I'm working on two inherited Django web apps right now, for the same customer. I wish Django has a default project structure like Rails. It doesn't. The only common ground between the two apps is that they are written in Python, use the same ORM and templating engine. One is a spaghetti monster of a zillion of apps that depend on each other (so the separation in apps is useless) and the database is totally opaque to inspection. The other app luckily tucked nearly everything inside a single app so its saner to navigate and we can query the database with SQL tools.

The point is that Django lacks a sane default for project structure and it costs time/money to people using it.

Re:Don't make me think, or why I switched to Rails from Java... by leetrout on Friday February 04, 2022 @11:23AM (#30208837)
If anyone else is feeling this pain please consider using this template https://cookiecutter-django.readthedocs.io/en/latest/
Re:Don't make me think, or why I switched to Rails from Java... by biorach on Friday February 04, 2022 @10:52AM (#30208376)
That's not accurate. Djano encourages, but does not mandate, a particular structure. Incompetent developers will always find a way to subvert whatever sensible defaults are at hand, which is the case you are faced with.
Re:Don't make me think, or why I switched to Rails from Java... by bredren on Friday February 04, 2022 @12:09PM (#30209506)
I have not had as much of a problem with structuring django projects. I agree there could be better documentation recommending best practices.

There is a very good talk from Dan Palmer from Djangocon 2021 called "Scaling Django to 500 apps" that gives helpful advice for project layout in a django app that may only have a few or several apps:

https://2021.djangocon.us/talks/scaling-django-to-500-apps/

That said, if we're going to dig on Django, it lacks typing, core-based API patterns and any embrace of modern front end. There are positive signals though, releases are coming faster and there is some real talent on the tech board right now.

I do think django and python in general are in a defensive position to hold the future of backend webdev compared to node / deno. However, there's still plenty of opportunity to compete for developers.

Re:Don't make me think, or why I switched to Rails from Java... by codazoda on Friday February 04, 2022 @11:21AM (#30208811)
I've never used Next.js so I decided to take a look. The first step in their Getting Started guide illustrates this pretty well...

  npx create-next-app@latest
  # or
  yarn create next-app
I would choose npx while my friend would choose yarn but there isn't a default or even an indication of why you might like either choice. We kinda just assume everyone already has a preference for npx or yarn.

This is really a Node or JavaScript problem and not an Next.js problem. Not that I have any idea how you might solve it. This is also just a single example and we tend to have these decisions at a lot of steps along the way.

Re:Don't make me think, or why I switched to Rails from Java... by ratww on Friday February 04, 2022 @10:21AM (#30207868)
As others have pointed in this thread, there's NestJS, Sails.js and AdonisJS, which are closer to Rails than Express or Next.js. And there's Meteor too, like the sibling post mentioned.

But to be fair 99% of JS backends I see are using Express (or AWS Lambda). Considering there's lots of choices I wonder if the problem is the fact the community never focused on a single solution. I wonder if a Merb/Rails-style merge between some of them would help that.

Re:Don't make me think, or why I switched to Rails from Java... by freddiecoleman on Friday February 04, 2022 @11:56AM (#30209332)
Love using NestJS. It's true that most places are stuck using express for whatever reason so you have to be a bit ahead of the pack.
Re:Don't make me think, or why I switched to Rails from Java... by CallMeMarc on Friday February 04, 2022 @10:21AM (#30207857)
RedwoodJS may be something you want to check out.

https://redwoodjs.com/

Re:Don't make me think, or why I switched to Rails from Java... by sytse on Friday February 04, 2022 @10:39AM (#30208162)
Yes, RedwoodJS seems like Rails for JavaScript.

Recently I’ve also been impressed with Remix that was mentioned in the article. It seems to have solved the client server code duplication problem while still offering the benefits of both.

Re:Don't make me think, or why I switched to Rails from Java... by crftr on Friday February 04, 2022 @11:46AM (#30209187)
Without knowing if it's possible, I really want to see a RedwoodJS w/ Remix proof-of-concept.
Re:Don't make me think, or why I switched to Rails from Java... by sytse on Friday February 04, 2022 @02:05PM (#30211395)
That would be awesome.
Re:Don't make me think, or why I switched to Rails from Java... by vidar on Friday February 04, 2022 @10:30AM (#30208030)
Agreed, I think it is the explicit goal of the project to get that same batteries included feeling of Django/Rails
Re:Don't make me think, or why I switched to Rails from Java... by dragonwriter on Friday February 04, 2022 @11:20AM (#30208807)
> I’ve yet to see anything in Node that feels like a stable 1:1 replacement

I’m not sure why there should be; for people who are happy with “good enough” default choices for a web app, Rails exists and makes the choice “Ruby” when it comes to language.

Re:Don't make me think, or why I switched to Rails from Java... by taylorwc on Friday February 04, 2022 @11:47AM (#30209207)
Definitely some exciting stuff like Redwood and Wasp working to solve these problems. I always loved what Meteor tried to do for this, though the JS ecosystem sort of evolved in a different direction.
Re:Don't make me think, or why I switched to Rails from Java... by systemvoltage on Friday February 04, 2022 @12:01PM (#30209395)
Do most people use Django as a server-side framework (no frontend-JS or very minimal JS, may be jQuery)? Or, is it mostly used as an API to interact with the React/Angular/etc front-end framework? What I am trying to get at is do people still build POST-redirect-GET patterns and such for form submissions or they use Django in a more 'modern' way?
Re:Don't make me think, or why I switched to Rails from Java... by reducesuffering on Friday February 04, 2022 @05:16PM (#30214113)
From my recent foray into modern Django world, most simple projects and MVP start out as server side like the official guide. Then, when people need some extra frontend magic like React and/or SPA, it's pretty easy to insert into Django. You just include the bundled React/Vue app into a js script still included and served by the same Django route/view/template. Of course, it's also common to start transitioning to Django Rest Framework (DRF) as your API points.
Re:Don't make me think, or why I switched to Rails from Java... by kbaker on Friday February 04, 2022 @12:15PM (#30209589)
You can use either or both... server-side comes out of the box, and is used by the getting started tutorial. API-based is also very common using django-rest-framework.

I'd say it is still a mix of both and both paths are well-supported and well-maintained.

Re:Don't make me think, or why I switched to Rails from Java... by kabes on Friday February 04, 2022 @10:13AM (#30207727)
Meteor comes to mind