Hacker News new | ask | show | jobs
by channikhabra 4382 days ago
Where do Django stand in the js everywhere fortresses of MEAN and damn awesome stuff like meteor/derby? I mean it's possible to use django with client-side js, precompiling js templates server side and using Django as REST backend or use websockets layer on it and do stuff the modern apps should (arguably) be doing i.e refresh-less UX, fast native-like apps, but still these major server-side frameworks (django, ror and friends) are so much loved and used by vast majority of "pros".

Most likely I am living in a bubble that making apps same language both sides specially in frameworks like Meteor which revolutionises the workflow is the best way to go.

Please break my bubble and enlighten me why we should still be using these framweworks and not js only alternatives.

I don't mean to start a flame war (or may be I do), I just want my perspective changed. It is sitting pretty stubbornly in my head that meteor like start-to-end pipelined flows are the way to go (read all-sides javascript frameworks).

2 comments

If you find using the same language in the browser and the server to be a compelling advantage, js is your only option. But IME it's not actually that big an advantage; most logic code belongs to one layer or another. For domain objects (i.e. non-logic code) you can use something like protocol buffers and then you can use the same object definition in both languages.

Advantages to me would be much more mature ORM support (e.g. others are talking about how good the migrations are; there are some cool efforts in js e.g. Knex but they're still very primitive in comparison to what Django can now do automatically), better templating (certainly arguable, but I find none of the js approaches encourage proper separation of markup and logic), and a much more comfortable language for writing business logic in. Python has nowhere near as many "gotchas" as js, and is much more readable for a less-technical domain expert.

You can easily do this with Clojure/ClojureScript too. As I understand it, it's also possible with Haxe. Theoretically, you could do the same with Ruby or Scala too (not sure I've heard of other languages with reasonably complete implementations that can handle both compile to native code (or a fast interpreter) and compile to javascript).
A huge plus is being able to use Python. I'm not completely anti-javascript but given the choice - I'd rather use Python for the bulk of my application logic. I'm sure Ruby people feel similar. As great as the strides in js have been, it's just not as nice a language as many of the alternatives.
I dont agree on this point. Javascript has quite a many gotchas i agree, but once u get over them, javascript is a pretty beautiful language. I've been a pythonist before getting into js about 4 months ago, i still love python but the flexibility js provides is unmatchable. Even python cant beat it.
I'd love to here some specifics here. I've never heard anyone call javascript beautiful before. I don't mind js, but please let me know what flexibility js provides that is unmatchable.
I am no expert of Python or Javascript, but here's some of what I love in javascript

* first-class functions

this is the first thing anyone would fall in love with when coming from Python. Python do treat functions as first class, but Python follows OOP way more strongly and functions in Python never get that level of authority as they do in javascript. Ability to define anonymous and named functions anywhere, immediately executable, fully or partially is a huge plus.

* highly dynamic: monkeypatch anything anywhere

Javascript is highly dynamic, you can override almost any property of almost any object anytime in the timeline. This opens room for all sorts of hacker. Like I worked on a fairly complex Meteor application and we needed to modify the behavior of some core meteor methods. No, using them through a proxy wasn't a possibility as we wanted to change how the app behaves overall. How would you do it? Fork meteor and roll out other version? No. Just overwrite the functions on Meteor at right time in the timeline. I know it's more hacking than engineering, but not all hacks hurt.

at many places we would intercept the objects being created in one part of the framework that would go to another for further processing and do shit load of operations on them half-way to make them work as we want (like temporarily turn mongodb cursors to model (in MVC terms) like interfaces which are more easier to work and reason with), and then forward them with original interface, properties changed to processed values.

* prototypical inheritance

I like the way javascript does inheritance. Or how we force it to. The prototypical ladder cause many problems but it also open doors for many interesting solutions which won't be that easily achievable in other languages.

* fun of writing code

Once you grok the fact that js is a functional language, accept it and start using it like a functional language, javascript is tons of fun to write. I mean you won't miss (m)any python features if you sue javascript as a functional language and make use of the functional abstractions provided by several js libraries. Just using underscore makes a huge difference.

* flexibility and extensiblity

reading prototype.js code blew my mind. You can beat, bend and extend js in whatever way you want.Yes there are several gotchas (some of the language itself and some because of browser implementations), but despite of that what javascript has to offer is remarkable. I was intrigued to read prototype by js ninja book, and it is indeed mind blowing for someone new to js like me. I am looking forward to desiccate javascript libraries which provide highly functional interfaces and macros. Ability to serialize (almost) any function and modify it and then execute at the runtime opens room for innovative solutions (and all sort of sorcery/hackery).

* freedom

python is quite liberal, but javascript takes it to another level in terms of what you're allowed to do with your code. I don't know how to express it with words, and I don't know how you can not feel it when doing a js project.

In some ways Python is more liberal but in different areas - Metaclasses, 'magic' methods (hooking into __getattr__ allows some very clever behaviour), operator overloading, control of the abstract syntax tree and doing crazy stuff with imports. Try doing some of that in javascript.

You want prototypical inheritance? Here you go: http://tobyho.com/2009/05/23/prototype-inheritence-in/

Monkeypathing? Nothing forbids it other than a sea of raised eyebrows if there was a cleaner way to achieve the same thing.

The only limitation Python has with first-level functions is that they can't be anonymous. I know a lot of people chafe at this but I've never seen any javascript code that wouldn't be improved by removing a couple of levels of nested anonymous functions ;-)

I think it's the extreme level of flexibility I dislike about javascript. Even Ruby is a touch too malleable for my tastes.

For me it's about hitting a balance between readability and brevity and having clear community norms so that other people's code is immediately comprehensible.

There's just Too Many Ways To Do It in javascript.

I'd be very interested to know what flexibility you think javascript provides that python doesn't. I have nothing against JS (I usually enjoy writing JS), but IMO it doesn't begin to offer anywhere near the functionality or beauty that python does.

I'm not interested in language wars, just genuinely curious about your statement.