Post bootcamp study "thread" for us 'real' beginners ;-) ... jump on in

I am going to go thru the entire ‘camp’ materials but supplemented with very basic ‘getting started’ info.
1> my first step today is watching the video from the designer of the language here:

cheeses are somehow a secret message apparently

and then some reading starting here:

as I have an interest in more functional ML languages.
looks like we need to update some links^^^^

follow along… lets see where we go

<> web assembly // more that just web use and not really assembly either
// its an abstraction from the bottom up / not top down.

<> async // functions complete sooner or later

<> let some_variable // are immutable by default

<> stable var some_variable // persistent memory is maintained after an upgrade on the canister code.

code from a Mokoto talk showing varient types and a recursive function. how special is that?
<> live coding on Motoko Playground Motoko Playground - DFINITY
the code on the playground is persistent. while canisters time out at 20 minutes

9 Likes

My plans for today are to go thru the Motoko at a glance page and define each element as best i can.

Semantics

  • call-by-value (like Java, C, JS, and ML; unlike Haskell and Nix) // better name than not lazy
  • declarations are locally mutually recursive // ?this one will need some research.
  • parametric, bounded polymorphism //???
  • subtyping as subsumption, not coercion //???
  • no dynamic casts
  • no inheritance // I think I will like this part – never really got the idea of this.something

please don’t hesitate to reply with some info. :wink:

2 Likes

Someone please chime in if I’m way off, but I believe this is a somewhat complicated way of saying:

a) functions should have unique names

b) you can call one function from inside another function (and the other way around)

In other words, if you split your problem intro smaller sub-problems, based on a branching logic, then you can call one function from the other, getting the desired result and keeping the code and logic a bit cleaner, and easier to understand at a glance. Doing so “recursively” is a fancy way of saying in a for loop, with special steps, and some jedi memory tricks along the way. Recursion is a bit more advanced of a concept for a beginner lesson, I would say.

So, I believe you’d need to first cover the strongly typed concept before. In strongly typed languages, every function needs to define what type of parameters it receives and returns. That is to say, if you write a function that takes an Int as an input, you won’t be able to call it with a float, or a string, etc. That concept is called strongly typed.

So what do you do when you need to write a function that could work on a bunch of types (maybe even all), if the types respect some conditions (bounded)? Well, you write a generic function. And we usually call them generic over T, where T is a generic type. That is to say, it doesn’t matter what type T is, just that it is a type (that satisfies some boundaries).

e.g. func add(a:T , b:T) → T { return a +b }

//terrible pseudo-code just for illustrating purposes

You’d be able to call add with (1.0, 2.0) as well as (1:8bit int, 2: 8bit int), etc.

I think you are right about most of these items are a little advanced. I will double back and fill in my responces later
Thanks for your info. It is slowly sinking in

spent half the day playing in the playground … loading examples from the fresh examples in dfinitys github.

a big advantage at beginning coding is knowing how to clone a repo … hours of entertainment .
the new encrypted_notes_app
trying to get it to run on my local machine.
ill add some links later.
got pretty far in the readme setup… but was unsuccessful
I thought docker made all things equal. :frowning:
error messages are a theme today

1 Like

so i got a new mbp yesterday by enduring a 3 hour return trip that normally would take 1 hour. not to complain because it is nice. having a few issues just getting the dfx new project defaults to run on node.

` modules by path ./node_modules/simple-cbor/src/*.js 17.5 KiB 3 modules
modules by path ./node_modules/iso-url/ 4.36 KiB 3 modules
modules by path ./src/ 2.05 KiB
./src/hello_assets/src/index.js 526 bytes [built] [code generated]
./src/declarations/hello/index.js 1.38 KiB [built] [code generated]
./src/declarations/hello/hello.did.js 167 bytes [built] [code generated]
webpack 5.63.0 compiled successfully in 378 ms
[webpack-dev-server] [HPM] Error occurred while proxying request localhost:8080/api/v2/status to http://localhost:8000/ [ECONNREFUSED] (Errors | Node.js v17.7.2 Documentation)
[webpack-dev-server] [HPM] Error occurred while proxying request localhost:8080/api/v2/canister/rrkah-fqaaa-aaaaa-aaaaq-cai/call to http://localhost:8000/ [ECONNREFUSED] (Errors | Node.js v17.7.2 Documentation)
^C [webpack-dev-server] Gracefully shutting down. To force exit, press ^C again. Please wait…
[webpack-dev-server] [HPM] server close signal received: closing proxy server

[email protected] hello % dfx --version
dfx 0.9.2.

[email protected] hello % node --version
v17.7.2.

[email protected] hello % npm --version
8.5.2.

It works fine using:
http://localhost:8000/?canisterId=ryjl3-tyaaa-aaaaa-aaaba-cai

but throws the above error from:
localhost:8080

also do i need to just add the new principal id to my older projects to use the new laptop on them?
nope! after adding new principal getting
Error: The Replica returned an error: code 4, message: “Caller is not authorized”

this did work tho:
dfx canister --network ic install --mode=reinstall ICbootCamp_assets

im even getting error 503 on forum.

Sorry for the late response here - this is an issue caused by the http proxy used by webpack-dev-server being broken on Node 17. We recommend using a long-term-support version, such as 16.

you can also try changing the proxy host from localhost to 0.0.0.0 in webpack.config
I had the same issue on my macbook air

1 Like

rolling back node to 16 lts was not sufficient. but after editing webpack.config as suggested resolved my error - thanks

1 Like