Ocaml Becomes Rust w/ Garbage Collection?

preview_player
Показать описание
Recorded live on twitch, GET IN

MY MAIN YT CHANNEL: Has well edited engineering videos

Discord

Рекомендации по теме
Комментарии
Автор

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

atiedebee
Автор

fun The first rust compiler was written i oCaml

RemcoJvGrevenbroek
Автор

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<T>, there may be a subtype relationship between Foo<Dog> and Foo<Animal>, but it may be:
* returning a T, in which case Foo<Dog> is a Foo<Animal>, which is covariance, or
* it may take a T, in which case Foo<Animal> is a Foo<Dog>, 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<A, R>.

SimonBuchanNz
Автор

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

casperes
Автор

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.

robertlenders
Автор

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

EricSampson
Автор

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#.

carlpittenger
Автор

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.

sumansaha
Автор

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

xbmarx
Автор

the beginning of a beautiful friendship

itacirgabral
Автор

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.

WizardofWestmarch
Автор

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<supertype> is a supertype of array<subtype> (array is covariant) but function<supertype> is like a subtype of function<subtype> (function is contravariant). Scala taught me something, at least 🤣

ForsakenDAemon
Автор

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.

MaxHaydenChiz
Автор

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

TroubleChute
Автор

Nice thumbnail -- Prime's OCaml-face.

ericbwertz
Автор

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

alexanderoh
Автор

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?

Titousensei
Автор

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

aftalavera
Автор

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

holthuizenoemoet
Автор

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

shobum
welcome to shbcf.ru