1 Java vs JavaScript

java vs javascript example

  java javascript
Execution bytecode executed in JVM script interpreted
Compilation source code compiled to byte code (type checking) sometimes transformed and/or compressed (minimized), but compilation not necessary
Types statically typed dynamically typed
Numeric types byte, short, int, long, float, double Number, BigInt
Portability “write once, run anywhere” (still depends on JVM version and implementation) Was horribly fragmented, today much better thanks to ECMA
OOP Everything is OO possible with prototypes
Inheritance OO Class prototypal
Concurrency Thread model Async callbacks with event loop
First class functions “kind of” since java 8 Yes
Function overloading Yes “kind of” with … rest operator in args
XML + JSON XML is a language. XML parsing supported out of the box. JSON OK JSON is a format (not a language). JSON is a subset of JS (is JS). XML possible via npm.
Exception Handling (try, catch, finally) Yes Yes
Deployment / Scaling typically big server, scaled vertically (add CPU+mem, i.e. add floors to building) typically containerized, scaled horizontally (add instances, i.e. add buildings to neighborhood)

2 What is node.js

3 Types in JavaScript

📢 JavaScript is dynamically typed 🚨

Theoretic types:

Inheritance:

4 Npm

npm

5 SQL vs NoSQL 🤜💥🤛

sql vs nosql

SQL NoSQL
storage tables collections
object encapsulation rows
👉 object may be split into multiple rows and across multiple tables (requiring ORM)
👉 normalized to remove duplication
👉 a single row may or may not have meaning to the application
👉 query with joins
👉 ORM to help read / write objects across tables
documents
👉 "semi-structured data"
👉 an entire object is typically encoded into a single document
👉 de-normalized to improve query perf & API requests (makes updates and deletions complex 👎😿)
identification primary key
👉1 row may not be an entire object
document id
👉 key value pair
👉 entire document can be fetched with id
organization table names tree
👉 similar to filesystem (directories and files)
encoding table schema
👉 column types
encoded into standard format
👉 JSON, XML, etc.
indexes yes ✔️ yes ✔️
queries SQL query language
👉 powerful and complicated
Query API or language
👉 generally simpler but limited
schema defined at table creation before adding data
👉 can be modified, but every row must match schema
no schema
👉 documents still need common structure to facilitate queries, but this is not enforced by the DB
schema migrations data must always be valid
👉 add new columns then complete existing rows
👉 often done with service "offline"
data is never validated
👉 modify all existing data to new structure (may require going "offline")
👉 migrate data at application time when documents are accessed (requires code that supports multiple versions of structure)
scalability vertical
👉 add memory, CPU, SSD, etc.
👉 adding floors to a building
horizontal
👉 sharding (replication over multiple servers/sites)
👉 adding buildings to a neighborhood
👉 ideal for large DBs and geographic distribution
examples PostgreSQL, MySQL, Oracle, Microsoft SQL server MongoDB, Redis, Cassandra, CouchDB, Firestore

Scaling

scaling