OCaml

来自开放百科 - 灰狐
(版本间的差异)
跳转到: 导航, 搜索
(项目)
(简介)
(未显示1个用户的37个中间版本)
第6行: 第6行:
  
 
==简介==
 
==简介==
OCaml,最早称为Objective Caml,是Caml编程语言的主要实现,由Xavier Leroy,Jérôme Vouillon,Damien Doligez,Didier Rémy及其他人于1996年创立,OCaml是开放源代码项目。
+
OCaml,最早称为 Objective Caml,是 Caml 编程语言的主要实现,由 Xavier Leroy,Jérôme Vouillon,Damien Doligez,Didier Rémy 及其他人于1996年创立,OCaml 是开放源代码项目(LGPLv2.1)。
  
OCaml一般用于编译器、程序分析、金融交易、虚拟机等方面。它是Jane Street的核心语言,重点是用它写实时交易系统会很赚钱。
+
OCaml 一般用于编译器、程序分析、金融交易、虚拟机等方面。它是 Jane Street 的核心语言,重点是用它写实时交易系统会很赚钱。
  
 
[[F Sharp|F#]],Microsoft [[.NET]]平台上 OCaml 风格的编程语言。
 
[[F Sharp|F#]],Microsoft [[.NET]]平台上 OCaml 风格的编程语言。
 +
 +
[[ML]] 家族的两个主要的方言是 Standard ML 和 OCaml。
  
 
==Windows==
 
==Windows==
第16行: 第18行:
  
 
==指南==
 
==指南==
 +
[https://ocamlverse.github.io/ OCamlverse] Documenting everything about OCaml
 +
 
完成第一个OCaml程序,Hello World!,创建test.ml文件,包含:  
 
完成第一个OCaml程序,Hello World!,创建test.ml文件,包含:  
 
  let _=print_endline "hello world!"  
 
  let _=print_endline "hello world!"  
第23行: 第27行:
 
   ./test
 
   ./test
 
REPL
 
REPL
$ ocmal 或 $ utop
+
  $ ocmal 或 $ utop // eval $(opam config env)
 
   utop # let () = print_endline "Hello OCaml World!";;
 
   utop # let () = print_endline "Hello OCaml World!";;
 
   Hello OCaml World!   
 
   Hello OCaml World!   
第51行: 第55行:
 
==项目==
 
==项目==
 
[https://github.com/rizo/awesome-ocaml Awesome OCaml] [[image:awesome.png]]
 
[https://github.com/rizo/awesome-ocaml Awesome OCaml] [[image:awesome.png]]
 +
*[https://ocamlverse.github.io/content/ecosystem.html OCaml ecosystem] [https://ocamlverse.github.io/content/compilers.html Compilers, Typecheckers, and Parsers] [https://ocamlverse.github.io/content/security.html Security and Cryptography] [https://ocamlverse.github.io/content/static_analysis.html Static Analysis] [https://ocamlverse.github.io/content/testing.html Testing] [https://ocamlverse.github.io/content/software_verification.html Formal Software Verification] [https://ocamlverse.github.io/content/protocols.html Protocols]
 +
*[https://forge.ocamlcore.org/ OCaml Forge] Deprecating the Forge in 2017
 
*[https://github.com/OCamlPro OCamlPro]
 
*[https://github.com/OCamlPro OCamlPro]
*[https://coq.inria.fr/ Coq]
+
*[https://github.com/ocamllabs/ OCaml Labs]
*[https://github.com/mirage/mirage MirageOS]
+
*[https://dune.build/ Dune] is a build system for OCaml projects with support for [[Reason]] and [[Coq]]
*[https://github.com/reasonml/reason Reason] 是一门基于 OCaml 强大类型系统的编程语言,并拥有让 [[JavaScript]] 和 C 语言家族开发者所熟悉的语法。
+
*[https://github.com/ocsigen Ocsigen] Multi-tier programming for Web and mobile apps
 +
*[https://github.com/BinaryAnalysisPlatform/bap Binary Analysis Platform]
 +
*[[Coq]] [https://github.com/mit-plv Programming Languages and Verification Group at MIT CSAIL]
 +
*[https://github.com/savonet/liquidsoap Liquidsoap] Audio & Video Streaming Language
 +
*[https://github.com/owlbarn Owl] - OCaml Scientific Computing
 +
*[https://github.com/mirage MirageOS] 一个用于构建安全、高性能网络应用的库(library)操作系统
 +
*[https://github.com/rescript-lang/rescript-compiler ReScript Compiler]
 +
*[[Reason]] 是一门基于 OCaml 强大类型系统的编程语言,并拥有让 [[JavaScript]] 和 C 语言家族开发者所熟悉的语法。
 +
*[https://github.com/esy/esy esy] Easy package management for native Reason, OCaml and more
 +
*[https://aeternity.com/#sophia aeternity Sophia] is a Ocaml-like language with syntax mostly resembling that of Reason.
 
*[https://github.com/mirage/irmin Irmin]数据库
 
*[https://github.com/mirage/irmin Irmin]数据库
 
*[https://github.com/mirage/ocaml-cohttp ocaml-cohttp] 非常轻量的HTTP server
 
*[https://github.com/mirage/ocaml-cohttp ocaml-cohttp] 非常轻量的HTTP server
第60行: 第75行:
 
*[https://github.com/docker/datakit datakit] from [[Docker]] team.
 
*[https://github.com/docker/datakit datakit] from [[Docker]] team.
 
*[https://github.com/docker/vpnkit vpnkit] from [[Docker]] team.
 
*[https://github.com/docker/vpnkit vpnkit] from [[Docker]] team.
*[https://github.com/janestreet/core Jane Street Capital's standard library overlay]
 
 
*[https://github.com/realworldocaml/ Real World OCaml]
 
*[https://github.com/realworldocaml/ Real World OCaml]
 
*[https://github.com/ocsigen ocsigen]
 
*[https://github.com/ocsigen ocsigen]
 
*[[Haxe]]
 
*[[Haxe]]
 
*[https://github.com/moby/datakit DataKit] -- Orchestrate applications using a Git-like dataflow
 
*[https://github.com/moby/datakit DataKit] -- Orchestrate applications using a Git-like dataflow
Facebook也发布了一些OCaml开源项目
+
*[https://github.com/bcpierce00/unison Unison File Synchronizer]
 +
*[https://blog.janestreet.com/deep-learning-experiments-in-ocaml/ Deep learning experiments in OCaml] [https://github.com/LaurentMazare/tensorflow-ocaml TensorFlow OCaml bindings]
 +
*[https://github.com/input-output-hk/qeditas-ledgertheory Ledger Theory] Coq开发的轻量级加密账本理论
 +
Jane Street 开源的 Ocaml 项目
 +
*[https://github.com/janestreet Jane Street @ GitHub]
 +
*[https://github.com/janestreet/core Jane Street Capital's standard library overlay]
 +
*[https://github.com/janestreet/hardcaml Hardcaml] is an OCaml library for designing hardware.
 +
*[https://github.com/janestreet/incr_dom Incr_dom]: a library for writing dynamic web-apps [https://blog.janestreet.com/a-tutorial-for-building-web-applications-with-incrdom/ A tutorial for building web applications with Incr_dom]
 +
Facebook 开源的 OCaml 项目
 
*[https://github.com/facebook/hhvm/tree/master/hphp/hack Hack] is a programming language for [[HHVM]]
 
*[https://github.com/facebook/hhvm/tree/master/hphp/hack Hack] is a programming language for [[HHVM]]
 
*[https://github.com/facebook/flow flow] Adds static typing to JavaScript to improve developer productivity and code quality.  
 
*[https://github.com/facebook/flow flow] Adds static typing to JavaScript to improve developer productivity and code quality.  
第85行: 第107行:
 
*[http://book.huihoo.com/developing-applications-with-objective-caml/ Developing applications with Objective Caml]
 
*[http://book.huihoo.com/developing-applications-with-objective-caml/ Developing applications with Objective Caml]
  
==开发者==
+
==开发==
 +
*[https://github.com/ocaml/ocaml/blob/trunk/HACKING.adoc Hacking the compiler]
 +
*[https://github.com/ocamllabs/compiler-hacking/wiki/Compiler-or-Language-projects-to-work-on Compiler or Language projects to work on]
 
*[https://www.zhihu.com/people/hongbo_zhang 张宏波] 前[https://github.com/ocaml OCaml编译器]核心作者, [https://github.com/bloomberg/bucklescript BuckleScript] 作者。
 
*[https://www.zhihu.com/people/hongbo_zhang 张宏波] 前[https://github.com/ocaml OCaml编译器]核心作者, [https://github.com/bloomberg/bucklescript BuckleScript] 作者。
  
 
==用户==
 
==用户==
 
*[[Facebook]]
 
*[[Facebook]]
*[https://tech.esper.com/ Esper]
+
*[https://esper.com/ Esper]
 
*[https://blogs.janestreet.com/why-ocaml/ Jane Street是OCaml最大的用户] [https://www.zhihu.com/search?type=content&q=Jane+Street 知乎上的一些信息] [https://github.com/janestreet at github] [https://www.quora.com/Why-doesnt-Jane-Street-switch-from-Ocaml-to-F Why doesn't Jane Street switch from Ocaml to F#?]
 
*[https://blogs.janestreet.com/why-ocaml/ Jane Street是OCaml最大的用户] [https://www.zhihu.com/search?type=content&q=Jane+Street 知乎上的一些信息] [https://github.com/janestreet at github] [https://www.quora.com/Why-doesnt-Jane-Street-switch-from-Ocaml-to-F Why doesn't Jane Street switch from Ocaml to F#?]
 
*[https://github.com/xapi-project/ Citrix]
 
*[https://github.com/xapi-project/ Citrix]
第99行: 第123行:
 
<gallery>
 
<gallery>
 
image:lexifi-ide.png|LexiFi IDE
 
image:lexifi-ide.png|LexiFi IDE
 +
image:owl-architecture.png|owl架构
 +
image:ocaml-compiler-pipeline.png|OCaml编译器
 
</gallery>
 
</gallery>
  
第105行: 第131行:
 
*[https://github.com/ocaml/ocaml OCaml @ GitHub]
 
*[https://github.com/ocaml/ocaml OCaml @ GitHub]
 
*[https://ocaml.org/community/planet/ OCaml Planet]
 
*[https://ocaml.org/community/planet/ OCaml Planet]
 +
*[https://blog.janestreet.com/using-ocaml-to-drive-a-raspberry-pi-robot-car/ Using OCaml to drive a Raspberry Pi robot car]
 
*[https://ocaml.org/learn/tutorials/index.zh.html OCaml中文教程]
 
*[https://ocaml.org/learn/tutorials/index.zh.html OCaml中文教程]
*http://caml.inria.fr/ocaml/
+
*[https://caml.inria.fr/ The Caml language]
 
*http://docs.huihoo.com/ocaml/
 
*http://docs.huihoo.com/ocaml/
 
*http://download.huihoo.com/ocaml/
 
*http://download.huihoo.com/ocaml/

2021年12月31日 (五) 04:16的版本

Wikipedia-35x35.png 您可以在Wikipedia上了解到此条目的英文信息 OCaml Thanks, Wikipedia.

OCaml

OCaml-Logo.png

目录

简介

OCaml,最早称为 Objective Caml,是 Caml 编程语言的主要实现,由 Xavier Leroy,Jérôme Vouillon,Damien Doligez,Didier Rémy 及其他人于1996年创立,OCaml 是开放源代码项目(LGPLv2.1)。

OCaml 一般用于编译器、程序分析、金融交易、虚拟机等方面。它是 Jane Street 的核心语言,重点是用它写实时交易系统会很赚钱。

F#,Microsoft .NET平台上 OCaml 风格的编程语言。

ML 家族的两个主要的方言是 Standard ML 和 OCaml。

Windows

指南

OCamlverse Documenting everything about OCaml

完成第一个OCaml程序,Hello World!,创建test.ml文件,包含:

let _=print_endline "hello world!" 

编译 test.ml

ocamlc test.ml -o test  // Byte-code编译
或 ocamlopt test.ml -o test // Native-code编译
 ./test

REPL

 $ ocmal 或 $ utop // eval $(opam config env)
 utop # let () = print_endline "Hello OCaml World!";;
 Hello OCaml World!  

类型

 utop # (1, "str1", 2.);; // 元组tuple
- : int * string * float = (1, "str1", 2.)     
 utop # [1; 2; 3];; // 列表list
- : int list = [1; 2; 3]  
 utop # [|1; 2; 3|];; 数组array
- : int array = [|1; 2; 3|]   
 utop # type vec2 = { x : float; y : float };; //记录record
type vec2 = { x : float; y : float; }

常见问题

Error: Unbound module Core

vim ~/.ocamlinit 加入以下内容,并重新运行utop

#use "topfind"
#camlp4o
#thread
#require "core.top"
#require "core.syntax"

-bash: ocamlfind: command not found

eval $(opam config env)

项目

Awesome OCaml Awesome.png

Jane Street 开源的 Ocaml 项目

Facebook 开源的 OCaml 项目

  • Hack is a programming language for HHVM
  • flow Adds static typing to JavaScript to improve developer productivity and code quality.
  • Reason: Build Systems Rapidly
  • Infer is a static analysis tool for Java, Objective-C and C, written in OCaml.
  • pfff Tools for code analysis, visualizations, or style-preserving source transformation.

课程

文档

书籍

开发

用户

更多用户成功故事

图集

链接

分享您的观点
个人工具
名字空间

变换
操作
导航
工具箱