Live data from Hacker News

Improvements to OCaml code editing: the basics of a refactor engine

tarides.com

11–20 of 21 posts

Re: Improvements to OCaml code editing: the basics of a refactor engine

#11
Tarides has an OCaml focus. Elsewhere on their site, with an interesting omission:

"Examples of functional programming languages include OCaml, Erlang, Clojure, Haskell, Scala, and Common Lisp."

F# and OCaml are close cousins, and for me F# is even cleaner syntax and twice as fast (M4 Mac Studio).

It was a struggle for me to overcome my partisan preference for OCaml.

Re: Improvements to OCaml code editing: the basics of a refactor engine

#12

I feel that Ocaml could really use better VSCode integration more than literally anything else, but the community seems completely oriented around emacs

We try to invest equal time between the OCaml platform (on VSCode) and OCaml-eglot (for Emacs). In fact, I find the VSCode extension to be rich (and generally iso-features with Emacs mode).

However, I (as maintainer of OCaml-eglot) find Emacs easier to extend (the VSCode extension is surprisingly complex when you stray from the beaten path), which seemed perfect for incubating an experimental feature. Furthermore, as mentioned at the end of the article, the feature can also be invoked from a code action, which makes it de facto callable from VSCode once the various PRs have been merged :)

Re: Improvements to OCaml code editing: the basics of a refactor engine

#13
post #12

I feel that Ocaml could really use better VSCode integration more than literally anything else, but the community seems completely oriented around emacs

We try to invest equal time between the OCaml platform (on VSCode) and OCaml-eglot (for Emacs). In fact, I find the VSCode extension to be rich (and generally iso-features with Emacs mode). However, I (as maintainer of OCaml-eglot) find Emacs easier to extend (the VSCode extension is surprisingly complex when you stray from the beaten path), which seemed perfect for incubating an experimental feature. Furthermore, as…

The LSP features, in my experience, work very well in VScode, no shade there. But debugging features like breakpoints still seem to be experimental? Whenever I ask others about it online they usually try to tell me that print debugging is superior anyways

Re: Improvements to OCaml code editing: the basics of a refactor engine

#15

I feel that Ocaml could really use better VSCode integration more than literally anything else, but the community seems completely oriented around emacs

My experience is that everything goes into Merlin, which is Ocaml tool for analysis and refactoring, and is then added to editor from there.

Here significant work was done to properly bridge the gap between Merlin and the LSP server so it should work fine in VSCode.

Generally speaking, the Ocaml community seems to spend a lot of time getting VSCode to work.

Re: Improvements to OCaml code editing: the basics of a refactor engine

#16

Tarides has an OCaml focus. Elsewhere on their site, with an interesting omission: "Examples of functional programming languages include OCaml, Erlang, Clojure, Haskell, Scala, and Common Lisp." F# and OCaml are close cousins, and for me F# is even cleaner syntax and twice as fast (M4 Mac Studio). It was a struggle for me to overcome my partisan preference for OCaml.

F# started as an Ocaml port to the CLR. In the end, they decided to port a subset of the language so you get mostly the same syntax, no parametrised modules which is a big part of Ocaml but in exchange you can call libraries from other languages using the CLR. Of course, that comes with the issue of being a second class citizen in the .Net family, albeit a very nice second class citizen.

F# have drifted a bit further since but not that much. It’s a nice language but it’s not really comparable to Ocaml at this point. At least, I don’t see many cases where people would have to chose one or the other. I think people know if they want the CLR or not.

Re: Improvements to OCaml code editing: the basics of a refactor engine

#17
post #2

Very cool! Does it replace identical expressions in the same scope? Like: let tau = 3.14 +. 3.14 becomes let pi = 3.14 let tau = pi +. pi ? EDIT: Or even crazier with function: let _ = (x + 1) + (y + 1) becomes let plus_one a = a + 1 let _ = (plus_one x) + (plus_one y) (I ask this just out of curiosity. Even the "simpler" version is very impressive!)

LLM generated variable names would be nice!

Re: Improvements to OCaml code editing: the basics of a refactor engine

#18

Tarides has an OCaml focus. Elsewhere on their site, with an interesting omission: "Examples of functional programming languages include OCaml, Erlang, Clojure, Haskell, Scala, and Common Lisp." F# and OCaml are close cousins, and for me F# is even cleaner syntax and twice as fast (M4 Mac Studio). It was a struggle for me to overcome my partisan preference for OCaml.

F# started as an Ocaml port to the CLR. In the end, they decided to port a subset of the language so you get mostly the same syntax, no parametrised modules which is a big part of Ocaml but in exchange you can call libraries from other languages using the CLR. Of course, that comes with the issue of being a second class citizen in the .Net family, albeit a very nice second class citizen. F# have drifted a bit further…

I make little use of .NET; my hand-coded atomic queue is faster than .NET work stealing for parallelism, for example. I like the slightly cleaner syntax and twice as fast for my applications.

I'm escaping the black hole of Haskell. If one can code in Chez Scheme, one can code without parametrized modules, as much as I admire them. And there are also F# additions OCaml could admire.

I held back for all of your reasons, and finally caved. I never saw myself in the .NET ecosystem, but prejudices are a funny thing.

Re: Improvements to OCaml code editing: the basics of a refactor engine

#19

Earlier quoted context omitted.

F# started as an Ocaml port to the CLR. In the end, they decided to port a subset of the language so you get mostly the same syntax, no parametrised modules which is a big part of Ocaml but in exchange you can call libraries from other languages using the CLR. Of course, that comes with the issue of being a second class citizen in the .Net family, albeit a very nice second class citizen. F# have drifted a bit further…

I make little use of .NET; my hand-coded atomic queue is faster than .NET work stealing for parallelism, for example. I like the slightly cleaner syntax and twice as fast for my applications. I'm escaping the black hole of Haskell. If one can code in Chez Scheme, one can code without parametrized modules, as much as I admire them. And there are also F# additions OCaml could admire. I held back for all of your reasons…

> prejudices are a funny thing

I don’t think people have prejudices here. Ocaml is Ocaml and F# is F#.

If your point is that people using OCaml should instead use F#, I vehemently disagree. That would be losing most of what makes Ocaml actually Ocaml.

Still F# is a nice language. F# without using .Net library I don’t see the point however. It’s the most interesting part of the language.

Re: Improvements to OCaml code editing: the basics of a refactor engine

#20
post #2

Very cool! Does it replace identical expressions in the same scope? Like: let tau = 3.14 +. 3.14 becomes let pi = 3.14 let tau = pi +. pi ? EDIT: Or even crazier with function: let _ = (x + 1) + (y + 1) becomes let plus_one a = a + 1 let _ = (plus_one x) + (plus_one y) (I ask this just out of curiosity. Even the "simpler" version is very impressive!)

Most refactoring engines don't automatically replace all identical expressions by default since it can change semantics (especially with side effects), but they typically offer a separate "introduce and replace all occurrences" option that you can explicitly choose.
Post reply on HN