Тёмный

Web in Native Assembly (Linux x86_64) 

Tsoding Daily
Подписаться 114 тыс.
Просмотров 55 тыс.
50% 1

Playlist: • Web in Assembly
Chapters:
- 0:00:00 - Announcement
- 0:00:56 - flat assembler
- 0:02:36 - Hello, World in fasm
- 0:12:10 - fasm is Self-Hosted
- 0:14:07 - fasm Macros
- 0:20:23 - bm
- 0:21:49 - fasm community
- 0:24:25 - Plans for the Session
- 0:26:32 - Starting the Web Server
- 0:29:10 - Creating the Socket
- 0:38:08 - Stealing Constants from C
- 0:39:22 - Inspecting with strace
- 0:42:10 - Inspecting with gdb
- 0:49:19 - Storing the Socket in Memory
- 0:55:19 - Handling Socket Error
- 1:00:40 - Log Tracing
- 1:05:23 - The Difficulty of Binding the Socket
- 1:07:26 - Allocating sockaddr Structure
- 1:19:46 - Populating sockaddr Structure
- 1:25:52 - Binding the Socket Address
- 1:32:06 - Closing the Socket
- 1:35:45 - Listening to the Socket
- 1:39:55 - Accepting the Connection
- 1:53:32 - Responding with Plan Text
- 1:55:05 - Responding with HTTP Response
- 1:59:59 - Request Processing Loop
- 2:03:22 - Outro
References:
- flat assembler - flatassembler.net/
- Chromium OS - Linux Syscalls - chromium.googlesource.com/chr...
- tgrysztar - fasm - github.com/tgrysztar/fasm
- Tsoding - bm - github.com/tsoding/bm
- MenuetOS - www.menuetos.net/
- nakst - gf - github.com/nakst/gf
- musl - libc - musl.libc.org/
Socials:
- Twitch: / tsoding
- Twitter: / tsoding
Support:
- BTC: bc1qj820dmeazpeq5pjn89mlh9lhws7ghs9v34x9v9

Наука

Опубликовано:

 

