TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

OCaml Programming: Correct and Efficient and Beautiful

347 点作者 philonoist将近 3 年前

21 条评论

blackerby将近 3 年前
A quick scroll through the comments and it looks like no one is actually talking about the book itself, so I will. I came across it at a really good time in my computer science self education. It helped me learn about some essential data structures and algorithmic analysis. The video lectures interspersed in the text augment the text and vice versa. The sections without videos were tougher for me to digest, but are written clearly and bear revisiting and study. If you, like me, are looking for a good next step after Grossman’s PL MOOC, I recommend spending some time with this incredible free resource.
评论 #31863129 未加载
muglug将近 3 年前
I found my experience trying to work with a large OCaml base a nightmare — when signatures changed in an unstable dependency (e.g. function argument removed and nested inside another), the errors spat out by the typechecker were utterly incomphrehensible.<p>This was largely due to automatic currying in OCaml — if I have a function call &quot;some_function arg1 arg2&quot; and &quot;some_function&quot; adds a third argument, that call becomes a function that requires a single argument, arg3, but the typechecker message that tells you all of this is well-nigh unintelligible.<p>Switching to Rust was a blessed relief, not least because Rust has much better developer tooling and documentation (but also no automatic currying).<p>It made me think that OCaml is efficient and beautiful if you&#x27;re the only person touching your specific codebase (which I think is true in the vast majority of cases) <i>or</i> if many of your colleagues are deep OCaml officionados with PhDs, but it&#x27;s not a good collaborative language for the rest of us.
评论 #31861030 未加载
评论 #31861159 未加载
评论 #31861041 未加载
评论 #31861640 未加载
评论 #31870282 未加载
评论 #31862655 未加载
评论 #31862797 未加载
评论 #31861224 未加载
评论 #31868084 未加载
评论 #31861762 未加载
sshine将近 3 年前
I spent a lot of time on Standard ML in university.<p>OCaml was always portrayed as the engineer&#x27;s alternative for real applications.<p>I spent some time brushing up on OCaml a few years ago using Exercism.io.<p>While OCaml is a personal &quot;top tier&quot; language, I&#x27;d always prefer Haskell, Rust or Scala.<p>Type classes &#x2F; traits just seem to beat a higher-order module system for me.
评论 #31860805 未加载
评论 #31860337 未加载
frankohn将近 3 年前
As a former OCaml hobbyist programmer my take on these kind of books or articles is that, yes OCaml is extremely elegant and beautiful as a programming language and it shines for simple applications. Some parts of it are actually not so elegant, for example the object oriented aspect completely spoil the elegance of the core language.<p>On the other side OCaml, as a pure functional programming language with immutable value by default doesn&#x27;t scale well to large, complex application. Just the paradigm is no longer tenable and you need to switch at least partially to imperative programming with mutable variable. For example this is what it does the implementation of the OCaml itself.<p>To develop further the point about &quot;what doesn&#x27;t scale&quot; there is also the function with unnamed arguments and currying. While extremely elegant for simple programs it gets confusing for real-world applications when function needs quite a lot of arguments and there is no longer any obvious order to give them. If you stick with that and you choose an order it becomes arbitrary, difficult to remember and currying no longer makes a lot of sense.<p>Functional programming with immutable values is a wrong pattern for programming languages. Many algorithms, almost all actually, are naturally expressed in imperative style with mutable arrays or variables.<p>What is needed is to bridge the good things from OCaml, the type system, the pattern matching with tagged types into a modern, imperative programming languages.<p>Rust is a sort of answer but they got it wrong because it is too low level about managing the memory, the ownership pardon, and everything else so programmers cannot just express the algorithm or the logic they want to implement but they have to spend a lot of mental energy thinking about ownership issues and unneeded accidental complexity like lifetime annotations.
评论 #31865080 未加载
评论 #31869380 未加载
评论 #31863177 未加载
评论 #31863312 未加载
评论 #31863490 未加载
评论 #31862976 未加载
评论 #31863330 未加载
评论 #31869271 未加载
评论 #31880086 未加载
评论 #31866421 未加载
评论 #31870395 未加载
hahnbee将近 3 年前
Cornell alum here who took CS 3110. This course made me a better programmer, made me gain a sense of respect for OCaml and functional languages in general, and made me fall in love with CS. The textbook and professor are both phenomenal.
kubb将近 3 年前
My introduction to programming course in my university was in OCaml. It was all downhill from there when it comes to the programming languages I had to use.
评论 #31860564 未加载
评论 #31860935 未加载
zaptrem将近 3 年前
I took this class last semester. Michael Clarkson is an awesome professor. After learning OCaml I want pattern matching in JavaScript! Beyond the language itself, it absolutely made me a better programmer.
评论 #31861662 未加载
0x69420将近 3 年前
very grateful that this course is free for all, and the youtube lectures are neat too<p>real world ocaml 2e is nice, but like a lot of oreilly books about $LANGUAGE lately it&#x27;s a lot of thinly-veiled $COMPANY opinions on $LANGUAGE best practices, where $COMPANY is, in this case, jane street. this is great if your motivation for learning ocaml is applying for a job at jane street<p>if you think ocaml seems cool because wow jane street does epic hft in ocaml, then read real world ocaml 2e<p>if you think ocaml seems cool because wow they wrote coq&#x2F;fstar&#x2F;the early rust compiler in ocaml, then read cs3110
评论 #31870659 未加载
lairv将近 3 年前
Every time I use recent &quot;functional&quot; languages (Rust, modern Typescript) I realise how great OCaml is
评论 #31860990 未加载
christophilus将近 3 年前
I love OCaml. Fast builds, native binaries, fairly expressive and elegant once you’re accustomed to it. Now that it is multi-core, I hope it gains traction.
mark_l_watson将近 3 年前
That is a great format for an online book! The text looks like it could be read on its own for a quick review, and the hundreds of short embedded videos dig into detail.
usrn将近 3 年前
I really want to like ML but I have some complaints about OCaml in particular:<p>The stdlib is <i>very</i> weak so everyone uses this third party library. That really rubs me the wrong way.<p>All structures share a namespace for their elements which is super wacky.
评论 #31880122 未加载
m_a_g将近 3 年前
I learned some Haskell years ago but it didn&#x27;t stick with me. Lately, I want to get back into functional programming to see whether I&#x27;m missing out on something. This book looks nice, and so does OCaml. Any suggestions on books, courses, or resources on this subject?<p>Also, just to get proper motivation, why should I learn functional programming as a capable Software Engineer?
评论 #31860094 未加载
评论 #31860084 未加载
评论 #31860091 未加载
评论 #31860120 未加载
评论 #31860102 未加载
评论 #31861421 未加载
评论 #31860030 未加载
评论 #31860284 未加载
tgflynn将近 3 年前
This is a very specific question but I thought I&#x27;d ask it here on the chance someone might have a good answer.<p>I&#x27;ve been slowly working my way through this course and I ran into an issue recently when I upgraded my OCaml installation to the latest version (4.13.1). With this version I find that the simple instructions for building an executable with dune (especially one that uses OUnit) given here <a href="https:&#x2F;&#x2F;cs3110.github.io&#x2F;textbook&#x2F;chapters&#x2F;data&#x2F;ounit.html" rel="nofollow">https:&#x2F;&#x2F;cs3110.github.io&#x2F;textbook&#x2F;chapters&#x2F;data&#x2F;ounit.html</a> no longer work.<p>It seems dune now requires you to initialize a project. Does anyone know how to translate the instructions in the course to the current version of dune ?<p>I realize I could install an opam switch for the previous version but I&#x27;d rather be working with the latest one.<p>Just hoping someone might be able to save me an hour or so figuring this out on my own.
评论 #31865304 未加载
评论 #31865725 未加载
评论 #31864812 未加载
raverbashing将近 3 年前
&quot;beautiful&quot;<p>But then it has quirks like using ;; to end statements (EDIT: only in the REPL). And comments with that weird syntax<p>But worse of all are the optional parenthesis in function calls. Yes, I know Ruby has it. But it feel super weird and a needless flexibility (that causes more confusion than it solves).<p>I can&#x27;t get over this stuff, sorry.
评论 #31863495 未加载
评论 #31864997 未加载
belmont_sup将近 3 年前
Another day, another surprisingly large discussion around OCaml whenever it comes up on hn.
jcelerier将近 3 年前
I did a lot of my PhD work in OCaml. I hated pretty much every minute of it compared to C++, when comparing the exact same algorithms aha.
评论 #31861502 未加载
he0001将近 3 年前
How do I know that some code is beautiful? And how will one know that it will always stay beautiful? Correct and efficient is one thing. Beautiful? This is off topic but topics like this grinds my gears as it’s purely subjective.
omginternets将近 3 年前
Forgive this tangential question, but does anyone know of a practically-oriented tutorial for implementing an ML-style language? Any format is fine, as are books.
评论 #31872892 未加载
vijaybritto将近 3 年前
This book&#x27;s setup instructions are super easy to follow than OCaml&#x27;s own site!!
pjfin123将近 3 年前
I took this class!