The C A M L, with an O at the front It’s not imperative scaring ya, and we ain’t tryna stunt Just tryna process every single type to keep it in check And having higher-order fun with it is just a side effect (c) rangersbeats
Any curried ML language is nice, and Rok too (even though it doesn't curry functions by default). With OCaml I just had to get used to the French ordering of product types: `int list` instead of `List Int`. French acronyms can be confusing in the same way.
I'm beginning to love Ocaml. It's the language that would be born if Rust and Go had a baby. By the way you went through the code really fast, so it was difficult to grasp a lot of what you were saying. Do you have this code posted on github? I looked, but I didn't find it.
And now the scary part: the name is originally an acronym for Objective (as in OO) Categorical (as in Category theory in math - yes, monads & c.) Abstract (as in device independent meaning for its programs) Machine (as in reduction rules which implement that meaning) Language (as in a notation for the C and A above). It's really a clever decoy which tempts you from the bountiful fruits of Real Programming into the arid wasteland of Computer Science - with the tacit goal to make you unemployable...
Ocamllex is included with Ocaml package. So I use it for the lexer. I refuse to use ocamlyacc, that adds dependency and Ocaml is sufficiently cool to implement a parser.
Really liked the video, what i would like to see is how to use dune/run tests or an explanation on how to use modules. I tried to read the documentation and i could not figure this things out.
Please keep these coming! I've done the book in Go, so seeing a different way will be interesting. I can already see how much better pattern matching is compared to type switching on interfaces in the original. OCaml is a language that I used to be interested in (as a middle ground between Rust and Haskell), but I got put off by how inconsistent the community is. I can see it being useful for cases like this, where you likely don't need much outside of the core language.
My own Master's final programming project was to implement a compiler whose (i) source language was Prolog extended with certain features which come in handy when you are writing compilers in Prolog (ii) object language was standard Prolog (iii) implementation language was... Prolog, of course.
Apart from being able to use monadic parsing expressions - which is admittedly a _huge_ win! - laziness does not really buy you much in compiler writing. In contrast, say, Prolog-style logical variables with unification make backpatching semi-generated code much simpler.
Long overdue video, Teej! I knew you were doing some OCaml and got curious, but try as I might I'm not made for watching live streams. Interesting implementation, would love to see more. I did some ML back in the day, so it's not completely alien.
I love Ocaml, glad you decided to make a video on it. I know you're pretty hot on the language also but obviously it's not as popular as say rust for example. I'm looking forward to the opam Windows release since I do most of my development on Windows. Fortunately in the meantime we have DKML which is pretty fantastic.
never lean OCaml before, although you try to explain it but still couldn't get how it works(I also haven't read the book for how it implement the lexer). Might see the code offline again. but it seems fresh and interesting to look at functional program with OCaml. had been doing imperative programming for so long time.
By the way, if you want to keep people hooked and understanding the syntax easier, you could consider using reason syntax. It is the same, but with a more C-style looking
Nice to see your first ocaml my caml video. If you can find a way to have your green screen a little further back, you can probably prevent the green reflection that its casting on your head.
Seems really cool, would love to see other examples! A bit curious about the performance, but mostly really curious about the ecosystem. Is there a package manager that people actually use and are there implementations for graphl and grpc as well as the most common databases?
I want to encourage you to keep making videos like this because OCaml is a brilliant and beautiful language for programming language theory. That said, the clickbait title was a bit jarring. "Writing an interpreter ... in OCaml?!?" This is exactly what OCaml excels at! There's nothing surprising about writing interpreters in OCaml!
I’m enjoying these Ocaml videos! I have always loved functional programming languages, but never got into Ocaml. I need to give it another look. Pattern matching makes code really easy to reason about IMO
Looks like my comment got flagged somehow, I just think OCaml looks pretty is the primary takeaway I got from here 😂. I want to make it work with Godot somehow. ⭐️
Great video, ocaml seems pretty cool. I have kinda mixed feelings about immutability though. I love the idea behind pure functions, but how do the performance and memory consumption compare to mutable solutions? It seems like the lexer is allocated for every token. Does ocaml perform some kind of optimization behind the scenes?
ocaml's compiler and garbage collector are optimized for lots of small, immutable allocations! In some cases, making many small objects (that are all declared mutable) is actually faster than creating mutable ones (because the compiler can make more optimizations). It's not like trying to write immutable code in javascript.
In general, immutable functional languages are mostly slower than something like C or Rust but they are often faster than mutable and garbage-collected languages. Immutability provides a bunch more possibility for optimization!
I did it the other way around: First Standard ML and Caml - because it was and still is the only ML with a pulse - but then turning to Haskell because some features of Caml were not quite orthogonal, Whenever you add later a totally different programming or data model into an existing language, you are bound to see the stitches which keep that Frankenstein's monster together. As proof, compare (i) the Java generics, which added parametric polymorphism into what had been so far a purely object-oriented language with ad hoc and subtype polymorphism (ii) the "O" which added objects into Caml which had been so far purely parametrically polymorphic (iii) Haskell which developed instead the fresh idea of classifying types and not values. In OO terms, they did introduce ad hoc polymorphism, but for interfaces only. Values stayed intact, and hence parametric polymorphism continue working as before.
Whilst the older games certainly had a lot of multiplayer, they were absolutely viable single player games. Do you feel this element will be lost with the ever increasing push towards seasons and battle passes in diablo 4?
@@teej_dv now a days everything has a battle passe,and most of the time it doesn't serve any purpose beside making money, you should take a look at the video about abusive monetisation strategies that asmongold reacted to very informative
@@teej_dv Thank you. I saw it in a video with you and Prime recently. You two look like you have so much fun streaming together. Thanks for being so inspiring ❤️
Hmm... I think flex/yacc can often be "easier"... until they're not. Once you want to try and do something non-standard, you'll have a hard time. The point of the series isn't to pick the easiest way to write an interpreter, but instead to understand what is happening under the hood.
Flex and yacc are code generators. They open a can of worms beyond imagination. Code generation is pure evil. Stay away from those and use a language that allows you to express ideas in a concise way. Haskell, OCaml, F#, Scala, Rust are good examples.
Lexers and parsers are in my opinion not hard enough problems to justify parser generators. Of course use what you like but parsing is so simple that you can just do it yourself and be more flexible!