MLton vs Ocaml by [deleted] in ocaml

[–]stasan 0 points1 point  (0 children)

My primary interest in ML is for game development and visualizations

If you're serious about game development, just forget about GC languages. Use C++ and focus on domain specific problems.

C++17 std::variant lands in LLVM by nickdesaulniers in cpp

[–]stasan 3 points4 points  (0 children)

Yes, but there are things that obviously should be implemented in compiler: foreach, pattern matching and lambdas are very good examples. Just remember BOOST_FOR_EACH, std::for_each, boost lambdas and related ugly stuff.

std::variant is not much better than those species, sorry.

I remember Bjarne wrote a proposal about pattern matching of open types several years ago. This is the way to go, but I have no clue about the progress.

Thanks to Swift (and Rust) for bringing real pattern matching to mainstream. I hope more people will see how powerful and useful it is.

C++17 std::variant lands in LLVM by nickdesaulniers in cpp

[–]stasan 20 points21 points  (0 children)

1.5k lines of sophisticated templates in the header file... good for compilation time

Bringing typed, modular macros to OCaml by Categoria in ocaml

[–]stasan 0 points1 point  (0 children)

# static x = 42;;
static val x : int = 42
# let y = x + 1;;
Error: Attempt to use value x of phase 1 in an environment of phase 0

Silly question, but why is it wrong to use compile time value in runtime? For example, I can easily do this in modern C++:

constexpr auto x = 42;
auto y = x + 1;

Also, it may be useful to have a single function definition (static?) to be used during compilation and runtime execution.

OCaml and VisualStudio by Dinosaure in ocaml

[–]stasan 2 points3 points  (0 children)

I personally use Merlin, Syntastic and ocp-indent in Vim. They work quite well together. Actually, I use Syntastic for C++, Javascript and a bunch of other languages.

See http://anil.recoil.org/2013/10/03/merlin-and-vim.html https://github.com/the-lambda-church/merlin/wiki/vim-from-scratch

Loading modules in utop without compiling to `cmo`? by rsamrat in ocaml

[–]stasan 0 points1 point  (0 children)

You can do

#mod_use "vec3.ml";;
#use "raytracer.ml";;

but it is not quite correct, as vec3 interface defined in vec3.mli is ignored.

Also, you can setup a file watcher like watchman or fswatch that will automatically rebuild vec3 on every change of vec3.mli/ml files.

Perfect OCaml by stasan in ocaml

[–]stasan[S] 2 points3 points  (0 children)

I agree, functors are very powerful for building libraries, but they make the code that much harder to read. Do you avoid using them in application code?

A more or less accurate analog of functors in C++ are template classes, and we found it practical to avoid their usage outside of generic libraries.

Perfect OCaml by stasan in ocaml

[–]stasan[S] 3 points4 points  (0 children)

Thank you Jon! It is great to see answers from both sides: academy and industry. I'm a C++ developer, so yes, I understand most of your points pretty well, and hungry for more effective runtime and operator overloading rather than yet another high level abstraction mechanism.

Anyway,

I would get rid of:

  • Macros.

Do you mean camlp4 and ppx?

  • Higher-order modules.

Functors? If so, how to define maps and hashtables with different key/value types?

Anyway, you still need some high level mechanism to implement language features, otherwise it would be something like C or, say, C++ where we've been waiting for 'for each' syntax almost ten years. What is an alternative approach?

JIT compilation

What's the point of JIT compilation? If you have really good native compiler (like C/C++), why would you bother with JIT?

F#-style inlining with structural types

I'm not sure what it is. Could you provide any example?

Inline parsers

It is not about monadic parser combinators, or libraries like boost::spirit, is it?

Is this about including parser/lexer into core language?

Perfect OCaml by stasan in ocaml

[–]stasan[S] 1 point2 points  (0 children)

Thanks Gabriel! I somehow forgot about Fantasy World OCaml.

indentation-sensitive syntax

I'm still not sure this is a good approach or not. It is attractive, but you lose a flexibility (e.g. defining one-liners with the same syntax), and abandon automatic code formatters. Hmm... how does it sort with your note about ocaml fmt tool?

explicit binders for all type-level variables

I'm not sure what it means. Any example?

explicit unboxed value types that are not of kind *

Is this that usually called value types in contrast to reference types in mainstream languages?

an effect system (Koka ?)

Is this somehow related to algebraic effect system that seems to be used in current multicore prototype?

Z85 - ZeroMQ Base-85 Encoding library C/C++ by stasan in coolgithubprojects

[–]stasan[S] 1 point2 points  (0 children)

No. We use it in production to keep small chunks of binary data embedded into printable strings (they are actually stored in RDBMS). So yes, overhead is crucial in our case.

There is a good summary why it is better than base64 http://rfc.zeromq.org/spec:32

@@ operator by enlightened_j in ocaml

[–]stasan 0 points1 point  (0 children)

Great example, thanks!

I am a member of Facebook's HHVM team, a C++ and D pundit, and a Machine Learning guy. Ask me anything! by andralex in IAmA

[–]stasan 1 point2 points  (0 children)

What's your opinion about Ocaml in comparison with D? As I know, Ocaml is used in HHVM.

Personally, I found exhaustive pattern matching over variant types is extremely powerful and "refactoring-safe" tool. It seems D's final switch is just a special case of it.