Intro to OCaml + Functional Programming

preview_player
Показать описание
This is a brief introduction to OCaml and function programming 👩‍💻⭐️!

Topics covered include: features/uses of OCaml, imperative vs functional programming, tail recursion, and various ways to write a function to compute the Fibonacci number at a given position.

Links to resources if you'd like to learn more:

This video was made as a part of Cards Against Humanity's Science Ambassador Scholarship. As the 2021 recipient, each semester throughout my undergraduate education at Caltech I'll be creating new videos about the cool STEM topics that I am studying! Subscribe to see more.
Рекомендации по теме
Комментарии
Автор

Actually, the essential difference between imperative and functional programming languages is that the first program you learn with an imperative language is Hello World, and with a functional language it's the Fibonacci sequence.

ErikBongers
Автор

that was great!
i didn't know tail recursion can handle recursive calls dependent on more than one previous state.
it's much more powerful than i thought then.

michalbotor
Автор

I learned Ocaml back in college for a CSCI class which destroyed me mentally and academically. Coming back here as a software engineer of 7 years to relive the trauma. To 1st/2nd-year CSCI students: you got this!! Uni classes are way harder than the average job.

grantsorenson
Автор

Hey Gabbie. Would you consider doing an OCaml series?

MaybeJustJames
Автор

Thanks, that was a nice way of presenting some of the important aspects of functional programming. Also, OCaml seems to be having some kind of revival. Maybe I should take a look. I have been programming Clojure for about 10 months, then I quit that job and sadly I am not doing any real functional programming for a living, but I am still trying to apply its principles where possible.

jds
Автор

Awesome vid. I'm more on the Haskell street but OCaml having strict evaluation makes it a more practical PL.

juansalvadordomandl
Автор

Fascinating and head-spinning! I definitely need another coffee, but premium quality.😃

Master-Yoda
Автор

Cool demo. Made me interested in trying. It’s very different from what I’m used to: Python, JavaScript and go

al
Автор

Your voice is really chill, I love it.

By the way, you could try OBS, you don't have to use Zoom to show the camera (at least that's what it looks like). It doesn't take away from the quality of the video, but it's nice to know!

stefanalecu
Автор

great vid! is the "rec" before a function name a keyword for recursive functions? if so that sounds like a great way for the compiler to differentiate and optimize it with tail recursion like you talked about

lucasmachado
Автор

Some correction hope you do not mind: The formal definition of "Functional Programming" (FP) is widely debated and there isn't a fully agreed upon definition as there are some who argue that any language that has "Higher Order Functions" (HOFs) as well as lazy evaluation is FP, others ague that it must also have pure functions i.e referential transparency. Most languages today have HOFs and in some cases also can do optional lazy evaluations. The lines are blurred. Haskell for example (as well as Clean and Miranda are purely functional that is functions can not do any mutations or side effects). As mentioned most languages these days even Java can do FP because they can do HOFs, Closures, lazy evaluation etc. I suspect there has been "goal post shifting" in more recent time (this is my personal opinion however) in regards to what is FP, much like the "no true Scotsman fallacy" FP definitions keep changing over time it appears. For example the Erlang, Lisp, OCaml, F#, and Clojure are all described as FP, yet they're not "purely functional" nor are all of them lazy. TL;DR it's complicated mess!

Anhar
Автор

Okay maybe it's I do Ocaml, great video btw

sphesihlemanuel
Автор

Good luck in your exams :)
I'm studying cs also but i'm only starting my second year

pablofirpomolina
Автор

Neat vid! It’s really interesting that quant firms like Jane Street use it. It seems less intuitive than a language like python, but i can see how it would be faster to run than python code and maybe more attractive that way!

youturru
Автор

Do more on Ocaml
Like a beginner’s guide

colokwing
Автор

Great video. Thanks for posting. One question for you, what color scheme are you using here for VS Code?

eyeiozm
Автор

Can you describe please how to run ocaml code in vscode? I tried but didn't work

سيفالشمري-ضثو
Автор

"Ocaml uses tail recursion" means (I suppose) "Ocaml uses Tail Call Optimisation". What it means is that it is not expensive to use tail call in a recursive function because it gets translated to a loop.
Tail recursion exists in any programming language, but in most of them it is expensive as it has to create a stack for each "iteration" (each call) and can then result in a stack overflow (which is not ideal for a simple loop)

GeorgijTovarsen
Автор

Is curious! Decades ago as a kid my big shift was to functional C which was all the rage. Then went to C++ and finally Java in 2000. Those one line functions? Are there editors that will uncompact? Seems like a fix for readability. Rhetorical. But if not you could write one, no? Also rhetorical.

jstevh
Автор

1:11 no haskell? 😢 haskell is beautiful...

mzg
welcome to shbcf.ru