25 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 196   
@garakchy
@garakchy 9 месяцев назад
Protect this geek at all costs. He is a gem in modern world where people find even python a difficult language.
@snk-js
@snk-js 9 месяцев назад
yesss, I am so grateful to find deep content in the surface of the web
@aziskgarion378
@aziskgarion378 9 месяцев назад
Sadly, his government will snatch him and force him to be a part of their military programs.
@varshneydevansh
@varshneydevansh 9 месяцев назад
Python is difficult as it hides so many things behind the wrapper 😫
@shedontlove8490
@shedontlove8490 9 месяцев назад
He said it quite clearly on his last Twitch stream: "There's no magical book or course that will make you a programmer. Just endure the pain." That's the only way you can learn programming.
@axelkoster
@axelkoster 9 месяцев назад
​@@shedontlove84901:02:38
@cobbcoding
@cobbcoding 9 месяцев назад
oh my gosh he did webdev in the language the memes tell me not to learn because it is hard oh my.
@ocaly
@ocaly 9 месяцев назад
But what a beautiful video he assembled here today for you!
@nikkehtine
@nikkehtine 7 месяцев назад
The best way to do web dev is without the tools that have been made specifically for web dev
@angelcaru
@angelcaru Месяц назад
too true​@@nikkehtine
@helidrones
@helidrones 9 месяцев назад
For me as a late boomer / early gen X this feels like coming home from a long journey. No dependency hell, can be debugged with pen and paper. Thank you!
@rkdeshdeepak4131
@rkdeshdeepak4131 9 месяцев назад
Best Web Dev Tutorial for beginners.
@davidebiondani3062
@davidebiondani3062 7 месяцев назад
Hahaahah
@bitmanagent67
@bitmanagent67 9 месяцев назад
Tsoding is a freaking genius!!! I love the way he decomposed problems and solves them one by one. He is a real OG programmer.
@DivineDarknesss
@DivineDarknesss 9 месяцев назад
the cubicle bound webdev fears the recreational assembler
@brunopena3710
@brunopena3710 9 месяцев назад
this is what i thought WebAssembly was at first.
@im-anomalies
@im-anomalies 7 месяцев назад
Dude, I really appreciate what you are doing, it is rare to have such of deep content (at least to me who is a junior myself) but yet entertaining. I really love to see and learn how things work under the hood, not just using them, and most of your video just fit that.
@yyvan5125
@yyvan5125 8 месяцев назад
Watching this taught me a lot, on top of you explaining how things work, reading some docs and following along in c is super fun. Thank you mr Tsoding
@bbq1423
@bbq1423 9 месяцев назад
1:32:20 You can use the `goto out` pattern used in the linux kernel here, as in for each error branch you'd do `jl out_x` where x is an incrementing number, then at the end of the function you have the labels in reverse.
@sortof3337
@sortof3337 9 месяцев назад
I watched and followed everything in the entire video. Oh man, it was so satisfying to see hello world. I even parsed the name myself. Thank you thank you.
@JannisAdmek
@JannisAdmek 4 месяца назад
If you ever feel neglected, just remember the EXIT_SUCCESS and EXIT_FAILURE he defined at 59:40 and then ignored for the rest of the stream.
@konstantinsotov6251
@konstantinsotov6251 8 месяцев назад
That's what I thought of when I first heard the word "Webassembly"
@nefrace
@nefrace 9 месяцев назад
This is the first video that I've fully watched on your channel, and now I want to try fasm in gamedev
@gnorts_mr_alien
@gnorts_mr_alien 7 месяцев назад
That was really fun you made me watch the whole thing!
@victornikolov537
@victornikolov537 9 месяцев назад
I like you find all that fun. That is the way to learn. If one can't enjoy learning it is torture.
@disoversity
@disoversity 9 месяцев назад
This channel is amazing.
@Arniores
@Arniores 9 месяцев назад
watched the whole thing, actually cool
@paoloose
@paoloose 9 месяцев назад
i can literally watch you coding for hours
@legendrags
@legendrags 6 месяцев назад
Yesterday, I didn't even know this guy. Now, he is one of the best ppl I know.
@shipitko
@shipitko 8 месяцев назад
wow, the development screencast by anyone who is not indian on youtube in 2023! instant subscription
@tonym5857
@tonym5857 8 месяцев назад
Great video ... took my attention from the beginin..
@varshneydevansh
@varshneydevansh 9 месяцев назад
I watched this stream and it was amazing 💪🏻
@akashkarnatak6581
@akashkarnatak6581 9 месяцев назад
What a madlad!!
@kompocik5195
@kompocik5195 9 месяцев назад
I love how you explained syscalls so fast. I do know that you don't make tutorials but maybe you would like to do one about Assembly etc. because you're explaining everything in very easy way without unnecessary theory while doing real-life examples :P.
@iamdozerq
@iamdozerq 9 месяцев назад
this IS a tutorial for everyone who wants to learn
@pokefreak2112
@pokefreak2112 9 месяцев назад
all his videos are already tutorials, you can follow along and learn exactly what he's doing by googling the parts you don't understand I've been watching since 2019 and learned a ton anything more trimmed down than this would lose a bunch of important information
@rebokfleetfoot
@rebokfleetfoot 9 месяцев назад
i've done my share of assembly, but never thought about it as a web app, wild and cool idea :)N
@Tepigers
@Tepigers 8 месяцев назад
cant wait for the cobol web development video 🙏
@bbq1423
@bbq1423 9 месяцев назад
There is a pretty neat clang built in that lets you dump structs in a formatted way (__builtin_dump_struct)
@grenadier4702
@grenadier4702 9 месяцев назад
Sockets automatically close on program exit Backlog defines the queue of waiting-to-connect sockets and already-connected sockets. If your backlog is 100, you have at maximum 50 connected sockets and 50 awaiting sockets
@billwall267
@billwall267 9 месяцев назад
Tremendous. Please do more fasm vids.
@JamesSjaalman
@JamesSjaalman 9 месяцев назад
The size argument to bind() is also needed for copy_from_user to know how much to copy, without knowing the exact subspecies of the polymorphism. (BTW: the overlaid "struct sockaddr" construct is often named a "smart union")
@Tawre007
@Tawre007 9 месяцев назад
"struct sockaddr" hopefully doesn't want to get raised pay
@nefrace
@nefrace 9 месяцев назад
1:02:49 -- now that's my favorite way to tell user that everything is ok "Oking service"
@bbq1423
@bbq1423 9 месяцев назад
1:45:20 The size field is calculated the wrong way around
@julesl2087
@julesl2087 9 месяцев назад
yeah it's "$ - .sin_family"
@remrevo3944
@remrevo3944 9 месяцев назад
@@julesl2087 Or as written in the documentation also just $ - .
@cold_ultra
@cold_ultra 9 месяцев назад
So when can we expect a developer bootcamp for beginners using this stack?
@ichigo_nyanko
@ichigo_nyanko 8 месяцев назад
Hello, 'not a low level person', nice to meet you.
@hughdavenport1
@hughdavenport1 9 месяцев назад
I had a similar issue with not having names in the debugger. I looked into the specs needed. In the end I used porth (yes porth!!) to read the custom debug file fasm to create some more asm (and maybe C?) files so that the debugger knew the names!
@jamesnewman9547
@jamesnewman9547 9 месяцев назад
Starcraft used IPX by default for networking
@f1refa11
@f1refa11 8 месяцев назад
это слишком офигенно
@JakobKenda
@JakobKenda 8 месяцев назад
13:15 I downloaded the fasm executable directly from their website and it is, in fact, statically linked
@remrevo3944
@remrevo3944 9 месяцев назад
1:56:35 In my experience you can also always just open the network tools and capture one request. That already shows enough about http to be useful.
@whoopsimsorry2546
@whoopsimsorry2546 9 месяцев назад
Well, x86_64 has it, however if you were dealing with x86 amd and intel have different ways of calling syscalls and you'd have to use the vDSO. That's the original reason vDSO was created so you don't have to different syscalls for the different architecture. However, nowadays the vDSO also contains stuff that just shouldn't require kernel access like get_time() and stuff like that.
@__christopher__
@__christopher__ 9 месяцев назад
On x86 you can just use INT 0x80, that works on both architectures.
@HPMuwa
@HPMuwa 9 месяцев назад
You forgot close connfd, maybe if browser get close or content-length, it would be faster because browser will know that content is over
@HPMuwa
@HPMuwa 9 месяцев назад
And will not wait new content
@orizach01
@orizach01 9 месяцев назад
this whole video reminded me of the time you did basically the same thing but in porth
@orizach01
@orizach01 9 месяцев назад
1:28:20 this made me smile
@alexandrohdez3982
@alexandrohdez3982 8 месяцев назад
Great 👏👏👏
@rt1517
@rt1517 6 месяцев назад
1:23:43 It is really easy to implement htons in assembly using XCHG instruction. And for htonl, there is the BSWAP instruction. And for information, in C, you can use __builtin_bswap16/__builtin_bswap32 under gcc and _byteswap_ushort/_byteswap_ulong under msvc.
@KitsuneAlex
@KitsuneAlex 8 месяцев назад
Does bind really determine the type based on the size? Looks more like a validation thing to me, the actual type is probably deduced using a union-type approach where they check the address family, since that's always the first field of the struct. At least that's what i'd expect. Good video :3
@wisnoskij
@wisnoskij 9 месяцев назад
This language seems so cool. For me, It is weird thinking about code being OS dependent. The OS they built for example in in theory either be written in Windows fasm or Linux fasm or possibly even written in fasmOS fasm and only compile-able on itself a different kind of self hosting.
@telnobynoyator_6183
@telnobynoyator_6183 9 месяцев назад
> interpreter that outputs binary No way I had a similar idea a couple days ago for my own programming language and now I'm seeing an example of that x)
@tomaspecl1082
@tomaspecl1082 9 месяцев назад
This is cool. And btw I also had a similar idea before. Basically its not an assembler. Its all macros. Even the "instructions" are just macros. That way you should be able to use different instruction sets with it by only changing the definitions.
@huistelefoon5375
@huistelefoon5375 8 месяцев назад
it's called a compiler
@oracuda
@oracuda 8 месяцев назад
more like LLVM IR@@huistelefoon5375
@Tigregalis
@Tigregalis 9 месяцев назад
since i am learning technology from tsoding, and tsoding is a meme lord, does that not mean i am learning technology from memes?
@jamesnewman9547
@jamesnewman9547 9 месяцев назад
I also did a very similar thing back in the oughts by writing go functions that when called, looked like G-Code and output gcode to stdout. So then I have all the power of golang, but then my main was this go-gcode hybrid that output gcode when run. Yeah.
@lnlnxlnx3685
@lnlnxlnx3685 9 месяцев назад
Very interesting
@dennis-heinri-ch
@dennis-heinri-ch 8 месяцев назад
First of all: A really great video! I learned a few basics about fasm. But one more thing: What desktop environment is here in use? I never had seen something like this before. But i like it :)
@MatiByte
@MatiByte 7 месяцев назад
I think it's i3wm🙂
@andy_lamax
@andy_lamax 9 месяцев назад
I just had a crash course on syscals and I am mad how I understood them in under 12 mins
@krenilraj4180
@krenilraj4180 9 месяцев назад
Bro which course can you tell me ?
@SaifKhan-lq1sp
@SaifKhan-lq1sp 9 месяцев назад
​@@krenilraj4180this video lol
@ProtossOP
@ProtossOP 9 месяцев назад
@@krenilraj4180I assume he meant this video
@andy_lamax
@andy_lamax 9 месяцев назад
this video 😂
@krenilraj4180
@krenilraj4180 9 месяцев назад
@@andy_lamaxLOL
@anon_y_mousse
@anon_y_mousse 9 месяцев назад
This might be why I used nasm instead, but I've been trying to figure out if you can do variadic macros and none of the examples from the fasm website are working with fasm itself. So supposedly you can do variadic macros, but either the examples are out of date or my copy of fasm is. Maybe I'll write my own assembler so it's not annoying.
@keremardicli4013
@keremardicli4013 9 месяцев назад
Visual studio is on the market since 97!
@huistelefoon5375
@huistelefoon5375 8 месяцев назад
And it still keeps getting worse!
@user-ko5yr9mo6d
@user-ko5yr9mo6d 9 месяцев назад
Are you john_found who wrote article on habr about this?
@ukuluhamaa5908
@ukuluhamaa5908 9 месяцев назад
It does seem that fasm not being static is a debian thing, in the arch repos it's static.
@ecosta
@ecosta 8 месяцев назад
ASM is "hard" because people treat CS like the "how to draw an owl" joke: we have machine code, then we have assembly, then we have React. What is in-between? Who cares! I just LOVED the concept of "fasm" - I might try it sometime on my old asm repos.
@rationalityfirst
@rationalityfirst 9 месяцев назад
On my Arch install fasm is static. I use Arch, btw.
@__christopher__
@__christopher__ 9 месяцев назад
Your second sentence is redundant. Well, technically I guess you could have an Arch install without using it ...
@ce5983
@ce5983 9 месяцев назад
​@@__christopher__bro was invoking the "arch, btw" meme so people wouldn't think he was just saying that to highlight his use of arch. I'm using Arch rn, btw
@ce5983
@ce5983 9 месяцев назад
fasm: I'm a bit of a webdev myself
@huistelefoon5375
@huistelefoon5375 8 месяцев назад
Ah, so this is the Web Assembly my colleagues have been talking about..
@StevenMartinGuitar
@StevenMartinGuitar 9 месяцев назад
Next up, "Implementing our own C in fasm" 😅
@rationalityfirst
@rationalityfirst 9 месяцев назад
Gdb has a command that starts and automatically stops at the entry, it's 'starti'.
@ChaoticNeutral6
@ChaoticNeutral6 9 месяцев назад
Huh, when I use fasm locally the output elf files are executable by default. Weird
@patto2k358
@patto2k358 9 месяцев назад
26:31 writing a simple TCP server in fasm
@kgarrison343
@kgarrison343 9 месяцев назад
How long until you're writing your own os in fasm?
@ayoubbelatrous9914
@ayoubbelatrous9914 9 месяцев назад
in my opinion fasm competes with food
@shrddr
@shrddr 6 месяцев назад
pretty sure I learned more in 2 hours than 2 years of university
@farpurple
@farpurple 8 месяцев назад
Why do i need stdlib if syscall(1, 1, "Hello world", 14) ?
@flamendless
@flamendless 9 месяцев назад
I think I'll prefer to code in fasm over cpp
@freezingcicada6852
@freezingcicada6852 8 месяцев назад
1:56:29 This whole bit has been my experience whenever I'm searching for answers/ examples and makes me question the legitimacy of "I just google the answers, bro" memes.
@7KeHek
@7KeHek 9 месяцев назад
There was int 80h for syscalls in 32bit Linux.
@alicewyan
@alicewyan 9 месяцев назад
What is the pretty font in your emacs?
@someever2
@someever2 7 месяцев назад
Iosevka
@uuu12343
@uuu12343 9 месяцев назад
1:08:57 This is the art of grepping
@rogo7330
@rogo7330 9 месяцев назад
IPX is dead. I remembering fixing aircrack-ng's driver for TP-Link USB WiFi dongle and it would not compile because there was some shit in code about IPX, and at the time IPX was already purged from Linux code base. I least I remember it when I was searching for it in git logs in kernel sources.
@rogo7330
@rogo7330 9 месяцев назад
words are hard bruh
@fareltek4111
@fareltek4111 9 месяцев назад
Hi.Can you implement Eventbus Publish/Subscribe system in c please.Thank you for videos
@paulzupan3732
@paulzupan3732 8 месяцев назад
Do you use evil mode
@rationalityfirst
@rationalityfirst 9 месяцев назад
1:45:00 it didn't work because you switched the operators for computing size.
@SolathPrime
@SolathPrime 9 месяцев назад
This evil :fear:
@FireDragon91245
@FireDragon91245 9 месяцев назад
lol it reminds my of my own assembly transpiler it also has compile time generatoed code but mine does not have compiler directives like %for or something you can write you own compile time generators in the language itself
@cobbcoding
@cobbcoding 9 месяцев назад
Chromium syscall table 🗿
@ivanjermakov
@ivanjermakov 9 месяцев назад
It's webdev after all...
@samnit.
@samnit. 7 месяцев назад
I need programming classes from you
@LivingInLowLevel
@LivingInLowLevel 9 месяцев назад
Try nasm assembly too please 🙏
@LivingInLowLevel
@LivingInLowLevel 9 месяцев назад
Nasm 32 bits
@mmmmm1438
@mmmmm1438 9 месяцев назад
bro i will make celebrate if you respond i want your opinion about problem solving website
@juniordataengineer
@juniordataengineer 7 месяцев назад
And what is this guys real name . He is soo good
@konkitoman
@konkitoman 9 месяцев назад
Why in ASM takes 30-50ms to load, from binary content and in Rust (tokio + axum + tower-http) loading a file then presenting takes only 1-2ms to load Why ASM binary that is 1KB is slower then 60MB Rust binary Please explain why is that slow and how you can make-it faster!
@Joorin4711
@Joorin4711 9 месяцев назад
@@aqfj5zy There is no compiler involved when generating the *binary* that is serving the data to the browser in the video. I know that tsoding says "And it compiles!" but that is not actually what is happening. The time it takes from the browser making its request to the page being counted as loaded is pretty much bounded by the browser in this case.
@Stroopwafe1
@Stroopwafe1 9 месяцев назад
Because Tsoding didn't include any of the optimisations you can do to make it serve responses as quickly as possible. You're comparing the most basic webserver to a well developed framework. Also, webservers aren't CPU bound, IO is the thing that takes the most time. If webservers were CPU bound, then this most basic example would outspeed every framework
@TsodingDaily
@TsodingDaily 9 месяцев назад
Because I forgot to close the connection
@konkitoman
@konkitoman 9 месяцев назад
Now i realizate that you need to flush or close the connection!
@curoviyxru
@curoviyxru 9 месяцев назад
why I have read the title as dev in webassembly...
@TsodingDaily
@TsodingDaily 9 месяцев назад
I changed the title. Hopefully it's easier to read now.
@PopescuAlexandruCristian
@PopescuAlexandruCristian 9 месяцев назад
From what I remember fasm has wasm as a target so future stream where the response payload is fasm compiled to wasm from fasm is the next logical step :)
@Rakkoonn
@Rakkoonn 9 месяцев назад
​@@PopescuAlexandruCristian So you could have a fullstack framework in assemby. Finally gone full circle from javascript.
@user-bb4sb7xb1e
@user-bb4sb7xb1e 7 месяцев назад
Is the source code for this on github?
@warnaoh
@warnaoh 9 месяцев назад
How does he get this gdb "gui" ?
@huistelefoon5375
@huistelefoon5375 8 месяцев назад
it's a built-in feature of gdb, you can do this with `tui enable` as he did in the video
@rev_krakken70
@rev_krakken70 5 месяцев назад
Can you share with me the discord link?
@masoud1128
@masoud1128 9 месяцев назад
Please do zig crash course
@suryaprakash-sh5bf
@suryaprakash-sh5bf 9 месяцев назад
What's that emacs theme anyone 😅
@sams6889
@sams6889 8 месяцев назад
Just following along for fun, my gf2 does not show the instructions after i try `run` even though the program runs fine (at 47:00)... anyone know why? Btw thanks for this great video. +1 sub
@konstantinrebrov675
@konstantinrebrov675 8 месяцев назад
What kind of assembly language is this?
@ango_coding
@ango_coding 4 месяца назад
Its fasm assembler
@andy_lamax
@andy_lamax 9 месяцев назад
tsoding after explaining something for like 10 mins. Then says "I don't fully understand it"
@hamzakhiar3636
@hamzakhiar3636 8 месяцев назад
What's his discord server
@yaksher
@yaksher 8 месяцев назад
Only like an hour in, but it kinda feels like using an assembler with such powerful macros ends up sorta defeating the point, because if you're generating the bulk of your code through macros like this... well, it's basically serving as a compiler that does no optimization. You lose out on the ability to skip unnecessary operations and very tightly pack things and whatever. At that point it's just like... why not write C?
@TsodingDaily
@TsodingDaily 8 месяцев назад
twitter.com/tsoding/status/1704206555594264984
@yaksher
@yaksher 8 месяцев назад
@@TsodingDaily I don't think it's cheating, and I think it's a very neat. Obviously the objective of this video was not to create the best or easiest website and it's not a criticism of the video. I'm just wondering if assembly with this many macros serves any practical purpose or if using so many macros ends up defeating what limited practical function assembly still has with compilers as smart as they are.
@TsodingDaily
@TsodingDaily 8 месяцев назад
> I'm just wondering if assembly with this many macros serves any practical purpose urmom said it does
@Winnetou17
@Winnetou17 8 месяцев назад
@@yaksher Whenever you want/need to optimize or do crazy stuff, you can simply not use macros or whatever.
@yaksher
@yaksher 8 месяцев назад
@@Winnetou17 Okay but by that token, you may as well just write C and inline assembly the parts you need to super-duper optimize. Optimizing or doing crazy stuff is the only practical purpose assembly really _has._ Outside that, it's just a fun gimmick. Or perhaps I'm missing something, which is what I was asking about.
@nathanfranck5822
@nathanfranck5822 9 месяцев назад
Next tcp/ip in qbasic
@grawlixes
@grawlixes 9 месяцев назад
I would nonironically love this
@3dplaycanvas
@3dplaycanvas 8 месяцев назад
Бро, ты русский? Можно по-русски вопросы в комменты кидать тебе?
Далее
I regret doing this...
1:20:07
Просмотров 64 тыс.
Are headphones destroying our hearing?
6:49
Просмотров 239 тыс.
The Linux Experience
31:00
Просмотров 296 тыс.
Symbolic AGI: How the Natural Will Build the Formal
43:32
Signals. I spent 2 years to understand this part.
21:24
How A Steam Bug Deleted Someone’s Entire PC
11:49
Просмотров 903 тыс.
This is NOT a Tesseract.
13:13
Просмотров 297 тыс.
Спидран по ПК
0:57
Просмотров 30 тыс.
С iPhone точно не укачает!
0:41
Просмотров 470 тыс.
iPhone 16 - КРУТЕЙШИЕ ИННОВАЦИИ
4:50