It's such a great pattern when implemented well, for sure
@hypernarutouzumaki7 күн бұрын
What about unicode strings? How are they stored?
@IsaacHarrisHolt7 күн бұрын
They're still sorted as arrays of UTF-8 codepoints, the same as any other string. The std.unicode package in the standard library has functions for wrangling unicode strings, and I believe you can have it output a u21 for a unicode codepoint, as that's enough to cover the entire unicode space. There are some really good articles online you can look at if you want more info :)
@kacaii7 күн бұрын
More zig videos pls 🙏
@IsaacHarrisHolt7 күн бұрын
It's pretty cool, right! Though it's not particularly likely I'll be doing more Zig at the moment - I'm pretty focused on Gleam
@classic-259 күн бұрын
Brain overload🤯🤣 5:52
@IsaacHarrisHolt8 күн бұрын
💯
@potatoes_fall9 күн бұрын
I wish this video spent less time writing code and more explaining why gleam is superior for this use case. The example can be built in any language. I may not be the best listener but I wasn't able to understand how Gleams special feature make it suitable as a redis replacement.
@IsaacHarrisHolt8 күн бұрын
Fair criticism! As for that, the short answer Gleam has some really great ways of having in memory kv stores thanks to Erlang and the BEAM. The long answer is a little more complicated, and one for research :)
@benarcher3729 күн бұрын
What a horrible syntax
@IsaacHarrisHolt9 күн бұрын
Thankfully syntax is just surface level, and quite easy to get over once you start using the language in earnest!
@AsbestosSoup10 күн бұрын
I love what Zig is bringing to the table, offering C-like performance with more modern features... but wow the syntax is awful
@IsaacHarrisHolt9 күн бұрын
Thankfully syntax is something you can get over pretty quickly when learning a language
@Towhidn10 күн бұрын
A rare no-fluf guide with short and clear style. I wish more content creators emulated this. 👍
@IsaacHarrisHolt10 күн бұрын
Glad you found it useful!
@araozu11 күн бұрын
One thing that you didnt mention about the difficulty of learning gleam/rust is pure fp. Not being able to do a loop and instead doing recursion is the first that comes to mind, but really everything changes from other languages, its a completely new paradigm. And id say that may even take as much time as learning to fight the borrow checker
@IsaacHarrisHolt11 күн бұрын
That's a fair point, but as someone who writes both languages a lot and spends time in the community, I can say that that's not generally true for people. And if recursion is something you struggle with, I have a great video on the topic 😉
@jonnyso111 күн бұрын
I generally agree with your point but I think people making the productivity vs performance argument often underestimate how productive you can be in Rust. You can get started sooner in simpler languages, which is valuable, but once you get going with Rust the difference in productivity is a lot smaller than its made out to be, and it depends a lot on the type of problem you're dealing with. Rust isn't THAT complex.
@IsaacHarrisHolt11 күн бұрын
As someone who writes Rust for work, I don't _totally_ disagree with you, but it's not just about actually getting the code on the page. The long compile times lengthen the feedback loop (even with caching etc.) and deploying Rust is a real pain in the ass most of the time. Dockerising it is never as simple as it should be.
@jonnyso111 күн бұрын
@@IsaacHarrisHolt You're right, but those aren't really fundamental language design problems, such that you didn't even mention them in your video. These are things that are being worked on and that are likely to improve with time, unlike something like lifetimes which does make the language more complex and also is not going away. That also assumes everyone would be using the same type of environment as you, I don't use docker for instance, a self contained binary is easy enough to deploy. Still I don't believe that Rust will ever reach a state that your point isn't at least technically true.
@pippabrooks216211 күн бұрын
The whole video I can't help but think: Move Zig, for great justice!
@IsaacHarrisHolt11 күн бұрын
Zig is good!
@MiningForPies11 күн бұрын
Turned off the moment you showed the pricks from top gear
@IsaacHarrisHolt11 күн бұрын
I'm happy for you. It was just a meme.
@MiningForPies11 күн бұрын
@ and its use told me all I need to know.
@bibliusz77711 күн бұрын
don't show yourself. don't include ads
@IsaacHarrisHolt11 күн бұрын
1. Yeah, sorry, I'm pretty ugly, right? 😁 2. I've got to be able to support making this content somehow. I don't have unlimited free time, so I have to prioritise. Would you rather have a video with a 30-60s ad or no video at all?
@bibliusz77711 күн бұрын
@@IsaacHarrisHolt 1. it's noise. i prefer minimalism 2. yeah, but it makes saving and recommending a video hard
@IsaacHarrisHolt11 күн бұрын
Fair enough. I'd rather produce videos with minimalistic animations to explain the points I'm making, like CodeAesthetic or aarthificial. Unfortunately, I have neither the time, skills, nor time to learn the skills to make that happen, and finding someone who can animate well enough to achieve what I want, but also understands the concepts of the videos well enough to not need hand holding all the time, is next to impossible. And there are sponsor segments in a huge amount of videos these days. They're what allow creators to put time, effort and money into their videos. That said, you can skip them, or just not watch the video in the first place.
@bibliusz77711 күн бұрын
@ Btw, can you recommend a job? I use Rust, Gleam, Haskell, Elm, Nix. The direction I want to take is data science, game theory and genetics. Currently I am learning how to frequently find value bets, since now main priority is earning several million so I can own a business so I can do my research on how to give advantage to children. My goal is to be an ancestor to last life, since I realized that life depends on low entropy and it seems to grow globally :D
@bibliusz77711 күн бұрын
@@IsaacHarrisHolt Btw, can you recommend a job? I use Rust, Gleam, Haskell, Elm, Nix. The direction I want to take is data science, game theory, genetics. Currently I am learning how to frequently find value bets, since I want to earn several million so I can own business so I can do my research on how to give advantage to children. My goal is to be an ancestor to last life, since I realized that life depends on low entropy and it seems to grow globally :D
@RoyaltyInTraining.12 күн бұрын
Snake case for variables and camel case for functions immediately pisses me off. What if I want to take in a function as an argument?
@IsaacHarrisHolt12 күн бұрын
It's probably my least favourite part of Zig. That said, you would always just write all your function names in snake case and deal with the fact that library functions will be camel case
@anotherelvis13 күн бұрын
Great video
@IsaacHarrisHolt13 күн бұрын
Thank you!
@Br4dButt0wski14 күн бұрын
how suitable it would be for graphics or game dev stuff in your opinion?
@IsaacHarrisHolt13 күн бұрын
I can't really answer your question I'm afraid. Performance-wise, fine! People wrote games in all sorts, including JavaScript and Lua, so it depends on the complexity of your game. It'll mostly come down to tooling, and I don't know enough about that.
@Hooorse14 күн бұрын
Ok, Gleam is not Rust, but surely it's Go.
@IsaacHarrisHolt14 күн бұрын
Gleam is definitely like a functional Go!
@danser_theplayer0115 күн бұрын
No threads in gleam? That's crazy, won't catch me doing this in javascript. "Effortless concurrency" hah.
@IsaacHarrisHolt15 күн бұрын
The BEAM VM (and therefore Gleam) uses 'processes' which are essentially green threads and can be thought of as analogous to Go's goroutines. The only difference really is the 'shared nothing' architecture whereby each process has its own memory and call stack.
@franklin.gamaral15 күн бұрын
Like only by title hahaha
@IsaacHarrisHolt15 күн бұрын
Haha thank you!
@danser_theplayer0115 күн бұрын
The async meme comes from people who have no clue how promises work and why they have to be that way.
@IsaacHarrisHolt15 күн бұрын
I totally get why futures and future-likes have the function colouring problem, my point is mostly that it's not the only concurrency model that exists. People do tend to think of it by default, though. Promises work great for single-threaded systems that can only achieve background work by polling, but they're overkill when you have green threads/processes. They also can't work in a totally immutable system
@IAmSamuelCharpentier16 күн бұрын
5:40 calling supper will call any methods of the extended class or parent class that has the same name as the current method. So yes, super() in the constructor calls the parent class constructor. But super() in the method train() will call the train() method of the parent class.
@IAmSamuelCharpentier16 күн бұрын
Oops, that’s Typescript, sorry!
@IsaacHarrisHolt15 күн бұрын
No worries!
@IAmSamuelCharpentier16 күн бұрын
5:00 you name an anonymous function using const to make out a constant.
@IsaacHarrisHolt15 күн бұрын
I don't understand what you mean here, sorry
@VarunG-y6p16 күн бұрын
i want to do side projects in gleam but idk where to start, i tried following your video on lustre but i got a bit lost after a point. I am new to gleam im finding it hard to understand the elm architecture.
@IsaacHarrisHolt16 күн бұрын
Join the Gleam Discord! Loads of people there who can give you help
@VarunG-y6p16 күн бұрын
@IsaacHarrisHolt okay thanks for the info. Will do.
@TheOlian0417 күн бұрын
THIS is the kind of gleam videos we need! More of this please :)
@IsaacHarrisHolt17 күн бұрын
Of course!
@khai96x17 күн бұрын
What are the advantages of phantom type parameters over new type wrappers?
@IsaacHarrisHolt17 күн бұрын
You can make generic functions with them across many different phantom types. For example, with the `Distance(a)` type, I could write: `fn add(dst1: Distance(a), dst2: Distance(a)) -> Distance(a)` Then I could add ANY two distances, as long as they have the same phantom type. If I was using new type wrappers, I'd have to have an add_miles, add_kilometres function, etc. Also, phantom types have no runtime overhead, as they're compile-time only.
@AGeekTragedy17 күн бұрын
Any video discussing strongly typed physical units/quantities is an automatic like from me. How easy is it in Gleam to have it work out the correct return type of (say) dividing a quantity in metres by a quantity in seconds?
@IsaacHarrisHolt17 күн бұрын
Very easy! Phantom types are just generic type parameters at the end of the day. `fn calculate_speed(dst: Distance(a), time: Time(b)) -> Speed(a, b)` You'd have to write it as a function though, and have a `Speed(a)` type. You wouldn't be able to just use primitive operators (which makes sense as `Distance` and `Time` aren't primitives)
@adtc17 күн бұрын
That was... A LOT! 😵💫
@IsaacHarrisHolt17 күн бұрын
Hopefully it was helpful!
@ivymuncher17 күн бұрын
the camera fix is looking good!!
@IsaacHarrisHolt17 күн бұрын
Thanks!
@Biriadan17 күн бұрын
You can get this concept to dynamically typed languages as well! Clojure supports metadata on elements, which can contain units of measure, provenance, etc. The book Software Design for Flexibility leverages metadata in scheme to implement an automatic type conversion system.
@IsaacHarrisHolt17 күн бұрын
Interesting! I don't know how many languages are likely to support it, but that's pretty cool
@josealonso732117 күн бұрын
I think Kotlin also has this construct, but it is not called I like that.
@IsaacHarrisHolt17 күн бұрын
Phantom typing is just the generic name for the concept. Languages may have their own names for sure
@BlueishSapphire717 күн бұрын
Amazing video, I had never heard of phantom types until now. A small suggestion, it would be helpful if you zoomed in on the code a little more in the video because it was very hard to see on mobile
@IsaacHarrisHolt17 күн бұрын
Thanks for the feedback!
@ballackuk1317 күн бұрын
I'm sure most of the time we care about runtime bugs, thats why we do testing
@IsaacHarrisHolt17 күн бұрын
Sure, but another tool in your belt is always helpful!
@taquanminhlong17 күн бұрын
Now I can finally understand the rust phantom type here 😂😂😂
@IsaacHarrisHolt17 күн бұрын
Awesome! Glad this was useful
@khai96x17 күн бұрын
Phantom types in Rust are necessary only because sometimes types need extra information to pass to trait impls. I'm pretty sure they weren't made with typestate/newtype pattern in mind.
@IsaacHarrisHolt15 күн бұрын
They can absolutely be used as phantom types. There's a good talk somewhere on type driven API design in Rust that uses a similar concept.
@IsaacHarrisHolt15 күн бұрын
They can absolutely be used as phantom types. There's a good talk somewhere on type driven API design in Rust that uses a similar concept.
@boscodomingo17 күн бұрын
These are basically ValueObjects...
@IsaacHarrisHolt17 күн бұрын
I'm not totally sure what they are! Are they a language-specific thing?
@Antash_17 күн бұрын
@@IsaacHarrisHolt ValueObject is a name often used in Domain Driven Design, and it describes a concept of creating classes/concepts/types (depending on the paradigm) that wrap primitive types, so instead of using a float, one would create a (for example) Measure class that would wrap a raw float. It's basically a design pattern to fight "primitive obsession", so the goal is the same, but it's in runtime, and allows to have for example methods that would allow adding Miles to Kilometers but with proper conversion ;)
@antoniong438017 күн бұрын
I might not understand what you mean. It doesn't feel like you could achieve Compile-time checks with this strategy
@Antash_17 күн бұрын
@@antoniong4380 You do. Instead of using some phantom types, just just use normal types. The disadvantage is that it can be a lot of boilerplate, as you now have a full type, so in places where you need a float (for example in some library you're using) you cannot directly use your own type, but must do a conversion, or break encapsulation, something like that.
@boscodomingo17 күн бұрын
With ValueObjects you could achieve compile-time checks as well since you can make methods that only take said classes, thus forbidding certain unwanted behaviours. For example, I could make a value object for Email, and validate that the string provided is not empty, has a certain length and matches my email regex. With that, I know that anytime I'm using an Email elsewhere, I don't have to check for such things. Thus any code that relies on them can work based off those assumptions at runtime, and leverage their properties/methods at compile time
@blinklight17 күн бұрын
Please complete 💯 subscribe 😢
@MrMysticphantom17 күн бұрын
As someone who develops monitoring systems, CRMs, ERPs and ticketing systems this is hitting very very close to the pain i normally deal with. Many programmers sadly really underestimate the importance of business logic flaws, let alone making phantom types or similar mechanisms to restrict behavior.
@IsaacHarrisHolt17 күн бұрын
Yeah, it's definitely one of those "be the change you want to see" things. If you can start implementing them in the bits of the codebase you own, you may be able to start convincing people through the organisation to use them
@applimu799217 күн бұрын
Phantom types look similar to dependent types!
@IsaacHarrisHolt17 күн бұрын
Phantom types are probably closer to branded types. Dependent types usually require the compiler to know something about the actual runtime value (e.g. my dependent type is only EVEN numbers) whereas phantom types are effectively user-assigned tags.
@reo10117 күн бұрын
@@IsaacHarrisHolt In the dependent-type world you could have Open and Closed be the constructors of a single enum-ish type, restricting the "type of the type" of File to be just one of those two (and not an unrestricted type). If I understand it correctly, Gleam has only 2 "levels" of "stuff" - values and types, with no way to differentiate different types (noone can stop me from working with a `File(File(Int))` or something. One might say that the "type of types" (the type of stuff you can put in `File(here)` is "Type" and not something more specific, i.e. the type of types is an "open type", in contrast with a closed one (like a hypothetical enum).
@IsaacHarrisHolt17 күн бұрын
Interesting. Seems I need to do more research into type theory 😅
@deedit466615 күн бұрын
That was my immediate thought aswell. I wrote my Bachelorthesis about verifying a prgramming language using Coq and learned a lot about dependent types in the process. Although Phantom Types are more restricted than dependent types.
@IsaacHarrisHolt18 күн бұрын
The first 500 people to use my link skl.sh/isaacharrisholt01251 will get a 1 month free trial of Skillshare!
@sunofabeach942418 күн бұрын
bruh it's not Polars
@IsaacHarrisHolt18 күн бұрын
That's correct
@mjpthetrucker948519 күн бұрын
People complaining about the speed of speech when you can literally slow the video down.💀💀💀💀 I do it on videos whether there is fast speech or not. Helps with comprehension. Try it, folks. Thanks for the video!
@IsaacHarrisHolt19 күн бұрын
In fairness, this one probably is a little fast 😅 I've tried to slow down more recently. Thank you, though!
@pixsa20 күн бұрын
OK, Do a performance benchmark then !
@IsaacHarrisHolt20 күн бұрын
Comparing what? At what scale? Between which languages? What are we measuring and why is that important? What are we measuring? It's never as simple as just "do a performance benchmark".
@MagnusNemo-xc5nx20 күн бұрын
It's for soy devs
@IsaacHarrisHolt11 күн бұрын
I'm only a soy dev because lactose makes me gassy 🤷♂️
@kunou452721 күн бұрын
In my experience "there has to be a better way" is often a skill issue. Case in point; systemd.
@IsaacHarrisHolt21 күн бұрын
"Better" can sometimes mean "wastes less of my time to configure". Sure, call it a skill issue, but if something keeps me from working on the truly important things, and there's another tool that'll let me achieve the same thing faster, I consider that better.
@kunou452720 күн бұрын
@@IsaacHarrisHolt I wouldn't call that case a skill issue. It's just not the primary reason for that mindset of reinventing the wheel. Your case is the exception to the rule.
@va9iff21 күн бұрын
how long does `use` goes down? to the end of the scope?
@IsaacHarrisHolt21 күн бұрын
Yep!
@__vyre22 күн бұрын
not a huge fan of the syntax, but holy fuck the overflow operator is peak
@IsaacHarrisHolt22 күн бұрын
I think syntax is a hurdle you can get over pretty quickly. Give it a shot!
@Biriadan22 күн бұрын
I feel like you could get the behavior you want with speak and keep it purely functional by using multi-methods. Imo, OOP feels for the most part like a very constrained subset of the ideas from FP. It provides a less complete solution to encapsulation, less complete runtime polymorphism model, and a less complete abstraction model. Even when I was learning OOP in school I never really bought into it or did it because it always felt logically messy and oddly specific to me. FP is such much more holistic that once I found it I knew it's what I'd been looking for for a decade at that point.
@IsaacHarrisHolt22 күн бұрын
There are definitely plenty of different ways to write all of this! And a lot of this will depend on the language you're writing, too. Not every one is set up to be able to replicate this nicely, though it does seem we're heading more towards functional and "post-OOP" based on which new languages are becoming popular
@danser_theplayer0123 күн бұрын
comptime sounds like *eval* but for compile insted or runtime, neat.
@IsaacHarrisHolt23 күн бұрын
It's great
@danser_theplayer0123 күн бұрын
"If and loops and switch can be used as expressions" goddamn, I might want to leave easy to write js and try zig for a hot minute.
@IsaacHarrisHolt23 күн бұрын
Honestly having everything as expressions is one of my favourite languages features, be it in Zig, Rust or Gleam!
@diggus8824 күн бұрын
6:29 I think that should be "if (!HUNGRY)", not "if (HUNGRY)".
@IsaacHarrisHolt24 күн бұрын
You're right, thank you!
@Giona_226 күн бұрын
As a Rust user, I have to agree the "rewrite it in Rust" movement was definitely a mistake. I think what a lot of people don't understand is that coding languages are entirely situational by definition, as a coding language is just a specific interpretation of abstraction of machine code. Sure, a language like C is technically "general purpose," but how many people are making LLM's in C? How many do you think are writing embedded firmware (not counting the RPi Pico) or system drivers in Python? You know? Rust is great for a lot of reasons, but it's not an end-all-be-all. Nothing really is.
@IsaacHarrisHolt26 күн бұрын
This is a great take. These days we're also seeing more and more specialist programming languages and fewer "general purpose" ones, and I think that's fine! Alternatively, we see languages like Gleam which can compile to different backends depending on the use case you're targeting.