Ocaml Becomes Rust w/ Garbage Collection?

Поділитися
Вставка
  • Опубліковано 29 вер 2024
  • Recorded live on twitch, GET IN
    / theprimeagen
    TJ: / teej_dv
    twitch: / teej_dv
    MY MAIN YT CHANNEL: Has well edited engineering videos
    / theprimeagen
    Discord
    / discord
    Have something for me to read or react to?: / theprimeagenreact

КОМЕНТАРІ • 212

  • @edz8659
    @edz8659 Рік тому +417

    I love ocaml (I have never used it)

    • @vaisakhkm783
      @vaisakhkm783 Рік тому +14

      😂 ikr

    • @SimGunther
      @SimGunther Рік тому +45

      That sums up the language landscape:
      Languages you love and languages you use extensively are (for now) mutually exclusive.

    •  Рік тому +1

      I came here to say the same and you were first!

    • @RenderingUser
      @RenderingUser Рік тому +6

      Same (I have never heard of it)

    • @VivekYadav-ds8oz
      @VivekYadav-ds8oz Рік тому +3

      @@SimGunther except ofcourse Rust.

  • @itacirgabral1687
    @itacirgabral1687 Рік тому +3

    the beginning of a beautiful friendship

  • @HyperFocusMarshmallow
    @HyperFocusMarshmallow Рік тому +3

    I recall a few years back when apple lived in Objective-C land and did reference counting using retain and release (and maybe auto release or something). And I remember finding that paradigm so much more simple and elegant than just pretending like things will be just fine, like in languages with a garbage collection only model.
    But even there you had some data structure whose name I don’t recall, some NS…Pool maybe. I really don’t remember. And you’d construct it and let it do garbage collection. It was a garbage collector.
    I haven’t thought too hard about it but if you really really need garbage collection isn’t there just some crate for it. Maybe that doesn’t end up sufficiently optimized or something.
    But I just don’t think that’s the kind of thing that needs to be baked into the language. I mean, it’s fine if it it’s, but if you don’t have it you can opt in right.

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому

      I found, while trying to interop with obj-c from Rust, that the docs for autorelease to be absolutely hilariously garbage. There's basically no actual explanation of what it actually does, just vague guides for using it from obj-c, and you're as l occasionally forced to use it with some APIs. Fun times!

    • @HyperFocusMarshmallow
      @HyperFocusMarshmallow Рік тому

      ​@@SimonBuchanNz I honestly don't recall. Did you manage to figure it out?

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому

      @@HyperFocusMarshmallow I think I ended up just letting everything leak, which is fine for the specific case where nothing was in a loop.

  • @heitorvrb
    @heitorvrb Рік тому

    was this guy sitting on a bouncing ball or something?

  • @tobyzieglerrr
    @tobyzieglerrr Рік тому

    Ok, roast me, i like Java and i like Rust. I do not like OCÄML

  • @atiedebee1020
    @atiedebee1020 Рік тому +368

    Im so proud how far programming languages have come, finally local variables

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +89

      its amazing

    • @zsh7862
      @zsh7862 Рік тому +9

      lua? or am i missing smth, i dont know too much about it

    • @Poem-Tree
      @Poem-Tree Рік тому +25

      @@zsh7862its sarcasm

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому +23

      ​@@zsh7862for reference, local variables have been a thing since the creation of structured programming in the mid 50s.

    • @complexity5545
      @complexity5545 Рік тому +1

      @@SimonBuchanNz This rebuttal made me chuckle.

  • @RemcoJvGrevenbroek
    @RemcoJvGrevenbroek Рік тому +63

    fun fact!....... The first rust compiler was written i oCaml

  • @EricSampson
    @EricSampson Рік тому +13

    C# and F# let you do explicit stack allocations, re your comment about not knowing any GC langs that do

  • @josevargas686
    @josevargas686 Рік тому +37

    ThePrime: you cannot have the same great communication while working remotely as you do in an office.
    Also ThePrime: most greatest communication with TJ while reading overly complex technical articles.

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому +2

      I'd say it as "the one person working remotely can't have the same great communication as the rest of the team working in the office", which I also think is too strong (I think it's more "it's harder" than "can't"), but is compatible with streaming

  • @robertlenders8755
    @robertlenders8755 Рік тому +30

    F# is the daughter of ocaml and has had possibly stack allocated values with structs and guaranteed stack allocated values with byreflike for a few years now.
    Local looks interesting though as it seems like it can be applied to existing types rather than declaring a new one.

    • @complexity5545
      @complexity5545 Рік тому +6

      I'm not a windows guy, but when I do its C# and F# (and some C++). F# is a really good language.

    • @metaltyphoon
      @metaltyphoon Рік тому +11

      @@complexity5545c# and f# hasn’t been a “windows only” thing for more than 7 years

    • @LSM07
      @LSM07 Рік тому +6

      F# will always be underappreciated, unfortunately. But yes, the CLR allows for both unsafe and stack allocated stuff and has for some time. I wouldn't be surprised if they added lifetime-like annotations at some point to F#, too (which will, inevitably, be added post-hoc to C#).

    • @meowrbius
      @meowrbius Рік тому +1

      @@complexity5545 How did you learn F#. Why there are no resources for it?

    • @Eugensson
      @Eugensson 5 місяців тому

      ​@@meowrbiusthere is a lot of info by Don Syme, also an awesome series of articles "F# for fun and profit".

  • @metaltyphoon
    @metaltyphoon Рік тому +47

    If prime’s pride didn’t blind him, he would see how F# is real world pragmatic OCaml

    • @xbmarx
      @xbmarx Рік тому +2

      F# doesn't have modules/functors like OCaml though. It's basically just alternative syntax for C#

    • @metaltyphoon
      @metaltyphoon Рік тому +8

      @@xbmarx Nice try but no. F# is pragmatic functional language. Things that F# has where OCaml doesn’t:
      1) Computational expression
      2) Perf abstraction ( stackalloc in this video)
      3) Anonymous Records
      4) Library ecosystem OCaml dreams of
      5) Slices and Ranges

    • @abuk95
      @abuk95 Рік тому +5

      @@metaltyphoon but it is from microsoft ecosystem, so that is a dealbreaker

    • @metaltyphoon
      @metaltyphoon Рік тому +7

      @@abuk95 oh so you want to be a SJ warrior, how about not using any GNU tools since Stallman sexual allegation? Guess what? You probably didn’t think twice and still use it. MS is not the same company from from 2 decades ago so stop pretending it is.

    • @nicolaspace1182
      @nicolaspace1182 Рік тому +2

      @@metaltyphoonMicrosoft is still as evil as ever, but that doesn’t mean you shouldn’t use their tools. If the man who invented the hammer was a murdering psychopath, would you then never purchase a hammer?

  • @confusedbystander2898
    @confusedbystander2898 Рік тому +49

    Very interesting. Gives of 'highly admired - barly desired' vibes for me.
    Not for Tom though ...

  • @rapzid3536
    @rapzid3536 Рік тому +14

    Would love a series exploring F#

    • @WillEhrendreich
      @WillEhrendreich Рік тому +1

      I approve this message.

    • @DMSBrian24
      @DMSBrian24 Рік тому

      F# is a microsoft thing, in the functional world i'd say learn Elixir if you're fine with dynamic typing and if you want static, go with Haskell or Ocaml

    • @absolutejam
      @absolutejam Рік тому +10

      ​@@DMSBrian24 what a narrow minded view 🤷‍♂️
      F# is an amazing language, has a rich ecosystem and performant runtime. And computation expressions are one of the greatest language features ever.
      But Haskell, Scala, Clojure, Elixir are all great. We shouldn't be limiting our world view based on surface level points. Try them all and evaluate them on their merits.

    • @lepingouindefeu
      @lepingouindefeu 3 місяці тому +1

      ​@@DMSBrian24 L take.

  • @casperes0912
    @casperes0912 Рік тому +51

    I've written a decent bit of OCaml at university. We used OCaml to make a compiler for example. I also wrote a weak memory checker with OCaml (for C11's Release-Acquire semantics) as well as CRDTs. It has its ups and downs. If you don't type annotate it, you can get horrid compiler errors

    • @meli-overwatch9298
      @meli-overwatch9298 Рік тому +1

      are you from tum?

    • @vikingthedude
      @vikingthedude Рік тому

      This guy wrote CRDTs. I just learned about them last month. Damn

    • @MaxHaydenChiz
      @MaxHaydenChiz Рік тому +2

      Have you used Haskell for similarly complex problems? I'd be curious of your opinion on how they compare.
      Personally, the main reason I like OCaml over Haskell is that the type inference is always decidable. So for CLI apps and other ordinary systems programming stuff, you need less manually written types (and can have the tooling just output your types into a file for you). And then for complex stuff, I tend to have fewer problems if I need to do complicated type system stuff (at least up to the point that having higher order polymorphism and the rest actually reduces code complexity; some stuff is just painful to do by hand without the help, from the Haskell compiler.).
      I've been meaning to experiment with using Coq and dependent types for those hard type-level problems. I'm told the ergonomics have gotten way better recently, and I really enjoyed the cleanliness of Idris over all the not-quite-dependent advanced types that Haskell supports.

    • @casperes0912
      @casperes0912 Рік тому

      @@meli-overwatch9298 what’s tum?

    • @casperes0912
      @casperes0912 Рік тому

      @@vikingthedude it was a project I took part in at university. Ultimate goal is for the implementations to be formally verified

  • @diadetediotedio6918
    @diadetediotedio6918 Рік тому +7

    16:00
    C# can alloc on the stack, either by using structs or for arrays by using stackalloc type_str_unmanaged[length]

  • @TroubleChute
    @TroubleChute Рік тому +1

    Woah may have been your 100,000th subscriber 👀Let's go

  • @xbmarx
    @xbmarx Рік тому +14

    Jane Street is also working on unboxed types in OCaml. Exciting language.

  • @SimonBuchanNz
    @SimonBuchanNz Рік тому +8

    Co- and Contra- variance is mostly confusing because it's not actually subtyping, but relations between subtyping relations between types. Which is a word salad that is much easier to describe with an example:
    For some generic Foo, there may be a subtype relationship between Foo and Foo, but it may be:
    * returning a T, in which case Foo is a Foo, which is covariance, or
    * it may take a T, in which case Foo is a Foo, which is contravariance, or
    * it may do both, in which case neither is a subtype, which is invariance.
    * it may even do neither, which means either may be a subtype of the other, which is bivariance! (In practice this means either they are actually the same type or it's unsound)
    The variance relation isn't a relation on the Dog or Animal, or even any of the Foo types: it's a relation on Foo instances to the T parameter: contra- if the subtypes go in the opposite direction, co- if they go in the same.
    The relation to function types is clearer when you look at them as being a fancy syntax for a generic: (A) -> R is basically just Fn.

  • @marble_wraith
    @marble_wraith Рік тому +6

    I'm influenced... OCaml is gonna replace Rust. Dang it!

  • @carlpittenger
    @carlpittenger Рік тому +13

    other than for example java primitives, the only garbage-collected language i'm aware of that lets you do stuff with the stack is c#: structs are inlined or on the stack, classes are on the heap. admittedly though, i'm not too familiar with modern c#.

    • @blade2663
      @blade2663 Рік тому +1

      Golang also

    • @Imaltont
      @Imaltont Рік тому +1

      Common Lisp can also, though exactly how it is done depends on the CL implementation.
      Edit: DYNAMIC-EXTENT in the hyperspec is what allows it, implementations that focus on performance such as SBCL does utilize it.

    • @mkwpaul
      @mkwpaul Рік тому +2

      Classes in C# are always allocated on the heap, no matter what.
      Where structs are allocated depends on how they are used.
      If you have a struct field on a class, then that struct is allocated with the class instance, on the heap, it is embedded in its parent.
      if you have a local variable with the exact struct type so:
      int x = 0;
      However C# automatically and silently boxes (i.e. creates a heap-allocated copy) whenever needed. Like for example when the type of the variable is object or an interface.
      so if I write the following:
      int x = 420;
      object boxedX = x;
      IFormattable formattableX = x;
      then the 420 is initially only allocated on the stack, but when boxedX and formattableX are assigned, the value of x is copied onto the heap.
      If I have the following functions:
      public void PrintFormattable(IFormattable formattable) {
      formattable.ToString("Format", CultureInfo.CurrentCulture);
      }
      public void PrintFormattable(T formattable) where T : IFormattable {
      formattable.ToString("Format", CultureInfo.CurrentCulture);
      }
      then any non-boxed interger I pass into the first method will be automatically boxed, however it wont be boxed if I pass it into the second method.
      More recent C# versions have added a bunch of language and runtime features that let you do more low level things without unsafe. For example you can now declare a struct as a "ref struct" which will enable compile-time checks to ensure that instances of that struct are only ever allocated on the stack and never "escape" to the heap.

    • @blade2663
      @blade2663 Рік тому

      @@mkwpaul That's exactly how Golang "escape analysis" works
      But with addition to explicit pointers

  • @SimGunther
    @SimGunther Рік тому +17

    Better to oversell a technology than a product, amirite?

  • @liquidsnake6879
    @liquidsnake6879 Рік тому +4

    what is this sudden ocaml hipsterdom, every channel is suddently putting out vids about ocaml lol

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому +1

      Jane Street exerting their sinister fintech power 🤫

  • @sho3bum
    @sho3bum Рік тому +4

    I do ocaml professionally but I'm a junior dev so I suck at most things

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +1

      but you do it professionally! that is amazing

    • @Ottopuncher
      @Ottopuncher Рік тому +1

      That's a skill finding an ocaml position. I wish !

  • @temper8281
    @temper8281 Рік тому +5

    You know what they say. Functional languages have no side effects because no one can understand how to write and run them.

    • @mskiptr
      @mskiptr Рік тому

      guide.elm-lang (dotyouknowwhat) is right there

    • @mskiptr
      @mskiptr Рік тому

      Yay /s I got shadowhammered!

    • @lunafoxfire
      @lunafoxfire Рік тому

      @@mskiptr i see both of your comments

    • @mskiptr
      @mskiptr Рік тому

      @@lunafoxfire The first one wouldn't show up when I was logged out | in incognito mode. Now both are visible regardless
      Eh, YT is weird

  • @sumansaha295
    @sumansaha295 Рік тому +7

    programming languages part a/b/c on coursera was my first exposure to functional programming and ml. Excellent courses btw. At the end of the course the professor said one thing I remember, "Language design until now has all been about what not to do, and I would like to see the future programming languages about what we could do" This course was over 10 years ago, Something I think about when I see the rust borrow checker.

    • @gloverelaxis
      @gloverelaxis Рік тому

      do you remember the professor's name or university? because I took a free online unit with the same structure dated 2019 from Professor Dan Grossman at the University of Wisconsin and it was the best educational experience of my life. he's a phenomenal teacher who happens to have contributed to the design of Rust

    • @sumansaha295
      @sumansaha295 Рік тому +1

      @@gloverelaxis Yup it's him, I agree one of the best courses I have ever taken, but I didn't know he contributed to rust?

    • @gloverelaxis
      @gloverelaxis Рік тому

      @@sumansaha295 ah awesome! yeah it was via the language named some synonym of Cyclone or Tempest or something; can't remember the specific linguistic feature it had that Rust incorporated. i'm so thankful for his work on that course; it totally opened my eyes to thinking about programming in *so* many new ways

  • @muhammedkadirtan3469
    @muhammedkadirtan3469 Рік тому +1

    Duuude, stop bouncing its distracting

  • @MaxHaydenChiz
    @MaxHaydenChiz Рік тому +9

    2 questions for you:
    1. Once you learn the language, are you going to install Jane Street's branch of the compiler to try to play with this stuff while it's in beta? Or are you just excited that it's coming in a future version?
    2. Did the youtube stream you made of the first day of OCaml get posted to one of your accounts? It became unavailable immediately after the stream ended, but I'd like to see the few parts I missed.

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +1

      its on @TheVimeagen

    • @imadetheuniverse4fun
      @imadetheuniverse4fun Рік тому

      @@ThePrimeTimeagen i'm guessing it's better for engagement but man it's hard to follow / find these threads across all your channels 😂

  • @MosiurRahman-dl5ts
    @MosiurRahman-dl5ts Рік тому +5

    The chair has gained sentience.

  • @KevinInPhoenix
    @KevinInPhoenix Рік тому +2

    I use a GCed language that automatically puts local variables on the stack and "escapes" variables to the heap that are referenced outside of the local scope (arguments to functions). That language is Go.

  • @zaneearldufour
    @zaneearldufour Рік тому +13

    I love seeing TJ playing along with your kayfabe

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +7

      ...?
      i never read that article and i am excited about ocaml... unsure about this

  • @WizardofWestmarch
    @WizardofWestmarch Рік тому +2

    I can see a use for local head prepend to a global list if those front values are only useful to that point and below in the call stack and will be thrown away after. Limits your pointer chasing as mentioned before.

  • @teej_dv
    @teej_dv Рік тому +2

    nice

  • @ericbwertz
    @ericbwertz Рік тому +2

    Nice thumbnail -- Prime's OCaml-face.

  • @worgenzwithm14z
    @worgenzwithm14z Рік тому +1

    Dude just learn the st monad /s

  • @holthuizenoemoet591
    @holthuizenoemoet591 10 місяців тому

    what is this OCaml popularity all of a sudden? Its like an sort of Erlang renaissance

  • @mettemfurfur7691
    @mettemfurfur7691 Рік тому +3

    huh?

  • @sck3570
    @sck3570 Рік тому +3

    I dont get it, why all of a sudden we are learning an old(very old) language? what gives?

    • @carlpittenger
      @carlpittenger Рік тому +6

      i believe recent speed-ups, functional programming, interesting type system, etc.

    • @sck3570
      @sck3570 Рік тому +3

      Haskell you say, Yay!

    • @isodoubIet
      @isodoubIet Рік тому +2

      Jane Street single-handedly keeps OCaml alive basically

    • @isodoubIet
      @isodoubIet Рік тому +1

      @@MateuszGrzyb-od9uo There are other functional-ish languages that would be comparably good for that. Ocaml was used because being used at JS keeps it alive.

    • @digitalspecter
      @digitalspecter 3 місяці тому

      Well, it's more recent than Javascript..

  • @Titousensei
    @Titousensei Рік тому +2

    If the compiler can do raise an error for variables declared local that escape, why can't it automatically detect the ones that don't escape and make the decision to allocate them on the stack?

    • @digitalspecter
      @digitalspecter Рік тому

      16:26 it does

    • @Titousensei
      @Titousensei Рік тому

      @@digitalspecter My point was: if it's possible to automate that, why not do it transparently by default and avoid the declaration altogether?

    • @digitalspecter
      @digitalspecter Рік тому +1

      @@Titousensei Because you may want to ensure it is local and compiler to complain if you did something stupid that prevents that.

  • @m0ff607
    @m0ff607 Рік тому +2

    Eschewing?

  • @TheSkepticSkwerl
    @TheSkepticSkwerl Рік тому +2

    For the love of all. Escape has 1 c in it!

  • @amazakee
    @amazakee Рік тому +1

    any good video or article that would help me gain a deep enough understanding of GC for understanding this video?😅

    • @SimonBuchanNz
      @SimonBuchanNz Рік тому +1

      Google "heap and stack" for the gist of allocation in general. For the purpose of this video, GC is just heap you don't have to call free on. Googling "mark-sweep" will give you a general idea of the basic principle.

  • @njnjhjh8918
    @njnjhjh8918 Рік тому +1

    Hell yes, I love both Rust and OCaml

  • @rennelou9717
    @rennelou9717 Рік тому +1

    guys, why don't you try haskell?

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +2

      i want to write something with side effects

    • @rennelou9717
      @rennelou9717 Рік тому +1

      @@ThePrimeTimeagen guys, why don't you use monads?

    • @el_carbonara
      @el_carbonara Рік тому +1

      @@ThePrimeTimeagen prime, haskell is perfect for that

  • @whiskeytuesday
    @whiskeytuesday 9 місяців тому

    This is a local station, for local people

  • @ForsakenDAemon
    @ForsakenDAemon Рік тому

    Types are usually covariant - I need an Animal so I can take a Dog - but function types are often contravariant in their arguments - I need a [function that takes a Dog] so I can take a [function that takes an Animal]. Basically if supertype is a supertype of subtype, array is a supertype of array (array is covariant) but function is like a subtype of function (function is contravariant). Scala taught me something, at least 🤣

  • @sortof3337
    @sortof3337 Рік тому

    As somone who used HOT stack for 2 months. I'll say this --> to my dyslexic and ADHD brain --> rust is much much easier. Like rust is easy af compared to ocaml for me.

  • @KnThSelf2ThSelfBTrue
    @KnThSelf2ThSelfBTrue Рік тому

    Damn people took the [params list here] { do stuff } syntax from Jai and added exclave ho boy

  • @yasscat5484
    @yasscat5484 Рік тому

    adding keywords without a mechanism to keep backwards compatibility is probably a bad choice

  • @Wanderer2035
    @Wanderer2035 Рік тому

    Hey btw my sisters name is Julia do you think I should learn that code?

  • @HaloBolt35
    @HaloBolt35 Рік тому

    TJ and Primeagen remind me of McConnell and Asmongold

  • @alexanderoh1847
    @alexanderoh1847 Рік тому

    c# has value types which are very similar in nature.

  • @carstenrasmussen1159
    @carstenrasmussen1159 Рік тому

    It sounds like what D is doing also with scope and DIP1000

  • @thekwoka4707
    @thekwoka4707 Рік тому

    Single = doing different things is rough...

  • @AlesNajmann
    @AlesNajmann Рік тому +3

    OCaml has a very polished syntax compared to Rust. Just sayin' :P

  • @RogerValor
    @RogerValor Рік тому +7

    I feel like I am the only one who does not get the point of OCaml, it looks like code that tries to get rid of some syntactic annoyances just to introduce so many new ones, that the result just looks like someone really does not want you to read their code.

    • @complexity5545
      @complexity5545 Рік тому

      Boy did you say it.

    • @mskiptr
      @mskiptr Рік тому +1

      As one wise commenter wrote last week _it's just Haskell, but ugly_
      Edit: this is a joke obv

    • @xybersurfer
      @xybersurfer Рік тому +1

      i think that part of the problem here is that all this ugly locality stuff that Jane Street added to their version of OCaml, is giving you a bad impression. it's not normally there

    • @lunafoxfire
      @lunafoxfire Рік тому

      @@xybersurfer absolutely not

    • @RogerValor
      @RogerValor Рік тому

      actually started to learn ocaml just to understand what the hell is going on. who knows maybe i will like it later.

  • @foxcirc
    @foxcirc Рік тому +2

    async rust, 300 dependencies and 4 hours later I just throw it all out and use mio

  • @aftalavera
    @aftalavera Рік тому

    Ocaña is the second most loved language even tough nobody uses it!

  • @neessaa8713
    @neessaa8713 Рік тому +1

    Wait. Wouldn't Lifetimes as part of data type give the language a *spacetime allocator*? 🤔
    Turning the runtime Garbage Collector into an AOT Garbage Compactor, aka a Blackhole? 🥸
    And in this case, wouldn't the "side effects" be the Hawking radiations. causing the Heisenbugs? 🤯

  • @mvargasmoran
    @mvargasmoran Рік тому

    is this the actual TeeJ or is this a fake TJ?

  • @Gabriel-wq4ln
    @Gabriel-wq4ln Рік тому

    100K subs anytime soon

  • @DisFunctor
    @DisFunctor Рік тому +4

    OCaml seems really cool, but from my admittedly limited experience (and please do correct me if I'm wrong), it's missing a key thing that makes or breaks whether a language goes mainstream or not: good tooling. I hope Jane Street invests some more into it (and the good news is they have the financial muscle to do so), because subpar tooling has completely destroyed many a language's chance at escaping the "niche language" status.
    You might say Python tooling is not that great, and you might be right. But Python is also extremely easy to learn and currently being taught at every coding school and University as the introductory language, so you'd be comparing apples with oranges. Languages like Haskell or OCaml have a way steeper initial learning curve.

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +9

      i am 10000000000000000x on your side
      if it doesn't have spectacular tooling, your language sucks (no matter how good it ackshually is). This is why i think rust has gotten so popular is more than the language, but due to cargo

    • @EricSampson
      @EricSampson Рік тому +7

      F# is OCaml with wonderful tooling, just sayin’… 😇

    • @DisFunctor
      @DisFunctor Рік тому

      About variance (learned it through Scala, but I think F[A] would just be syntax for F in Rust and TypeScript, difference just being the type of brackets used):
      say Dog is a subtype of Animal
      type Container[A] is invariant on A, therefore you have no information about the relationship between Container[Animal] and Container[Dog]. They will be considered different types. This is useful if you need something's type to be precise (e.g. you want operations on Container[Animal] to never be combined with operations on Container[Dog]).
      type Container[-A] is contravariant on A, therefore Container[Animal] should be considered a subtype of Container[Dog]
      type Container[+A] is covariant on A , therefore Container[Dog] is to be considered a subtype of Container[Animal]
      As a cheat sheet for remembering one of its most popular use cases: say you want to declare a function with type F[-I, +O], you can see it has two type parameters. From reading the type signature you'll know the function F "consumes" or takes I's as inputs and is meant to output or "produce" O's.
      I believe it's, conceptually the same thing in OCaml. Hope that's somewhat helpful.

    • @ruanpingshan
      @ruanpingshan Рік тому +1

      @@EricSampson I remember being blown away 10 years ago when I tried F# and discovered that Visual Studio let me set breakpoints for individual expressions, not just for a whole line. Was still horrendous to debug though. Turned me off functional languages completely.

    • @meowrbius
      @meowrbius Рік тому

      @@EricSampson I know C# is getting better and better. How is the F# currently going? I wanna start scratching functional paradigm a bit and thought of giving F# a try. How is F# compared to other functional languages?

  • @timvw01
    @timvw01 Рік тому

    It will do its best, so will i.

  • @Kapendev
    @Kapendev Рік тому

    No DLang?

  • @ra-dro
    @ra-dro Рік тому

    By tj!

  • @thesaintseiya
    @thesaintseiya Рік тому

    You missed a paragraph...

  • @anon-fz2bo
    @anon-fz2bo Рік тому

    ODeez

  • @bloqDev
    @bloqDev Рік тому +3

    Rust bad, crab good

  • @NamanGoel34
    @NamanGoel34 Рік тому

    Swift added lifetimes already…

    • @NamanGoel34
      @NamanGoel34 Рік тому

      Swift: Rust without all the manual memory management, except when you really need the most performance possible.

  • @linuxrant
    @linuxrant Рік тому +2

    I really don't understand yet half of what you are all talking about. I would like just to have a language as easy as python with the performance of c++... to write games and some cool programs :) and that's it. I don't want to language hop like neckbeards hop through linux distros...

    • @lucasa8710
      @lucasa8710 Рік тому +1

      A had a similar idea, then I decided to implement such language and I realize the problem is way more complicated then it seems

    • @complexity5545
      @complexity5545 Рік тому

      C++ is the only way. Do 3D games in Unreal.

    • @sumansaha295
      @sumansaha295 Рік тому

      that sounds like Julia

    • @elcugo
      @elcugo Рік тому +3

      It sounds like you should use C# or Java.

  • @complexity5545
    @complexity5545 Рік тому +1

    My god OCaml. The next thing your going to try is TCL (which is a an even worst version of OOP functional programming). Ocaml its been a while for me. The french programming language. You guys are making your way up to why perl was created. LOL . I remember trying to refactor OCAML and having to use TypeRex and it made refactoring even worse. I then realized that I reached peak dumb-f4ck with this language. OCaml is really meant for tinkerer programmers which I define as programmers that like to keep changing code just to past the time and make sub-programmers lives more hectic. A good reason to choose OCaml over Haskell is for graphics and GUIs because OCaml is snappier and more realtime-like. Haskell has the problem of [hanging up] or pausing when the GC kicks in on graphics (back in the day).
    This was a good overview though. It made me remember stuff.

    • @totally_not_a_bot
      @totally_not_a_bot Рік тому +1

      Mathematical abstractions and practical utility don't generally play nice. It's why I just gave up on haskell.

  • @AlgorithmAlloy
    @AlgorithmAlloy Рік тому +1

    I love TJ ❤️ (In a purely sexual way if that wasn’t clear) (Joke if that wasn’t clear)

  • @amj864
    @amj864 Рік тому

    Julia does the stack allocated thing pretty aggressively.

    • @MaxHaydenChiz
      @MaxHaydenChiz Рік тому

      I really want to like Julia. But I think they missed the mark with how their type system works and how traits are implicit instead of the building block. And at least right now, the library support isn't there. In my tests, it always takes about 2x the code that R would take for a similar analysis, At the same time, it isn't at a point where I can use it to replace the C++ portion of an R package and have it nicely integrate with CRAN. Nor does it have enough of the utility stuff that makes Python preferred for some data science use cases.
      I hope they get things sorted out eventually though. It's got a lot of good ideas.

    • @amj864
      @amj864 Рік тому

      @@MaxHaydenChiz It's a tool/preference thing, Honestly, I can't do shit in anything other than Julia and it covers most of my use cases. Just thinking about C++ will give me nightmares.

    • @isodoubIet
      @isodoubIet Рік тому

      @@amj864 Julia really blew it by having arrays start on 1.

    • @amj864
      @amj864 Рік тому

      @@isodoubIet Christ, another one, what is the difference between 0-based and 1-based?! If you think using one or another will make or break your mental model for programming, I have bad news for you!

    • @isodoubIet
      @isodoubIet Рік тому

      @@amj864 "Christ, another one, what is the difference between 0-based and 1-based?"
      0 is the right choice. 1 is not. Julia made the choice to cater to users less accustomed to programming where the difference matters, and as such it kneecapped its own development.

  • @stysner4580
    @stysner4580 Рік тому +1

    E s c ape. Notice the order of the s and c? Not a syntax error!

    • @lunafoxfire
      @lunafoxfire Рік тому

      so you're the one leaving 99 nits on every pull request

    • @stysner4580
      @stysner4580 Рік тому +2

      @@lunafoxfire You really think I would leave an uneven number of nits? It's like you don't know me at all!

    • @lunafoxfire
      @lunafoxfire Рік тому +1

      @@stysner4580 lol

  • @iamwhoiam798
    @iamwhoiam798 Рік тому

    I can’t believe that people don’t speak about the practical difficulties of Rust such as using global or class level variables inside functions.
    mutability problems are overwhelming. Sometime can’t decide whether function should be mutable or member variable should be interior mutable.
    Value enclosed mutexes are ridiculous.

    • @dynfoxx
      @dynfoxx Рік тому

      Why are value enclosed mutexes are ridiculous?

  • @isodoubIet
    @isodoubIet Рік тому +2

    Devs who program mainly managed languages keep falling into this trap where they think they can't get anywhere without the gc. Really value semantics + unique ownership gets you 99% of the way, shared ownership gets 0.9%, and garbage collection can be a legitimate help you with 0.1%. Managed languages optimize for the 0.1% hardest case and make your life sucky for the remaining 99.9%.
    The same devs go to Rust and run into trouble because the borrow checker is overly restrictive and forces them into awkward patterns just to shut it up. Turns out C++ had mostly the right model all along.

    • @ThePrimeTimeagen
      @ThePrimeTimeagen  Рік тому +2

      i disagree with this
      i think there are a variety of problems that c++ is annoying af to solve with

    • @isodoubIet
      @isodoubIet Рік тому

      @@ThePrimeTimeagen C++ has many problems, but the memory strategy is basically right: it's value semantics most of the time, unique ownership for a small part of it (which could be even smaller with something like polymorphic_value), and shared_ptr (ref counting) when concurrency makes lifetimes difficult to reason about. The biggest missed opportunity are destructive moves. One of these newfangled languages could go a long way just by starting fresh from this basic model.
      The borrow checker is a win for concurrency but makes everything much more annoying with little payoff everywhere else, IMO

    • @elcugo
      @elcugo Рік тому

      Biggest problem with C++ is that it needs to support code written 40 years ago. Modern C++ is kinda nice. At some point the commitee has to do a clean break.

    • @isodoubIet
      @isodoubIet Рік тому

      @@elcugo Yup. In general, the cpp committee needs a strategy for fixing mistakes. There's probably some reasonable middle ground between "everything is backwards compatible forever and we never fix mistakes" and "let's hack lol".

  • @KnThSelf2ThSelfBTrue
    @KnThSelf2ThSelfBTrue Рік тому

    Damn, bash influencing the oxidation of OCAML with local. My decision to be the cringe-maxed bash ninja just keeps paying off

  • @aftalavera
    @aftalavera Рік тому

    By the way Rust is the equivalent to following science! Covid and Climate change!