- 12
- 6 641
Beyond TypeScript
Germany
เข้าร่วมเมื่อ 12 ธ.ค. 2023
Hi, I'm Ivan. I started this channel to share my knowledge and maybe even entice people who are stuck with TypeScript to look beyond it. There are wonderful alternatives out there, from which we can at least, learn a lot.
Is Elm's syntax really weird?
When people see Elm's syntax for constructing views for the first time, they find it strange. However, there's nothing wrong with it because it's just syntax. Let's explore.
#elm
#elm
มุมมอง: 25
วีดีโอ
Elm deep dive and why is it so reliable?
มุมมอง 697 ชั่วโมงที่ผ่านมา
I want to dive deeper into what makes Elm so reliable in this video. #elm #frontend #archtecture #learning
Choosing Elm in 2024?
มุมมอง 997 ชั่วโมงที่ผ่านมา
I built a simple browser extension and decided to use Elm for this project. Was it worth it? Absolutely! But most importantly, there's so much to learn from it and apply to other mainstream frameworks! #elm #frontend #architecture
Rescript source, episode 7: Modules and Functors
มุมมอง 29810 หลายเดือนก่อน
In this episode, we'll talk about ways to organise and structure the #rescript code. #frontend #rescript #typescript
Error handling in TypeScript. How to avoid exceptions.
มุมมอง 2.3K10 หลายเดือนก่อน
This video was inspired by this one from @ThePrimeTimeagen: th-cam.com/video/YZhwOWvoR3I/w-d-xo.html. Please watch it will the end! In this video, I want to talk about alternatives to #exceptions in #typescript. There are ways to make the #code more #resilient and easier to #maintain by implementing better #error #handling on both #backend and #frontend. Most importantly though, exploring new #...
Rescript course introduction
มุมมอง 57611 หลายเดือนก่อน
In this episode, we'll look at the #rescript website, package listings and the Rescript Association. #rescript #frontend
Rescript course, episode 3: starting a #rescript project using the #npm template
มุมมอง 45811 หลายเดือนก่อน
In this episode, we'll create a new #rescript project using the #npm template. #rescript #frontend #javascript #typescript
Rescript course, intro
มุมมอง 1.1K11 หลายเดือนก่อน
Hi, My name is Ivan, I am a software developer. These days, I primarily use TypeScript to build applications that run in the browser, on the server or on the desktop. But I've always been fascinated by the beauty and power of strictly typed functional languages. Some of the ideas from these languages are slowly being adopted by what are considered mainstream languages, such as JavaScript or Typ...
Rescript course, episode 2: starting a #rescript project from scratch
มุมมอง 66611 หลายเดือนก่อน
In this episode, we'll look at how to start a#rescript project from scratch. This will also give you an idea of how to add Rescript to an existing #javascript or #typescript project. #rescript #frontend #javascript #typescript
Rescript course, episode 4: type system overview, control structures, algebraic data types
มุมมอง 48811 หลายเดือนก่อน
In this episode, we'll take a closer look at the #rescript type system, control structures, how they differ from #typescript and learn about algebraic data types. #rescript #frontend
Rescript course, episode 6: modelling an app as a state machine
มุมมอง 22311 หลายเดือนก่อน
In this video, we will use the previous example to explore building a state machine in Rescript, and how it works with the Reducer pattern. #rescript #frontend #statemanagement
Rescript course, episode 5: fetching and parsing JSON, safety
มุมมอง 44711 หลายเดือนก่อน
In this episode, we're going to #fetch some data from an end-point and make sure we can handle unexpected responses gracefully. #rescript #frontend
Great video, very intriguing. Would love to see you building an app with Elm in a next video!
Thank you, Timo, for your kind words! Looking forward to it too :)
I couldn't figure out the purpose of using neverthrow or the idea behind this approach. There was no information about it in the project repository either. Then I came across your video, and everything immediately became clear. Thank you!
I'm glad it was helpful! The important thing it to understand the principle, the library you use is not that important. Heck, you can implement the Result type on your own too! ;)
@@BeyondTypeScript Yea! You are totally right
Recommend you switch to `neverthrow` as `ts-results` is unmaintained
Thank you for the suggestion! Indeed, there are lots of alternatives to `ts-results`.
I like the idea of Either/Result types, because it clearly separates what is happy and sad path. However, I am curious your thoughts of just returning original value type and an Error? For example, safeParseInt would return int | Error vs Result<string, Error>. I have been littering code bases with this and it has proven useful, and I am actually not sure when it would be desired or wanted to return an Error type in the happy path, so I don’t see the benefit of separating the sad path out. Is there other benefits to wrapping in Result type I don’t see?
Thank you for your comment! Generally speaking, for safeParseInt there are indeed just two outcomes - either int or Error (with only one possibility for sad path - 0). So, it's okay to return int | Error. However, the Result type help to turn a partial function (not defined for all inputs) into a total function (defined for all inputs), by returning a value of type Result<V, E> instead of int (for example). Notice that the Result type takes two generics - Result<Value, Error> and can be constructed in two ways - Ok<Value> or Err<Error>. However, the Error generic can hold another ADT for all possible outcomes (in more complex cases). For example, a file system operation can fail for a number of reasons - all of them can be defined as an ADT (by the way, same is true for the happy outcomes). This situation would be a bit cumbersome to describe without any differentiation mechanism - int | FileNotFound | BadPath | FileLocked | Whatever. Compare this to Result<int, FileSystemError>. On top of that, sometimes, there are cases where your function may return int | int - but which one is which? All in all, I'd say that it's a good practice to stick to a single code style - either throwing exceptions, or int | Error, or Result type. Mixing them will lead to confusion in the team. However, if I have a choice, I always use the Result type. I hope it all makes sense :)
Amazing video. Short and straight to the point.
Thanks for the video, completely agree on the topic. Just wanted to point out that there is no need to use a library. It's enough to return a discriminated union type like Response<T> = { type: 'error', reason: string } | { type: 'success', data: T }
Completely agree!
Thank you! ❤❤❤
can you create full rescript course
I appreciate your comment, thank you! Yeah, that the goal.
Haven't checked this out since Bucklescript. I really like the pipe feature, having gotten used to that (and pattern matching of course!) with Elixir. The main question I have is how does it interop with untyped/loosely typed json. My ibgib protocol is itself an ML so to speak (DLT with time as 1st class citizen, think git but more generalized as an explicit meta language use case), and the hiccups I run into with compile time languages is the difficulty of data casting/coercion. Rescript could be interesting since it is still eventually running on a js interpreter, so I am wondering if that might make it feasible for my use case.
I've learned a lot from your comment, thank you! 🙏 You are right, you can compile Rescript code into JS code. However, the compiler performs type checking, and Rescript is a language with strong typing. Therefore, type coercion is impossible. You'll need to write mapping functions. Examples of such functions are "Int.toString" or "Int.fromString". It may sound like a lot of work, but this way, if it compiles, it is correct. Also, you'll need to prove to the compiler that the data coming into your program is what's expected (think decoders). Thank you for your comment and I hope it helps!
@effect/schema is a good example of powerful and safe type coercion at runtime (encoder/decoder pattern).
ReScript really needs to start taking over from TypeScript
I get your point. The good thing is that both can co-exist too, we don't have to choose either or. Rescript is a tool to get the job done. Most importantly, we can learn the differences between type systems, ecosystem, etc. These new ideas alone will help make better choices and decisions in the future.
Have you had a chance to get acquainted with the "ts-belt" library? This is a library for TypeScript providing Option & Result types, but also other flavors from functional programming. And most interestingly, the source code of this library is written in Rescript! :)
I didn't know about this library, thank you for sharing! But as I read ts-belt, the first thing I thought about was Rescript's Belt :) I'll give it a go.
Друже, радий бачити і чути! Лайк, підписка і дзвіночок :)
you rock
🚀