News for hackers. Stuff that matters.
Re:Django Newbie Mistakes by jaffee on Thursday June 28, 2018 @10:19AM (#17417035)
I feel like I just got into a time machine - this is the top post on hacker news? People are learning Django in 2018?

I guess its fine if you have a small project and aren't going to see much traffic, but Python is so slow and difficult to maintian compared to (e.g.) Go. I say this as someone who worked in Python for a long time, and on several large Django projects.

Re:Django Newbie Mistakes by mbrameld on Thursday June 28, 2018 @10:25AM (#17417104)
How large are we talking? Do you consider Instagram large? If so, you should let them know they should stop using Python and Django.
Re:Django Newbie Mistakes by jaffee on Thursday June 28, 2018 @02:07PM (#17419151)
I'm sure they could save a massive amount of money and improve their latencies if they did.
Re:Django Newbie Mistakes by vivan on Thursday June 28, 2018 @10:24AM (#17417087)
I agree in principle that python for web can be slow, but plenty of sites have been able to scale with it (e.g. Reddit, Pinterest, Quora). So I think saying that python is only for projects that aren't going to see much traffic is a very broad and unfair generalisation.
Re:Django Newbie Mistakes by jaffee on Thursday June 28, 2018 @01:53PM (#17419045)
scalability and speed are two very different beasts. You can build scalable things in Go, or Python, or most any language.

At a certain scale though, the amount you'd save in infrastructure bills by using Go instead of Python is absolutely stupid. A 10x difference would not be surprising in the slightest.

Re:Django Newbie Mistakes by eksemplar on Thursday June 28, 2018 @02:40PM (#17419382)
It’s 2018 and people still work on COBOL, but unlike that, Django is actually really great.

Where I’m from the most popular techs are .net (not core), Java, PHP and Django. Django is perfectly viable in that regard.

Go may be better, but if you can run Instagram on Django, I don’t think most people will really have to worry about scalability. Go might become popular eventually, but right now, there isn’t a single golang job in my country, so you know. :)

Re:Django Newbie Mistakes by projectramo on Thursday June 28, 2018 @10:35AM (#17417172)
Oh man! I feel where you are coming from but who clicked on this link except Django fans?

That's like walking into a Django club and telling everyone their framework sucks. Even as a member that only gets you so far.

I can't believe you also called it difficult to maintain! Because when you say slow, the response its easy to maintain, and you went ahead and called it difficult to maintain?

At least give us a reason.

Re:Django Newbie Mistakes by jaffee on Thursday June 28, 2018 @01:59PM (#17419091)
Ha, ok - Django is not difficult to maintain, Django is a very powerful, carefully built framework with tons of features that can get you up and running with a production ready website very quickly.

Python is difficult to maintain. Full stop. Why? Anything in Python can do anything to anything else - there are no boundaries which makes it basically impossible to reason about code at scale. You need very strictly enforced code quality standards across your entire codebase and libraries in order to be able to trust anything - otherwise you don't know if some method on a class has been swapped out right underneath your feet, or if some field access is actually calling a function which is accessing a database.

Go is super easy to reason about compared to Python - as long as no one is importing unsafe or reflect (easy to check), you have very solid guarantees as to what can happen at any point.

Re:Django Newbie Mistakes by mixmastamyk on Thursday June 28, 2018 @07:07PM (#17421201)
Needs change over the lifetime of a project. The flexibility that is a virtue at first becomes less so as designs solidify. Theoretical issues become problems as a codebase/team scales.
Re:Django Newbie Mistakes by cosarara on Thursday June 28, 2018 @10:21AM (#17417062)
Does go have a web framework that does as much for you as django?
Re:Django Newbie Mistakes by djstein on Thursday June 28, 2018 @10:29AM (#17417135)
I know this was rhetorical, but no, it doesn't
Re:Django Newbie Mistakes by pbreit on Thursday June 28, 2018 @01:35PM (#17418898)
I'd like to see one that does 1/4 to 1/2 as much but otherwise stays out of my way.
Re:Django Newbie Mistakes by beal on Thursday June 28, 2018 @10:31AM (#17417153)
It is current year and Django is still very relevant in web development.
Re:Django Newbie Mistakes by pwf on Thursday June 28, 2018 @02:59PM (#17419533)
The stuff we used Go for was the right choice for Go for sure, but I don't think the API would have been any easier in Go (though I haven't used those frameworks before...).

We also could have done Django a lot better. And all of the Celery stuff probably should have been Go, especially with the Cassandra driver we were using. Still, I'm using Django today and as long as you don't abuse the ORM and nested DRF serializers too much, it's very scalable. I think as long as you make separate services in other languages at the right time for the right use cases, it's a very valid choice for rapidly building an API.

Re:Django Newbie Mistakes by michaelcampbell on Thursday June 28, 2018 @10:25AM (#17417099)
> People are learning Django in 2018?

I am. So, yes.

Re:Django Newbie Mistakes by brett40324 on Friday June 29, 2018 @09:41PM (#17429053)
I surmise I'll still be learning it in 2028!
Re:Django Newbie Mistakes by dba7dba on Thursday June 28, 2018 @01:43PM (#17418959)
I am too.
Re:Django Newbie Mistakes by danielecook on Thursday June 28, 2018 @10:24AM (#17417094)
What makes Go projects easier to maintain?
Re:Django Newbie Mistakes by terminalcommand on Thursday June 28, 2018 @11:16AM (#17417549)
I would argue that it's simplicity. I believe I've read somewhere that Golang was designed with junior engineers in mind. They wanted to create a language that young engineers could learn easily yet cannot make a lot of mess due to its simplicity.

They baked all features necessary right into the language. You get a http server, ssl support, templating engine etc. right in the language. You also have a database agnostic database driver right in the language. Python is also similar in many ways, it comes with "batteries included". But in my experience go standard library is written in a crystal clear straight-forward way. My workflow (and I believe the workflows of many programs) always involves jumping to the source of go standard library and just reading the code.

Django on the other hand has layers and layers of magic, you've got an ORM, modules etc. etc. Some people might like to let a framework handle everything, learn it inside and out and use it. But for other people like me, with a short attention span, django seems subjectively boring. Maybe if I didn't program as a hobby and it was my job to learn django I might have taken the time and learn it.

I started the django tutorial twice in the last 2-3 years. Both the times, I got bored and left. My subjective opinion was that it didn't teach me anything besides how to "generate" a site with Django. OTOH I had much more luck with Flask. Immediately after following the tutorial I was able to write websites and deploy them.

I think it's a matter of taste. I don't like big frameworks, I like to keep things very simple and minimal. My favorite OS of choice is OpenBSD, my favorite languages are C, Golang and Python. I don't like to use IDEs, I use Emacs, even Emacs feels a bit bloated sometimes.

From time to time I get the urge to try one of the big frameworks like Rails and Django, but I never quite got them.

Re:Django Newbie Mistakes by Karunamon on Thursday June 28, 2018 @12:26PM (#17418275)
I ran into this problem hard while learning Rails, and a full 99.9% of tutorials out there have you using generators rather than learning how it works. As a result, I didn't learn Rails for ages, writing it off as magic beyond my ken since none of them were teaching me what I thought I needed to know.

The tipping point for me was actually progressing through these tutorials a few times.

In Ralis land, creating a new page results in no less than 3 files being touched. A new view and controller, and a modification to routes.rb so the page can be hit. If those pages need to interact with the database, you also need to create a model and likely a database migration to write your new tables. Once you get comfortable with the ecosystem, you stop seeing the generators as newbie crutches and start seeing them as serious time savers. It's like you're learning a Rake-based metalanguage that spits out Ruby and ERB code.

It's much less time consuming to just delete any extra boilerplate than to make all those changes by hand.

That said, if you dig simplicity, then things like Django and Rails (especially Rails) will be huge turnoffs. The magic is their selling point :)

Re:Django Newbie Mistakes by terminalcommand on Thursday June 28, 2018 @04:16PM (#17420115)
That is exactly what I felt. Even while using Flask I was put off by having to rely on magical decorators @app.route() etc. While I was experimenting with ruby I had really enjoyed toying around with the cgi module.

Nowadays I want to dig a little deeper into uwsgi with Python.

Maybe at the end of my journey, I will reach enlightenment and get to the point where I start seeing the generators as serious time savers. For now I feel like, if I want a generator, I'll build one :).

Re:Django Newbie Mistakes by sbov on Thursday June 28, 2018 @01:15PM (#17418737)
> They baked all features necessary right into the language.

Not really. What about sessions? Auth? CSRF protection?

Re:Django Newbie Mistakes by terminalcommand on Thursday June 28, 2018 @04:07PM (#17420044)
That's true Golang does not come with automatic session management, authentication, csrf etc.

But if you look at it, csrf is just a hidden form value involving a token injected into the page. It is not hard to implement. In that sense Flask doesn't have csrf proection either.

Session management on the other hand could be troubling, but in the end they all rely on cookies: if I take a look at https://golang.org/src/net/http/cookie.go , I can easily make sense of it. But I can imagine the need for a higher level library for session management.

There is something called gorilla toolkit which has session management, but you're right it isn't included in the standard library. Golang's own template engine is also very primitive.

Re:Django Newbie Mistakes by michaelcampbell on Thursday June 28, 2018 @02:38PM (#17419360)
> I believe I've read somewhere that Golang was designed with junior engineers in mind.

Interesting, when one of the complaints about Java is exactly this.

Re:Django Newbie Mistakes by terminalcommand on Thursday June 28, 2018 @04:22PM (#17420164)
I found the link again, apparently Rob Pike had said:

  The key point here is our programmers are Googlers, they’re not researchers. They’re typically, fairly young, fresh out of school, probably learned Java, maybe learned C or C++, probably learned Python. They’re not capable of understanding a brilliant language but we want to use them to build good software. So, the language that we give them has to be easy for them to understand and easy to adopt.  [1]
But I think we should also keep Rob Pike's experience and wits in mind. It was probably intended as a humble witty remark. If you consider how complex concurrency is, and how Golang has made it simple with a single keyword to spawn coroutines (go) and a straightforward data structure (channels), I think he is right to say that Golang is easy to understand and easy to adopt.

[1] http://nomad.uk.net/articles/why-gos-design-is-a-disservice-... citing the quote from http://channel9.msdn.com/Events/Lang-NEXT/Lang-NEXT-2014/Fro...