- Видео 62
- Просмотров 15 965
Domagoj Mišković
Хорватия
Добавлен 5 фев 2024
Enjoying programming.
Видео
Learn OCaml [4] - Sum a List, understanding recursion
Просмотров 252 часа назад
Essentially trying to sum a list of numbers and understand how recursion works, applying itself again and again.
Learn OCaml [3] - studying recursive calls
Просмотров 254 часа назад
Elementary stuff. So, here I go again through naming and functions, and then looked at how the recursive calls expand and contract.
Learn OCaml [2]
Просмотров 739 часов назад
So this is about me myself documenting how I learn OCaml from the very beginning. So, in this video, I'm kind of repeating some of the things I did in the previous one, basically going through the greatest common divisor algorithm, and then looking at let definitions and let function expressions, and basically just, you know, getting used to writing some OCaml and how the recursive evaluation w...
0 to LSP : Neovim RC From Scratch (following Primeagen) [1]
Просмотров 27812 часов назад
So, in this session, I felt the need to reflect a bit on my streaming so far, and then in this video, in this first part, I tried to, I was following the primagen, or the primagen, not sure how, I'm still not sure how you pronounce his name. I was following his tutorial on RUclips, and it was really fun, and I got stuck a bit, and so this is the first part.
OCaml from the very beginning [1]
Просмотров 19714 часов назад
Over the past few days, I've been exploring how memory allocation works in C and creating very basic examples of allocating and freeing memory. Along the way, I found myself wanting to do some functional programming along with C which led me to OCaml. I kinda like learning more than one thing at the same time. I decided to explore OCaml from the Very Beginning by John Whitington, a book designe...
Learning C - Build Your Own Lisp [4]
Просмотров 40019 часов назад
So, in this session, I kind of explored together with chatgpt the malloc and wrote a simple kind of Hello World malloc program, and then I went on to read the fifth chapter, and now we are up to installing the MPC parser combinator library. Watch live at www.twitch.tv/domagojding
Learning C - Build Your Own Lisp [3]
Просмотров 177День назад
Broadcasted live on Twitch Watch live at www.twitch.tv/domagojding
Learning C - Build Your Own Lisp [2]
Просмотров 717День назад
Note: Up to an hour or so, the sound is coming on right channel only, then I switched to mono until the end of session. Sorry about that. So, in this session, I kind of tried to wrap my head around the loops, the while loops and the for loops, and it was actually, and it's actually quite difficult. It's like, even though you can understand it, the going itself through the steps of evaluation, s...
Learning C - Build Your Own Lisp [1]
Просмотров 2 тыс.День назад
So I began now a new book, to go through the book, Build Your Own LISP, that teaches programming in C. And it's more, it's a long, it's a, it's a big, so the whole book is one big project of building an interpreter in C, in LISP, with C. Why am I doing this? Because a lot of the operating systems materials are all about C. And I kind of want to, I kind of want to go all over even now and learn ...
Rustlings #1 [ intro & variables]
Просмотров 6214 дней назад
Broadcasted live on Twitch Watch live at www.twitch.tv/domagojding
Rust Book #1 - [guessing game]
Просмотров 4614 дней назад
Broadcasted live on Twitch Watch live at www.twitch.tv/domagojding
Rust By Example #2
Просмотров 9914 дней назад
Broadcasted live on Twitch Watch live at www.twitch.tv/domagojding
Rust by Example [1]
Просмотров 12714 дней назад
Following along the Rust by Example tutorial Watch live at www.twitch.tv/domagojding
Writing an OS in Rust #3 [minimal rust kernel]
Просмотров 49514 дней назад
Writing an OS in Rust #3 [minimal rust kernel]
Writing an OS in Rust #2 [freestanding binary up to minimal rust kernel]
Просмотров 30914 дней назад
Writing an OS in Rust #2 [freestanding binary up to minimal rust kernel]
Writing an OS in Rust #1 [freestanding binary]
Просмотров 35114 дней назад
Writing an OS in Rust #1 [freestanding binary]
Just being very happy for making my first Nix package xD
Просмотров 2821 день назад
Just being very happy for making my first Nix package xD
NixOS - Packaging Existing Software with Nix [3]
Просмотров 11721 день назад
NixOS - Packaging Existing Software with Nix [3]
Packaging a .deb File on NixOS [1]: First Steps and Challenges
Просмотров 13728 дней назад
Packaging a .deb File on NixOS [1]: First Steps and Challenges
Still Syncing, Configuring, Watching Nix-Hour
Просмотров 10128 дней назад
Still Syncing, Configuring, Watching Nix-Hour
NixOS Setup: SSH, GNOME Keyring, and GitHub (Not Quite There Yet)
Просмотров 186Месяц назад
NixOS Setup: SSH, GNOME Keyring, and GitHub (Not Quite There Yet)
I really appreciate your efforts! I have a quick question: I have a SafePal wallet with USDT, and I have the seed phrase. (alarm fetch churn bridge exercise tape speak race clerk couch crater letter). How should I go about transferring them to Binance?
Freaking rust.
Holly C
27:47 yes, he is using an alias for nvim.. Really good work btw! keep it coming :)
The reason why you start with the static char array buffer is because when "static" is used on a variable in this context, it has a lifetime the entire length of the program, and we want to give a maximum amount of bytes to read in. And the reason why we use "cpy" is because we only want to be working with a string that is as long as the user inputs. We don't want to be moving around a huge 2048 byte char array when the user only inputs something like "Test". And we also don't know how long the user inputs it because it's being input at runtime, so we use malloc (or calloc which initializes the entire array) which allows us to dynamically allocate memory depending on how long the user input string is. Also, we use fgets which is a function that allows us to specify how many bytes to read in, rather than "scanf" which doesn't and could potentially cause a buffer overflow if the user enters more strings than we've allocated space for. I'll try to make it to your next stream!
@@lane1313 I've been learning OCaml in the past few days and been thinking of memory allocation in C. So one thing that strikes me as a beginner is this requesting of memory and then freeing it manually. So let's say I want to do a computation and I request a certain amount of memory. How do I know if that is exactly the right amount of memory I need? And why would I request a certain number that I'm not actually sure about it? It's like, what if I have thousands of such memory allocation requests? What happens when they pile up and maybe I forget to free them? But then it comes to me, why would I do all this manually? It seems like a well-defined programming task to find new ways how to allocate memory. It's like more in a fragmented way, as much as I need, I request, and such. But yeah, I guess I would need to see how garbage collectors are implemented to really know what I'm talking about.
@@domagojding You ask such good questions! "How do I know if that is exactly the right amount of memory I need?" Well, what you'd do is come up with a formula for allocating as much memory as you need. Like, say if I wanted to allocate N amount of integer space. I'd take the amount of items I'd need and multiply it by the size of the type. So I'd do something like `(int *)malloc(N * sizeof(int))` Also, to check that the memory is correctly allocated, you can simply check if the pointer is a null pointer, which is what malloc and calloc return if the memory allocation fails. "And why would I request a certain number that I'm not actually sure about it?" Because this gives you the ability to work on changing values. Data can be inconsistent and volatile, and it's important to allow your memory values to change, like with user input. The user may not always enter something like "test" or "input example". It's fluid and changing, and allowing your program to allow for such changes gives the user more freedom to interact with the program. "What happens when they pile up and maybe I forget to free them?" Well, you'll encounter an issue known as a "memory leak" which is when memory is constantly consumed without being freed. As you've said, there is "garbage collection", which some languages like D implement, which free and manage memory for you. There are arguments as to the benefits and cons of both automatic and manual memory management. Garbage collection gives you the relief of not having to worry about remembering to free your allocations. Whereas manual memory management gives you the freedom to control memory and use it how you see fit. Both ideologies have pros and cons.
I like how you configured your setup like Tsoding
What the line "char* cpy = malloc(strlen(buffer) + 1);" is doing is dynamically allocating as much memory is needed to store the string stored in "buffer" into "cpy". "malloc" is a C function that is used to dynamically allocate memory on the heap. It has a `void *` return type meaning you can assign it to char pointers, int pointers, float pointers, etc. "strlen" is a function that find the length of a given char array (c-string) up to but not including the null terminator. The reason +1 is added to the end is because strlen does not return the size including the null pointer. So we need an extra byte for that null terminator character. I'd highly recommend you look at the documentation for these on cppreference, which is a site that gives an interpreted documentation of the C and C++ standard.
You actually don't *need* to write `return 0;` in your C or C++ main function. The main function is a special function which acts as an entry point, and the OS will return with a status code its-self depending on whether it was able to finish successfully or not. There is a macro named "EXIT_SUCCESS" and "EXIT_FAILURE" which is akin to returning successfully (or unsuccessfully with the latter macro) depending on the platform that you could return from. So yeah, you don't have to write "return 0;" in your main function, but for any other function which does have a return type, you do need to return something.
@@lane1313 Thank you. I'm kind of still trying to wrap my head around this way of saying the return type, because coming from Haskell, a function is an expression of sort that is reduced to a simpler one or a value, so it's kind of, for now, weird to say what is the return type, but it seems to be that the reduction itself has some kind of a return type, and because the reduction is stateful, so changing something, the return type can be something else, right? So I'm trying to understand the implications of this return expression in C.
@@domagojding So return statements simply mean in layman's terms "Stop what you're doing, and send this back to where it was expected." In functions, return statements state that the function is finished being executed and that either a value, object, or address (if you're returning a pointer of something stored in the heap/dynamic memory region) is to be given back. Same with loops. You can add a return statement in a for or while loop to signify that the loop is to halt and a value is to be stored in whatever scope that it's in. Does that make sense?
@lane1313 You know, the interesting thing is that it does make sense in the sense that the words make sense to me, but I still am having, you know, much difficulty in unwrapping or what would be the best word to, you know, understand this, this, do I call it mental model of evaluation? Because I'm kind of, I'm kind of giving a lot of statements to everyone else, like being a big boss, and from functional programming, which is kind of more, well, maybe that's not fair to say now, but it's, it's like the level of communication is, it's a bit different in the sense that I, I have many functions that do one thing, and if I want to change the output of a function, I transform it or I, well, I transform it in the sense that there is another function that, that externally looks like changing state, but the state is not changed. So it's, I think it's very hard for me now to explain what I mean in a few words, but maybe the, the number of words for now shows, shows still the difficulty in the way I try to understand this imperative model of computation.
@@domagojding I think you should give yourself some credit. You're obviously coming from a different world of programming, and in a sense, throwing yourself into the deep end making a programming language (even if it's just following a guide) in C, which is a whole different programming paradigm. So you should show yourself some grace and continue enjoying the journey of learning C and making this wonderful project. Functions can in fact, do multiple things, however, they can only return one thing at a time when you specify a return type (such as int, float, etc). A return statement can involve an expression (such as for example 5 + a). When the OS reaches the return statement in the stack frame (the stack frame if you're unaware, is the place in memory where the function is being kept. You might learn about function pointers later) it executes the code contained within it one line at a time. If the function has a return type, it'll be expecting a return statement before exiting the scope, which is what the compiler checks for. Once it reaches that return statement, it copies the value that's being returned into memory, and moves it back into the scope where the function was called and if it's being called in an expression like an assignment, it'll be placed where the callee' expects it. This is why you can call different function from within functions and assign values to variables from within functions. Let me know if that doesn't make sense or if I should reword something.
@lane1313 Hello, thank you for the comments. When you say if it makes sense or not, I think it does make sense, but more like I still don't understand, I still don't have the motions, so to say, of how the imperative model works. And I guess I go from word to word, and even if I kind of understand what it does, after I read the whole thing, for example, what you wrote, I'm not sure what I read. And then I go back and I read it, so I guess it just needs more practice, and doing the same thing. So I'll see how it goes. I tried to reflect on what you said in the video, in my newest video, the stream, Build Your Own Lisp, the third part. And yeah, but I'll reread your comment more, and I will let you know how it makes sense, or if rewording something helps. So again, thanks for the comment.
Which font are you using in your terminal, please?
@@hrqmonteiro iosevka
All right, all right, all right. 1:08:04 kinuo si i aktivirao mikrofon
Hi. Maybe before starting with kernel development start to train with some more basic stuff to get to know the basics. I think without these basics it will just stay copy & paste "programming" without building up knowledge. Maybe have a look at "rustlings", it is a fun way to learn.
Hi. Yeah Im on Rust book now and will start rustlings too.
Are you making a mircrokernel?
@@boxerfencer Yeah, but I was advised to learn, to learn more Rust before I attempt to do something like that, and just today I saw that Tim Clicks in his book, Rust in Action, is also covering some of these things, some of the low-level programming, and also I was looking into FPGAs, and something like connected with Haskell, since basically that's my only background. But so far it seems like I'm going along the Rust book, yeah.
@domagojding that's awesome! Are you planning to do a general purpose OS? Minix re-sparked interest in microkernels, but I feared with Tannenbaum's retirement microkernel interest stalled. With Redox and others such as yourself, not to mention Google's Fuschia , maybe we'll eventually get a microkernel OS for popular use, sooner than later.
@@boxerfencer Hi. Well, I'm nowhere near capable of doing something like that for now, but it's an interesting project of sorts. I found out that I should probably do the MIT operating systems course that, as a teaching device, tries to study and extend the XV6 operating system. So I'm probably going to be doing that. Plus, I'm also rethinking, should I learn some C, because there is so much content about this written in C, and do that along with Rust. But, yeah, it's a fun ride.
Very interesting to learn a language that you chose for writing an operating system. However, as a developer that wrote two compilers I found that the language you choose is important for the function it is used for. In this case you would have an OS that is very dependent on the behavior of the language processor of Rust. C and C++ are used because they compile down to machine language placing nothing at a higher level of control than the OS itself. While it is an interesting project and it is your learning experience, it will not be a very usable operating system. In fact, there are many reasons Linus wants to pull Rust from the Linux kernel.
Interesting, I commented on this a bit in the next stream, Im curious about the type system, how low can you go with it. Or like with lifetimes which you as a C programmer hold in your head so to say or declare them in rust? Also isnt rust able to go all the way down just like C. Eventually you do assmbley? Also very curious about lisp machines that ran lisp on metal.
This series has been very cool so far :3
welcome aboard void linux , I've been on it for the better part of a year now and it's been great so far.
Okay you got me with the comment in the end. I didn't watch it. But I did listen to you while I was painting a chair. Yes you did many things wrong, especially with the ssh agent stuff. But that's life 👍
a perfect tutorial
Nice
let f = {a, b}: a + " " + b; in f { a = "hello"; b = "world"; }
Or even.... let f = {a, b, c ? " "}: a + c + b; in f { a = "hello"; b = "world"; c=" --random.spacer-- "; }
29:00 I'm running NixOS on WSL on a work laptop. It's pretty nice. How well will it work if I spawn a bunch of VMs from it...I'll have to try it!
I'm working on a configuration of a router/firewall. This might be a good way to test the configuration before deploying it, if I can figure out how to set up the virtual networking so that it's the same as the real network (with VLANs and everything).
I hope these videos help me because I have a program I want to install but there is no package for it yet. The community never created one. I don't want to install in a shell. I want it to be available to all users globally.
you have to know that, apart from your video has little to zero useful info, the major reason i am stay away and NOT subscript is becuz you are using chatGPT. this is SO bad
Sweet...pronounced : Dan D Lion ...not sure it matters. My cat is called 'fleur' (14:30 c=a.x or c = with a; x;)
aw dandelion haha yeah I see, oh nice hello fleur!
Great video. I am hooked. (Well I was hooked on Nixos already, but this is 'just what the Doctor ordered'.)1:22 "Do I have to write everything?" ....why not just scroll the previous input with up arrow and append?
Busy right now, but looking forward to going through your Nixos videos
Hey thanks. I think I will be making recap videos of what I have learned since this module system deep dive for example is going to take hours already.
@@domagojding Ah okay. I will wait then until you post a new playlist
garbage
No khan academy, you are also goona go into that rabbit hole
I get that xD I'll try not to too much. Thanks!
thanks for UNIQUE and PURE content. please keep it up.
Brilliant. Tutorials. Text is large & legible. Cheers!! I have just hacked my VMs so this video comes too late. "hx --tutor" btw.
Will do. Thanks! Hey I just saw numtide just released github.com/numtide/nix-vm-test
@@domagojding Thanks. Well I just wanted to set up a VM in case I ever felt the need for enhanced security, browsing or whatever. I set up Vagrant and also Qemu.But I doubt it I will use either. Distrobox (&BoxBuddy) meets a present need (a Debian package not in Nixpkgs).
amazing explanation !!! what font is that you are using
Oooh I will have to check in couple days, Im on a trip. I kinda change fonts sometimes. I use nerd fonts, hm this could be caskydia not sure
amazing initiative
Hey thats very nice!
I recently started looking into haskell as well, it's nice to see someone else make their way through it at the same time. Also that 'Suggested fix' error message at 40:47 is really useful.
It would be good to cover the reason the result is one = 1; three = 3; two = 2; from the rec example, the answer is it's alphabetical...which isn't maybe immediately clear. good series, keep up the good work!
oh right! I will keep a note of this. Thank you! Yeah, after I do all these nix dev tutorials I will redo them again but like deep dives so I'll be sure to mention this
Great stuff as always nix newb this stuff is helpful
My main gripe with nix is how long it takes to iterate on the configs, coupled with the fact that there's no easy way for migrating to nix. I would have loved to make nixos work, but I just settled for home manager to be able to quickly restore the main programs I use and their configs (shell tmux pager fzf etc).
Yeah, and payoff is great too. I like how all is so interconnected, programmable interface for your system, so once you start even with home manager, you kinda wish you can go deeper. I think it's a great way to really start interacting with the system, like let's say NixOS modules which are super nice deep thing on it's own, then types of derivations and nix store.. oh it's like a very fertile ground for many ideas. In the end it's all nix expressions all the way you go so anything you learn it's not like wasted, but it expands from anything you know.
Heeeey this looks like a cool initiative