from what I see mostly removal of deprecated stuff, so a clean up release, which is not a bad thing. Good that TextEncoder & TextDecoder web api is now in node.js
Am learning Django and am getting more familiar with HTML's, JS's, CSS's as I go along. Can someone ELI5 why I'd need nodejs/npm? From my naive understanding, I can download all dependencies as source files and place them in static or go through a CDN, no? Is the sole purpose of npm downloading the various libraries?
Node.js can be used as an alternative to Python if you want to use Javascript instead of Python. It can run as a webserver, like Python. npm is a package manager for Node.js. It manages dependencies, and dependencies of dependencies, for Node.js projects.
The JS you can put on a CDN is client-side JS. You can download the source files and host them, or use a bundler such as https://webpack.js.org to compile them into a single file.
The advantage of any package manager over downloading source files is easy of use, you don't clog up your code repository with old files, etc.
I've got a subscription to Safaribooksonline, and there's a plethora of books/videos there. I found most to be somewhat limited in their scope, when read individually, but after going through a few of those, it starts to make sense :)
Thoughts: does not cover any html/css. The biggest negative I see here is that the book only shows a website twice or thrice. The rest of the book is pure-django-related stuff, which is very intersting/important but does not give a newbie a good understanding what he's actually doing (e.g. by showing real-life examples of a possible website). It contains some code-errors, unfortunately. I found it to be more useful as soon as I grasped the basics of django (models, views, urls, etc.)
Thoughts: absolutely the contrary to the above. Does show what sites you can create and provides the code for that so you can actually see what a website might look like, what a feature does etc., but it gives little to no explanation about the code. Without at least a basic understanding of how django works, the reader will have a hard time truly understanding what he's doing. It contains examples for multiple possible websites.
The only course I bought on udemy. Do absolutely not regret it. Content is vast, the instructor seems to know what he's talking about, many many many examples and explanation of all the basic concepts.
After reading through the aforementioned books, I found this tutorial to be super helpful. I went through the whole playlist within 2 days and this helped me to deepen the basic knowledge from the books
-------------------------------------------------
And except for that, I visit the django docs and stackoverflow every day, of course :)
I don't have any experience with Django. I'm hoping to learn Django next as it seem to solve a lot of backend complexity and provide a nice way to model data.
The reason I choose Node for the backend on one project was to have the same codebase and not maintain two systems (this project is in React so Node is a nice fit). But in hindsight I feel like I should have evaluated Django more. Node is difficult to maintain since it is so active with lots of dependencies to track :)
Would also like to hear someone else's experience with maintaining a Django project vs. Node.
I'm in the process of moving a project from Django to Node, these are some of the reasons: 1) Typescript everywhere: we are developing several frontends using Typescript, mostly with Angular and some Nativescript. Too many times I terminated a Python backend line with ";", mixed "true" and "True" or tried to solve a problem with a stream of (reactive) functions; 2) Django is sta(b)le: major changes, like Django Channels for websockets support, tend to have a difficult time in replacing the status quo and being first class citizens. This has a chain effect on the ecosystem which usually rely on the stable core. You may see this as feature because of the stability or as a limitation. If you, like me, may need websockets or GraphQL subscriptions, you will probably see the limitation first. Another issue related to stagnation is some degree of features overlap: if you are doing REST with Django you are probably using the Django REST framework, a third party framework built on top of Django. If you are using the DRF you will probably notice some similarities between forms and serializers and, as a matter of fact, serializers can replace forms and it is a good idea to do so, to avoid repetition. There are other similar cases, this is just an example; 3) The Django automatic admin is a trap: at the beginning it is a dream come true. You can do those boring CRUD parts literally in seconds, right? Then you start to push business logic into it. You do the first compromises: "ok, adding this single feature to the admin may require a little bit more time than what it would have taken with a stand alone dashboard, but the admin saved me tons of time so who cares?". Then you do it again. And again. And you will even change the way you reason about models because they will impact the UI the admin will generate. Very soon you will have a nightmarish mutation which will fight every new line of code. Of course I'm not saying that a feature should be avoided or considered bad because it can be used in a wrong way. I'm saying that you must know the tool and its limits to avoid the side effects, and often the ability to better see the bad parts come with experience; 4) performance: this is a very complex topic and depends on many different factors. For starters you may not need better performance at all, maybe your application can handle your workload without missing a beat because often web applications are IO bound anyway. But you must know that Django use a blocking IO design and this has some consequences regarding the number of concurrent clients served, the process model, memory usage, etc...
>From my naive understanding, I can download all dependencies as source files and place them in static or go through a CDN, no? Is the sole purpose of npm downloading the various libraries?
The purpose of npm is indeed downloading the various libraries, but not just for client development (to write JS for the browser) but also for server development. So it's also like pip in Python-land.
Nodejs on the other hand is more like a combined Python + webserver. It has the v8 runtime that executes .js (like Python executes .py files), various libraries you can import and use, plus a fast webserver built in.
On Node you can run frameworks similar to Django or flask (e.g. Express is a popular one).
We add node/npm to Django projects when we need a more complex pipeline for frontend JS than projects like django-pipeline can provide. If you want stuff like babel transpilation or tree shaking for your JS, all the fancy webpack stuff, you end up needing node in the mix.
If you need more asynchronous processing on the server side then node.js might be worth looking at (though you will need to do server side programming in JavaScript rather than Python. Python is far more pleasant to work with in my opinion).
Django channels however will give you the option of asynchronous server side code (and there are some other options for Python).
If you are at the learning stage I would forget about it for the time being.
NPM buys you automatic dependency resolution, a one-step process to update all your installed libraries to their latest versions, and the ability to pin some libraries to specific versions if you want/need to.
Some of these things you can get other ways -- libraries you load from a CDN will generally come with any critical dependencies already bundled in, for instance. But those solutions have their own problems; loading from a CDN means your app's performance is now tied to the performance of a system you don't have control over, and if the file on the CDN ever gets hacked, you're screwed. Managing your libraries with NPM lets you keep control over these sorts of things.
23 comments
[ 4.9 ms ] story [ 51.2 ms ] threadThe JS you can put on a CDN is client-side JS. You can download the source files and host them, or use a bundler such as https://webpack.js.org to compile them into a single file.
The advantage of any package manager over downloading source files is easy of use, you don't clog up your code repository with old files, etc.
In addition, since v6 [0], npm audits dependencies for security vulnerabilities, which is really useful to keep projects safe.
[0]: https://blog.npmjs.org/post/173719309445/npm-audit-identify-...
Here's a few of them:
https://www.amazon.com/Django-Unleashed-Andrew-Pinkham/dp/03...
Thoughts: does not cover any html/css. The biggest negative I see here is that the book only shows a website twice or thrice. The rest of the book is pure-django-related stuff, which is very intersting/important but does not give a newbie a good understanding what he's actually doing (e.g. by showing real-life examples of a possible website). It contains some code-errors, unfortunately. I found it to be more useful as soon as I grasped the basics of django (models, views, urls, etc.)
----------------------------------------------------
https://www.amazon.com/Django-Example-powerful-reliable-appl...
Thoughts: absolutely the contrary to the above. Does show what sites you can create and provides the code for that so you can actually see what a website might look like, what a feature does etc., but it gives little to no explanation about the code. Without at least a basic understanding of how django works, the reader will have a hard time truly understanding what he's doing. It contains examples for multiple possible websites.
---------------------------------------------------
HTML, CSS & Javascript:
https://www.amazon.com/Web-Design-HTML-JavaScript-jQuery/dp/...
Thoughts: great books! Filled with code and the actual picture of what all of it means/looks like. it covers all the basics but doesn't go super deep.
---------------------------------------------------
HTML, CSS & Javascript:
https://www.udemy.com/the-web-developer-bootcamp/learn/v4/ov...
The only course I bought on udemy. Do absolutely not regret it. Content is vast, the instructor seems to know what he's talking about, many many many examples and explanation of all the basic concepts.
--------------------------------------------------
Django youtube:
https://www.youtube.com/playlist?list=PL-osiE80TeTtoQCKZ03TU...
After reading through the aforementioned books, I found this tutorial to be super helpful. I went through the whole playlist within 2 days and this helped me to deepen the basic knowledge from the books
-------------------------------------------------
And except for that, I visit the django docs and stackoverflow every day, of course :)
Hope that helps.
The reason I choose Node for the backend on one project was to have the same codebase and not maintain two systems (this project is in React so Node is a nice fit). But in hindsight I feel like I should have evaluated Django more. Node is difficult to maintain since it is so active with lots of dependencies to track :)
Would also like to hear someone else's experience with maintaining a Django project vs. Node.
The purpose of npm is indeed downloading the various libraries, but not just for client development (to write JS for the browser) but also for server development. So it's also like pip in Python-land.
Nodejs on the other hand is more like a combined Python + webserver. It has the v8 runtime that executes .js (like Python executes .py files), various libraries you can import and use, plus a fast webserver built in.
On Node you can run frameworks similar to Django or flask (e.g. Express is a popular one).
I’m learning Ruby, can someone explain to me why I’d ever need Python/pip/PyPy/wheel/virtualenv?
You don't need node.js / npm. (I never have).
If you need more asynchronous processing on the server side then node.js might be worth looking at (though you will need to do server side programming in JavaScript rather than Python. Python is far more pleasant to work with in my opinion). Django channels however will give you the option of asynchronous server side code (and there are some other options for Python).
If you are at the learning stage I would forget about it for the time being.
Some of these things you can get other ways -- libraries you load from a CDN will generally come with any critical dependencies already bundled in, for instance. But those solutions have their own problems; loading from a CDN means your app's performance is now tied to the performance of a system you don't have control over, and if the file on the CDN ever gets hacked, you're screwed. Managing your libraries with NPM lets you keep control over these sorts of things.
Current stable is still at 8, and current is at 10 [1].
Is there a way to get this quicker?
[1]: https://nodejs.org/en/download/package-manager/#debian-and-u...
nvm is probably the easiest way to install it, but of course, you can do it manually:
1. mkdir -p ~/apps/
2. Download tar.gz and extract it to ~/apps/
3. Change $PATH variable to include the bin directory
4. Validate "installation" by version check[1]: https://github.com/nodejs/Release#release-schedule
Edit: There is also a snap package with nodejs - https://nodesource.com/blog/announcing-node-js-snap-linux-us... but there is 12.x (edge channel) not 11.x