176 points · by noch · 5y ago · 108 comments
It says, in the 'Future Work' section:
> This could be extended to allowing multiple names to be initialized (such as through destructuring) with a "normal" conditional to be written after the assignment with a ; (similar to a for).
if (let x = 1, y = 2; x || y) {
/* ... */
}
if (let {x, y} = data; x && y) {
/* ... */
}
Meanwhile, OCaml from day one: if let x = true in let y = true in x || y then
...
if let { x; y } = data in x && y then
...I think this assertion was true 20-25 years ago. Less so now.
* GADTs
* Row polymorphism with inference
* First-class modules
* Let binding operators, e.g., let* for monadic binding
On the coming soon to OCaml (hopefully) and way ahead front:
* Algebraic effects
* Modular implicits
Not to forget that when languages pile on features over the course of years, they effectively split their users into 'old-style' and 'new-style' codebases, where people need to worry about what features are usable with what versions of the language. It's a huge mess.
Functional Programming in OCaml - https://news.ycombinator.com/item?id=22408664 - Feb 2020 (58 comments)
Functional Programming in OCaml - https://news.ycombinator.com/item?id=22400233 - Feb 2020 (1 comment)
Functional Programming in OCaml - https://news.ycombinator.com/item?id=19292067 - March 2019 (144 comments)
He is a pretty good communicator!
https://www.youtube.com/playlist?list=PLre5AT9JnKShBOPeuiD9b...
A great help here is a "start-project-template" like with svelte (for example), they have RIGHT on the home-page a big-ass block that shows you how to "get and start" the svelte-new-project-template.
Coming to OCAML the "tooling" can be confusing and ambiguous. For example you can use ocamlc, dune,ocamlbuilder,esy opam etc.
And of course the "few options" for a std lib Core, Batteries etc.
I like the "syntax" from the Batteries more to be honest.
Perhaps give a reference to "libraries" on the first page (or all?) where you use Core so people know how to use Core (opam, dune).
Here's an implementation for those interested: https://github.com/senhorsolar/hack-assembler
However, I thought I should mention that I got _exactly_ as far as [0] (found while trying to google a solution) before giving up. The REPL is great, but if I can't compile easily, it doesn't inspire the confidence needed to go any further.
The community actually standardized its way of compiling around Dune which is very good.
[1] https://ocaml.org/learn/tutorials/a_first_hour_with_ocaml.ht...
[1] https://ocaml.org/learn/tutorials/a_first_hour_with_ocaml.ht...
In my defense, [1] makes no reference to dune, which I am excited to try out.
[1] https://ocaml.org/learn/tutorials/a_first_hour_with_ocaml.ht...
> You may follow along with this tutorial with just a basic OCaml installation, as described in Up and Running.
So, you can't really skip 'Up and Running'. And, the Graphics module usage is in the section 'A module from OPAM', which explicitly talks about installing the package and then loading it in the REPL ('top level').
It is co authored by Yaron Minsky, I think Yaron plays a big role in making OCaml relevant
I think OCaml would have been a far less popular language, had Yaron chosen another language for jane street
once you grok functors and algebraic type systems, a lot of other system design patterns seem like abstractions on a few key concepts.
I would like to see a course or textbook that explains functional programming in the abstract. Instead of going into the details of any one functional language, gives examples of how various functional languages implement the various core ideas of functional programming.
So, explain functional programming concepts such as pure functions, referential transparency, functors, monoids, monads, effects, lazy evaluation and so on, not in the context of any specific language, but giving examples from multiple functional languages.
In other words, focus on functional programming in general, instead of one specific implementation of it. I have been looking for such a textbook or course, but it doesn't exist.
Lots of developers are curious about functional programming. Even if you don't program in a functional programming language, many principles of functional programming, such as pure functions, can be applied in any language. Almost all languages in use today, including JavaScript, C#, Java, Python and Rust have varying degrees of FP features. Understanding what FP is all about is helpful in learning those features.
I'd argue that the market for learning what FP is all about, and how you can apply FP features in traditional languages, is bigger than the market for learning specific FP languages such as OCaml, Scala, F# and so on.
https://www.lihaoyi.com/post/WhatsFunctionalProgrammingAllAb...
(edit) a post that uses JS, PHP, Python etc. to explain many FP concepts: http://chriswarbo.net/blog/2015-01-18-learning_functional_pr...
These three things are mostly Haskell-specific though, at least in relation to functional programming.
https://docs.rs/functional/0.0.5/functional/trait.Functor.ht...
https://docs.rs/functional/0.0.5/functional/trait.Monoid.htm...
https://docs.rs/functional/0.0.5/functional/trait.Monad.html
Having to use monads for sequencing is something that happens in Haskell and not in Rust.
It is a very bold statement. There is nothing in course about how to fight complexity. Knowledge how to traverse an ADT tree helps a little unfortunately. But it is a great classic CS course though.
You should read it more carefully. E.g. https://www.cs.cornell.edu/courses/cs3110/2020sp/textbook/mo...
> One key solution to managing complexity of large software is modular programming: the code is composed of many different code modules that are developed separately. This allows different developers to take on discrete pieces of the system and design and implement them without having to understand all the rest. But to build large programs out of modules effectively, we need to be able to write modules that we can convince ourselves are correct in isolation from the rest of the program. Rather than have to think about every other part of the program when developing a code module, we need to be able to use local reasoning: that is, reasoning about just the module and the contract it needs to satisfy with respect to the rest of the program. If everyone has done their job, separately developed code modules can be plugged together to form a working program without every developer needing to understand everything done by every other developer in the team. This is the key idea of modular programming.
Imagine you are a UFC fighter and going to the gym and lift weights to be a "better fighter" even though, you didn't throw one-kick or punch one bag etc :P
In terms of performance, there is this paper https://kcsrk.info/papers/system_effects_feb_18.pdf where on a single core async OCaml and effect OCaml are close to Go's net/http, and there is also this project https://github.com/ocaml-multicore/retro-httpaf-bench but I haven't see any results from it.
- Bootstrap teaches a toned-down version of Racket (i.e. Scheme): https://bootstrapworld.org/materials/spring2021/en-us/course... . It's taught in some schools as well as a comp sci curriculum.
- https://code.world/ teaches using a toned-down version of Haskell. To my knowledge it's not used in schools.
[1]: https://www.coursera.org/learn/programming-languages
[2]: https://www.coursera.org/learn/programming-languages-part-b
Note the following:
> This work is based on over 20 years worth of course notes and intellectual contributions by the authors named above; teasing out who contributed what is, by now, not an easy task. The primary compiler and author of this work in its form as a unified textbook is Michael R. Clarkson.
You do not need to be enrolled in CS 3110 to be able to utilize this content (said "unified textbook").
They could have certainly done something more radical than OCaml then such as, say, Idris2 which is truly a challenge for those not used to it.