WebFund 2024F Lecture 8

From Soma-notes
Revision as of 21:26, 3 October 2024 by Soma (talk | contribs) (Created page with "==Video== Video from the lecture for October 3, 2024 is now available: * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec08-20241003.m4v video] * [https://homeostasis.scs.carleton.ca/~soma/webfund-2024f/lectures/comp2406-2024f-lec08-20241003.cc.vtt auto-generated captions] ==Notes== <pre> Lecture 8 --------- Assignment 1 is due on Monday, Oct. 7th, will discuss solutions in class on Tuesday. If you ware working on Windows, you nee...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Video

Video from the lecture for October 3, 2024 is now available:

Notes

Lecture 8
---------

Assignment 1 is due on Monday, Oct. 7th, will discuss solutions in class on Tuesday.

If you ware working on Windows, you need an editor that will produce UNIX-style text files. Most sane text editors will not change the type of file, so if you start with the template you should be fine.

Newer versions of Notepad on Windows may have support for UNIX textfiles, not sure.

TextEdit on Mac does support it, but its default format is RTF, so you have to tell it to save as a plain text file.
  - if you can change the font of individual words or lines, it isn't a plain text file

When you are doing web development, you SHOULD be using UNIX-style text files.
 - DOS style text files will often work, but they can also cause weird issues
 - UNIX-style text files are basically always safe

VSCode is a perfectly good text editor and should do the right thing.

ONE IMPORTANT THING
 - openstack VMs may go down at any time!
 - make sure to keep local backups of any important work

HOW SHOULD YOU BE DOING TUTORIALS?
 - your goal should be to understand every line of code that is assigned
 - to that end, you should do the suggested tasks
 - IN ADDITION, you should play with the code!
    - change, delete things
    - extend functionality

The code in this class is mostly boilerplate-free, almost everything is significant
 - if you don't know why a line is there, you're probably missing a concept

Normally, when we use a database in a web application, that database is separate from the web server.
 - often running on a completely different computer
 - communication is over the network, whether local or remote
   (as most local databases are still in separate processes
    and behave as if they were on a separate machine)

But not with sqlite
 - it is an embedded database, becomes part of the application
 - it is VERY fast, sometimes faster than regular file I/O

As a piece of software engineering, sqlite is a wonder
 - very small, very reliable, very efficient
 - all written in C with LOTS of tests
 - uses its own revision control system, Fossil, rather than git
   (guess what the file format of Fossil is?)

But given that sqlite is written in C, but it isn't running as a separate process, how is it incorporated into our Deno program?
 - by using a version where the C has been compiled into WebAssembly


So modern web browsers can execute code in two formats:
  - JavaScript
  - WebAssembly

WebAssembly is designed as a target for compilers, so basically any code can be complied to WebAssembly and used in a browser
 - but that code will need some JavaScript glue code to use all of a browser's APIs


Understand that sqlite isn't like other databases
 - expects only one program to access it at a time
 - generally fine if embedded, but you don't want to be having multiple
   threads accessing sqlite at the same time, could go badly
 - should NOT be shared between concurrent programs!
    - can be done to some degree, sqlite will lock the entire database
    - but definitely not the way to go

In the context of Deno, this isn't a big deal
 - sqlite is so fast, can be part of main event loop
    - don't need to use it asynchronously
    - and in fact you really shouldn't try

In JavaScript, => is used to declare inline anonymous functions
 - specifically, you have parentheses with the function arguments,
   =>, and then {} for the function body