Ocaml First Thoughts

Ғылым және технология

Recorded live on twitch, GET IN
/ theprimeagen
MY MAIN YT CHANNEL: Has well edited engineering videos
/ theprimeagen
Discord
/ discord
Have something for me to read or react to?: / theprimeagenreact

Пікірлер: 149

  • @jayshartzer844
    @jayshartzer84411 ай бұрын

    Ocaml seems like a good ride once you get over the initial hump

  • @ThePrimeTimeagen

    @ThePrimeTimeagen

    11 ай бұрын

    much like rust, there is definitely an initial hump, but apparently there is very little hump (i am positive pun intended here) if you come from another ml

  • @realmimak

    @realmimak

    11 ай бұрын

    definitely some caml humping

  • @nate_wil

    @nate_wil

    11 ай бұрын

    10/10

  • @NoX-512

    @NoX-512

    11 ай бұрын

    It’s the second hump that’ll get you.

  • @laurentogetatx
    @laurentogetatx10 ай бұрын

    I was a CS grad student in France in the 90s when caml-light, which was not ocaml yet, was the official language for teaching Programming 101. It is pretty amazing that 30 years later Ocaml is a new exciting things for cool guys like you.

  • @Tassdo

    @Tassdo

    9 ай бұрын

    Was still the official language when I was in "prépa" from 2014 to 2016

  • @laurentogetatx

    @laurentogetatx

    9 ай бұрын

    @@Tassdo the little coding we did in prepa in 89-91 was in turbo pascal

  • @martinbecker1069
    @martinbecker106911 ай бұрын

    The most interesting article I read about ocaml was an article on building a website as a series of micro-kernels. At first it was just one micro-kernel for the whole site but the article writer went one step further and made each endpoint it's own micro-kernel and the main one was just router to each sub-micro-kernel.

  • @saymehname
    @saymehname11 ай бұрын

    You introduced me to Ocaml and I’ve been enjoying it

  • @aBradAbroad
    @aBradAbroad11 ай бұрын

    Teej is an absolute Lawnmower!

  • @jayshartzer844

    @jayshartzer844

    11 ай бұрын

    He's the Lawnmower Man!

  • @aidantilgner
    @aidantilgner11 ай бұрын

    I actually started learn OCaml about a week ago because of one of your videos. I have to say, it is quite elegant to write. Also one benefit of it has been the greater understanding of recursion that's come out of not having access (at least by default) to mutability.

  • @Tala2n
    @Tala2n10 ай бұрын

    Once I finally setup Dune, its a pleasure to work with Ocaml. I use only a few features, I don't mind the OOP mess, my code has mostly pattern matchings.

  • @JanuszKrysztofiak
    @JanuszKrysztofiak11 ай бұрын

    My only brief encounter with Ocaml was ~20 years ago. It was an interesting FP, ML-derived language but rather lacking in the ecosystem and not multithreaded-friendly (back then). It felt like an academic project (and in a way it was).

  • @morphles
    @morphles11 ай бұрын

    Well, there are weirder stuff, and from what I seen I liked haskell more, but ocaml as haskells cousin - very nice to see some celebrity type people promoting some ML stuff :)

  • @StephenCoda
    @StephenCoda9 ай бұрын

    Had a play around with Ocaml a few years ago. Loved it, was doing opengl stuff and got quite far but if I remember I couldn't get native compilation working correctly on windows so I was stuck with the JVM version. In a round about way it was a similar experience for me to Clojure, loved it (I (Like lisps (generally anyway)), ideally would be using it all the time but it's not a good fit for my use case because performance (though ofc Ocaml -> native is fast).

  • @blidi666
    @blidi66611 ай бұрын

    Ocaml has been designer around a static type system, Hindley-Milner with an "object oriented" extension. Its type system is as complex as Hindley-Milner' and this type system has been designed with together with a type inference algorithm. Typescript intends to provide a type system to a dynamically typed language. Typing a dynamic language results necessarily in a complex type system and the type inference can not be as neat as in languages designed around type inference from the beginning.

  • @SimonBuchanNz

    @SimonBuchanNz

    11 ай бұрын

    Yes and no: there's definitely warts to typescript's system, which refuses to apply unification in lots of cases, the lack of negative types, how generics can only be unbound on a function value not others (think Array) It's definitely a really impressive achievement, though! I don't think there's any type system as complex just in terms of crap it has to deal with.

  • @chris-pee
    @chris-pee11 ай бұрын

    Will you be looking into ReasonML?

  • @WizardofWestmarch
    @WizardofWestmarch11 ай бұрын

    The rust Fn discussion was interesting because i used to struggle with it until i read ab article that finally made it clear. Fn once is most specific and basically it has a lifetime capture that leaves it after a single execution. Fn mut is obvious and fn is any function that doesn't have either restriction. And i should mention once is most specific mut is in between and fn is everything that has neither issue

  • @yaksher

    @yaksher

    11 ай бұрын

    I'd say it's sorta the opposite, actually. FnOnce is the _least_ specific. Every Fn is a FnMut and every FnMut is a FnOnce. Fn is a pure function that you can call as many times as you want, and if you give the same value it'll always have the same output (not really because RefCells exist, but y'know.). FnMut is a function that the compiler can't necessarily prove is pure, but which you can still call repeatedly. FnOnce is what you use when you're only going to call the function once and want to be maximally general and includes "move" closures. So for example, Option::and_then takes a FnOnce because it'll never use it more than once.

  • @WizardofWestmarch

    @WizardofWestmarch

    11 ай бұрын

    @@yaksher hm I see there you are coming from I think. Human languages are hard.

  • @peter9477

    @peter9477

    11 ай бұрын

    ​@@WizardofWestmarchEven so, your phrase "has a lifetime capture that leaves it after a single call" is a helpful way to view it.

  • @WizardofWestmarch

    @WizardofWestmarch

    11 ай бұрын

    @@peter9477 yeah that is the biggest part about Once that helped me a ton.

  • @attilasedon9593
    @attilasedon959311 ай бұрын

    Man, I think I will pick up Ocaml, after Go, it seems like a more sensible Haskell, don't get me wrong, I like Haskell, but everything is wrapped in monads, because it feels like a leaky abstraction, or I am just too dumb to use it well.

  • @adicide9070
    @adicide90705 ай бұрын

    definitely enjoying ocaml now and where it's going

  • @hypergraphic
    @hypergraphic11 ай бұрын

    I feel like Haskell is the gold standard for functional programming, and every other functional language is trying to make it actually usable :) Personally I'm torn between learning a low level language like Zig or Odin, or learning a functional language like Ocaml or Haskell.

  • @Thwy

    @Thwy

    11 ай бұрын

    Haskell was the first language I learned and for me it is very natural to write functional code. I feel Haskell is usable and awesome! And other functional languages are trying to accommodate imperative programmers, and that's fine, since it's the industry standard and most people are used to it. But don't underestimate Haskell!!!!

  • @georgerogers1166

    @georgerogers1166

    11 ай бұрын

    Rust

  • @zzzyyyxxx

    @zzzyyyxxx

    11 ай бұрын

    OCaml now has algebraic effects which even Haskell doesn't have. It's an interesting alternative to monadic patterns.

  • @zzzyyyxxx

    @zzzyyyxxx

    11 ай бұрын

    That's being said, learn Rust too

  • @vitalyl1327

    @vitalyl1327

    11 ай бұрын

    They belong to very different flavours of functional programming.

  • @Diego-Garcia
    @Diego-Garcia11 ай бұрын

    The name is Thefunctionalgen

  • @justinhoney1969
    @justinhoney19696 ай бұрын

    do you have any thoughts about F#?

  • @RyBrown
    @RyBrown11 ай бұрын

    the only reason I’d learn this is to get a job at Jane Street

  • @redolentofmark
    @redolentofmark9 ай бұрын

    What is TJ’s channel? He says it at the end.

  • @Vampirat3
    @Vampirat311 ай бұрын

    Like a rusty python that gets you over the hump ! I like it , its flexible good foe when its needed maybe

  • @FaZekiller-qe3uf
    @FaZekiller-qe3uf11 ай бұрын

    Rust was written in OCAML.

  • @pavloburyanov5842
    @pavloburyanov584211 ай бұрын

    Got my "translation mechanism" down while trying to interpret rust code in javascript

  • @officialraylong
    @officialraylong7 ай бұрын

    OCaml is fun. I like F# and use it when hacking around in Unity.

  • @CristianGarcia
    @CristianGarcia11 ай бұрын

    read Learn You a Haskell, bath in the beauty of FP, and then just go back to your old language.

  • @aidantilgner
    @aidantilgner11 ай бұрын

    What do you guys think of dependant types?

  • @SVVV97

    @SVVV97

    11 ай бұрын

    No offense but just based off the videos it seems like prime isn't exactly an expert on dependent types or "deeper type stuff".

  • @aidantilgner

    @aidantilgner

    11 ай бұрын

    @SVVV97 fair. To be honest I'm not either, but I am trying to learn and OCaml has been a great help towards that. Lots of concepts to explore. Jane Street has a podcast where they talked a bit about dependant types.

  • @talananiyiyaya8912
    @talananiyiyaya891211 ай бұрын

    I write OCaml via tools like coq. I try not to directly program in OCaml.

  • @stanrock8015
    @stanrock80159 ай бұрын

    Initially language internal translation but that changes at some point and you think I’m new language and translate back. That’s when you know your fluent. I used to dream in Chinese.

  • @derschutz4737
    @derschutz473711 ай бұрын

    Ocaml is very nice and has a style that some people prefer over Haskell. But it is very old and the room for a new FP language that is vastly better, is completely there. Using optimized ref counting (FBIP, Perceus) instead of/in addition to GC, modern syntax, modular implicits, better tooling, better error messages (elm should be the standard), more cohesive/consistent community etc.

  • @OverG88

    @OverG88

    10 ай бұрын

    Very old? No it's not.

  • @petrvorlicek3643
    @petrvorlicek364311 ай бұрын

    What's the O in Ocaml?

  • @Asjasification

    @Asjasification

    11 ай бұрын

    Objective Caml

  • @AlJay0032

    @AlJay0032

    11 ай бұрын

    The part you want to ignore.

  • @SVVV97

    @SVVV97

    11 ай бұрын

    @@Asjasification The objective being to avoid OOP

  • @thehibbi
    @thehibbi11 ай бұрын

    OCaml is more dreaded than C++ according to the SO survey from 2022, why don't you try C++? (:

  • @scythazz

    @scythazz

    11 ай бұрын

    Pretty sure he already knows c++

  • @ArrizalAmin
    @ArrizalAmin11 ай бұрын

    Just a heads up, Ocaml lacks ad hoc polymorphism (trait/interface). so if you like that, you're probably better go with haskell or idris, they have typeclass which kind of like rust's trait but more powerful.

  • @ehllie

    @ehllie

    11 ай бұрын

    Oh, you mean HKT?

  • @ArrizalAmin

    @ArrizalAmin

    11 ай бұрын

    @@ehllie yes

  • @davidjohnston4240
    @davidjohnston424011 ай бұрын

    You and your fancy OCaml. Why not write in standard ML, like we did in college 30 years ago?

  • @h2_
    @h2_11 ай бұрын

    Elixir bros hold strong, his defenses will fall eventually

  • @rogergalindo7318
    @rogergalindo731811 ай бұрын

    and thinking they could be talking about haskell 😔 my #nth comment about haskell here, wondering if prime doesn’t get tired of it HAHA

  • @laughingvampire7555
    @laughingvampire755511 ай бұрын

    when people understand the benefit of types, that they help you to track your assumptions across your code base, then you will understand that anything less of a sound type system like in typescript or Go creates more problems than it solves, you might not see it at the beginning but they will bite your ass in the moment you least expect it.

  • @nyahhbinghi
    @nyahhbinghi4 ай бұрын

    GLEAM for the BEAM

  • @xGigglypuff
    @xGigglypuff7 ай бұрын

    At Harvard, computer science concentrators have to do a course that is just a semester in OCaml (intended to improve design and style), and it caused me-and everyone I know-so much PAIN.

  • @micycle8778
    @micycle877811 ай бұрын

    i would write in ocaml, but it feels like the language has less of an ecosystem than Nim, which is saying something. plus the whole "use this rewritten version of the stdlib" isn't a good look imo

  • @yawaramin4771

    @yawaramin4771

    11 ай бұрын

    Ecosystem is fine, there are plenty of libraries for common tasks. You can just use the default standard library if you want, no one is forcing you to use the alternatives.

  • @tptodorov123
    @tptodorov1234 ай бұрын

    It's funny how every new generation of coders discover the hotwater and talks how good it is -- talking about type systems.

  • @metalim
    @metalim11 ай бұрын

    Ocaml toe

  • @CallousCoder
    @CallousCoder11 ай бұрын

    OCaml just looks wrong to me. And I’ve programmed some weird esoteric languages like Forth, MUMPS and a lot of assembly. But these are all procedural languages. Camel Toe is a functional language and there for the syntax looks so convoluted and foreign to me. My mind is wired more digitally thus procedural thinking - makes sense for an Electronics Engineer. ML is more for abstract scientists I guess. Oh yeah Rust and refactoring is a pain in the arse! Rust allows you to really paint yourself in a corner and have to sand the whole floor in stead just the path back to the door and repaint that.

  • @TankorSmash

    @TankorSmash

    11 ай бұрын

    That's the cool part about learning new programming languages, you break down your resistance to different styles and start to appreciate what all the differences are!

  • @CallousCoder

    @CallousCoder

    11 ай бұрын

    @@TankorSmash well I never appreciated functional languages. It’s just not how my engineers brain is Wired. Like I said I’ve programmed in very esoteric languages like MUMPs, I adore assembly and Forth probably being one of the weirder ones; passing everything over a stack and the reverse Polish notation that all clicked for me after about a few days. Functional never clicked I guess it’s just too abstract for my way of thinking - when you did hardware design and lowlevel programming you can only do that in a procedural way, so I guess certain beains are wired in a certain way. Functional languages are probably fun and easy for mathematician who in turn do not tend to not feel comfortable in the low level procedural stuff as much h. But it’s cool that there are choices, and that’s good. And just sniffing at them is also important to see what clicks with you, what is around and what they are great at and suck at. There’s no perfect language after all. Although C is damn near to perfection 😉

  • @TankorSmash

    @TankorSmash

    11 ай бұрын

    @@CallousCoder I failed my uni stats math class twice, and spent 10 years writing relatively performant C++ for my games. I'm the furthest thing from a mathematician and I still found a lot of value in FP! The puzzle-piece like nature of it goes a long way for me, where you can just move parts around without worrying too much because of the purity is such a nice quality. But yeah, definitely not going to be for everyone, especially since it's _so_ different and strange!

  • @CallousCoder

    @CallousCoder

    11 ай бұрын

    @@TankorSmash it’s not a race but I think I suck more at maths 😂I was so happy when I barely passed the 2nd semester and maths was out after that. Integrals, algebra equations 🤮Applied mathematics is okay but that abstract theoretical stuff never worked for me. And my dad studied mathematics and he couldn’t even teach it to me, although he did better than the maths teachers I had. At some point in highschool I was called into the headmaster’s office and there sat my physics and mathematics teacher. And basically the question was if I had something against my maths teacher because I aced physics and chemistry and failed maths and failed it miserably. I told them that I had not problem with Johan (teachers and students were on a first name bases at that school), just that if he can’t teach the concept that for some reason it doesn’t click with me. And physics is very factual and I know that I derived a formula wrong if say for example something falls from the Eifeltower and breaks the sound barrier, that just doesn’t happen. With abstract maths I’m glad that there’s an outcome and done with it 😃 I even had to do a summer course to get into the EE program. Because technically you weren’t allowed if you didn’t elect maths. But luckily recommendations were great from my old school. And the projects I did spoke for themselves. And barely passed that course. It would’ve been a real dud if I hadn’t. Because EE was basically my only, “stay out of the military draft option left”. I wanted to study music as I was a professional musician already although self taught I did manage to get into audition for the Royal Conservatory. I already had a place at the Amsterdam Film academy but my passion was music. So I waited and waited and eventually word came that I hadn’t made the cut. By then my position at the film academy had been filled. But based on my film they said I could enroll next semester. Since I tinkered a lot with electronics (phreaking, hacking radio to listen in on police, making effects peddles) my dad suggested to do EE for a semester and then do the film academy. I never went to the film academy 😃Although I did end up working in film and tv and also write scores every now and then. But that EE diploma always was there to pay the bills. Where my musician and film friends all frequently rely on benefits 😖

  • @derschutz4737

    @derschutz4737

    11 ай бұрын

    @@CallousCoder u dont have to be even semi-good at math to program functionally. prime maybe has the level of a upper level high schooler and he is going just fine. its a common misconception that in order to program functionally u need to be some advanced math person.

  • @user-nb1ty4lu6f
    @user-nb1ty4lu6fАй бұрын

    i like ocaml because it's strongly untyped

  • @jamesc2810
    @jamesc28104 ай бұрын

    My biggest problem with ocaml is it won’t install.

  • @AlJay0032
    @AlJay003211 ай бұрын

    Ocaml is nice but forget about the object oriented part.

  • @js-ny2ru
    @js-ny2ru11 ай бұрын

    Teej, no thank you...

  • @thingsiplay
    @thingsiplay11 ай бұрын

    I would rather learn Haskell than Ocaml. Change my mind.

  • @lavender0666

    @lavender0666

    11 ай бұрын

    languages are a tool, learn what's helpful to you :> no one needs to change your mind

  • @vitalyl1327

    @vitalyl1327

    11 ай бұрын

    Eager vs. lazy, simple and powerful module system (still, I'd prefer SML), portable bytecode implementation and highly efficient native compilers for major platforms, quite a bit faster than GHC.

  • @yueyu9762

    @yueyu9762

    11 ай бұрын

    The point free culture in Haskell is annoying

  • @yueyu9762

    @yueyu9762

    11 ай бұрын

    But learning Haskell is fun

  • @teej_dv

    @teej_dv

    11 ай бұрын

    im too lazy to change your mind

  • @RedOchsenbein
    @RedOchsenbein11 ай бұрын

    I just think, unfortunately, the tooling is bad. Dune, esy, opam... and somehow everything interferes with the others. I like the language. But setting up projects feels just bad and brittle.

  • @az8560
    @az856011 ай бұрын

    I feel that ocaml introductions should start with excuses and disclaimers. "Sorry, we use ;; because when I designed the language, I spilled the coffee near my ; key". "We sincerely apologize for having separate set of operators for ints and floats; but uniform unary minus; we understand that this probably violates Geneva convention". "Please bring close your bucket for vomiting before reading this section". "Don't forget to tell your doctor that you were trying to ocaml, it will prevent tragic cases of misdiagnosis when you will eventually be hospitalized with severe eye bleeding"

  • @ThePrimeTimeagen

    @ThePrimeTimeagen

    11 ай бұрын

    yeah... i think this statement is wrong, but it was nice try

  • @EdouardTavinor

    @EdouardTavinor

    8 ай бұрын

    ;; is only used in the repl btw

  • @francis_the_cat9549
    @francis_the_cat954911 ай бұрын

    Ocaml is really cool but you should really have a look it Odin, btw it has parametric polymorphism as well

  • @un9286

    @un9286

    11 ай бұрын

    he knows about Odin. he actually had a talk/interview with the creator of Odin. he said that Odin is not what he wants to learn rn

  • @kpamkar
    @kpamkar11 ай бұрын

    You should definitely try out erlang which is also one of the easiest functional languages to grok

  • @TS-by9pg
    @TS-by9pg11 ай бұрын

    I've tried learning OCaml by making a Tic-Tac-Toe game in the terminal. And I quit the moment I learned that in order to mutate the matrix, I basically need to create a new one with the element changed. And such a function is not even a part of the standard library. I love functional features of Rust (immutability by default, iterators, enums, etc.) but I really don't think the language should prevent mutability when it just makes sense and is way more efficient. Still hoping we would get an actual "Rust with GC" type of language though

  • @carlpittenger

    @carlpittenger

    11 ай бұрын

    if you include automatic reference counting under gc, jakt seems promising

  • @rallokkcaz

    @rallokkcaz

    11 ай бұрын

    There's literally a mut keyword and ref cells. Bad reason to quit hahaha.

  • @TS-by9pg

    @TS-by9pg

    11 ай бұрын

    @@rallokkcaz Maybe I've overlooked it, but there was an SO thread saying this is the way to do it in OCaml. Can you link where I can read more about it?

  • @yjlom

    @yjlom

    11 ай бұрын

    @@TS-by9pg there's a few ways, like using a matrix of refs. And with the work they're doing at jane street on improving the type system, the copy-everything pattern should be possible to silently optimise to in-place mutation

  • @AndrewBrownK

    @AndrewBrownK

    11 ай бұрын

    Immutable data structures were invented to handle this efficiently

  • @nyahhbinghi
    @nyahhbinghi4 ай бұрын

    Nobody knows what "LSP" is bro

  • @complexity5545
    @complexity554511 ай бұрын

    Good Video. I assume OCaml is now the new land of new programmers trying to replace JS and provide a C++ alternative (since we're all leaving Rust). This is a very good video especially the part about the OCaml community moving toward getting rid of the OCaml (incremental) Garbage Collector and compiling memory management baked right in it. I hated OCaml because of the GC. OCaml is like a french version of TKL + CamlLight. OCaml used to be (or is) a bad language for I/O applications (due to garbage collections) with horrible syntax and a bad OOP design. But if you guys are leading the plan to make OCaml without GC, then that would be a game changer. It would basically be like haskell without the GC. If that occurs, I'm joining and pulling out my old OCaml projects. Good Video (just for giving me the plan to make OCaml without GC).

  • @giovannisolimeno5040

    @giovannisolimeno5040

    11 ай бұрын

    I don't think people are leaving rust

  • @complexity5545

    @complexity5545

    11 ай бұрын

    @@giovannisolimeno5040 That's true. Regular programmers are not leaving rust. I should have said, "Some of us are second guessing using Rust as a main go to programming language (especially for embedded stuff and C++ replacement).

  • @tefro_tech

    @tefro_tech

    8 ай бұрын

    @@complexity5545 Who's leaving rust?

  • @malikcodes8038
    @malikcodes803811 ай бұрын

    eeee

  • @waffletube5707
    @waffletube57076 ай бұрын

    Spoiler alert: He loves it

  • @coder_one
    @coder_one11 ай бұрын

    What about Elixi? It looks better than OCaml

  • @RedOchsenbein

    @RedOchsenbein

    11 ай бұрын

    Yeah, I like it more. Especially because of the tooling. OCaml is just stronger in the typing realm.

  • @OverG88

    @OverG88

    10 ай бұрын

    Two different philosophies.

  • @karanmungra5630
    @karanmungra563011 ай бұрын

    Just learn Haskell. The most thoughtful language ever

  • @ThePrimeTimeagen

    @ThePrimeTimeagen

    11 ай бұрын

    the problem is i want to build something real and also have a good build tool and also have good library docs and also have a wife and kids

  • @ProjectVastness

    @ProjectVastness

    11 ай бұрын

    ​@@ThePrimeTimeagen F# then ¯\_(ツ)_/¯

  • @el_carbonara

    @el_carbonara

    11 ай бұрын

    haskell has great docs + hoogle and cabal is more than enough to get far. It is no more time consuming than what it is to learn ocaml, maybe easier because you commit to the functional way.

  • @scythazz

    @scythazz

    11 ай бұрын

    The problem about Haskell is Haskell always has the stink of it being a education only language. Like its the language that you get introduced to in a university programming language paradigms class when they teach fp. Why do you want to learn a language that not many companies are actually using to build stuff. Sure, u can learn a language purely for fun but it would better if there could be some return on investment on that right?

  • @silas427
    @silas42711 ай бұрын

    first EZPZ

  • @Tomyb15
    @Tomyb1511 ай бұрын

    When I first looked at OCaml sometime last year, I got as far in the landing page as it said "OCaml is an Object Oriented language" and immediately closed the tab. Waste of my time.

  • @liquidcode1704
    @liquidcode170411 ай бұрын

    ocaml is good in a drought

  • @morkallearns781
    @morkallearns78111 ай бұрын

    TheJaneStreetagen

Келесі