News for hackers. Stuff that matters.
Re:OCaml at Bloomberg by frozenport on Monday August 23, 2021 @02:39PM (#28280137)
"We worked really hard to prove our favorite language has value"

Notice the "Why we like OCaml" page could have been written for C++

https://pbs.twimg.com/media/E9fNTDYWYAoxF17?format=jpg&name=...

Re:OCaml at Bloomberg by dang on Monday August 23, 2021 @06:48PM (#28283021)
Please don't start programming language flamewars on HN. We want curious conversation here.

https://news.ycombinator.com/newsguidelines.html

Re:OCaml at Bloomberg by rvz on Monday August 23, 2021 @09:04PM (#28284012)
Oh dear. Looks like the grandparent comment totally ruined this whole post and created another language war that isn't need here.

I really wanted to know how Bloomberg uses OCaml since they are silver sponsors of OCaml [0], but it wasn't clear how they used the language in production anywhere, until right now in this post here.

But unfortunately, the opinions are mostly about X language vs Y rather than the post itself. It is ruined and that's not good at all.

[0] https://ocaml-sf.org/

Re:OCaml at Bloomberg by iso8859-1 on Monday August 23, 2021 @04:40PM (#28281627)
It would be weird for this slide to list all the things that they don't like.

But that is what they'd have to do with C++, since its problem is not the features it has, but that it has every feature.

Re:OCaml at Bloomberg by tialaramex on Monday August 23, 2021 @06:28PM (#28282812)
> it has every feature.

Not yet, but there is continued enthusiasm for adding more features to C++.

Bjarne wants it to have lifetime tracking. Wouldn't it be nice if your C++ compiler could point out that you can't very well return this object since you've no reason to think it will exist by the time you return?

Vittorio wants it to have Rust-style language version management through epochs.

Herb wants it to offer slimmer exceptions instead of the bulky mess that people often opt to switch off entirely.

All of them agree C++ is too big. However, before it can be slimmed down properly, they just have one more thing to add...

Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @03:08AM (#28285905)
Just like C keeps getting features, C2X is around the corner.

Get ready for lambdas and better generic programming support.

They just keep forgetting to add safer types.

Re:OCaml at Bloomberg by jstimpfle on Tuesday August 24, 2021 @05:34AM (#28286663)
As always, good trolling pjmlp.

There was a proposal of a some lambda thing. From looking briefly over it, it seemed too complicated to me. I hope it doesn't get included.

If you look on the Wikipedia page for C2X, there is no mention of lambda: https://en.wikipedia.org/wiki/C2x .

Instead, pretty much all that is listed there are small and useful cleanups of the standard:

    - two's complemement is required, which I assume will remove some UBs
    - Labels can appear before declarations and at the end of compound statements
    - Removal of K&R function definitions
    - Unnamed parameters in function definitions
In fact those are some of the major complaints people are having with the language currently.

As well as some very useful features that are small and self-contained

    - A feature for binary resource inclusion in the preprocessor (#embed)
    - Binary literals such as 0b10101010
    - _Static_assert
I don't know the process and the people well enough to say I agree with everything WG 14 does, but I'll say that's how you improve quality of life while staying humble. The changes I see here, no chance of having to fix some grand idea over decades, like with RAII which requires N new type specifiers and constructors, move semantics...
Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @08:16AM (#28287786)
Making my best since golden comp.lang.c and comp.lang.c.moderated days.

Wikipedia isn't always up to date, ISO mailings is where the stuff is.

http://www.open-std.org/jtc1/sc22/wg14/www/projects

http://www.open-std.org/jtc1/sc22/wg14/www/wg14_document_log...

Happy reading.

Re:OCaml at Bloomberg by jstimpfle on Tuesday August 24, 2021 @11:03AM (#28289755)
Following through and skimming your links, I cannot find a lot to back up your claims. The latest discussion of lambda in C that I can find is the following document: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1483.htm

At the very bottom:

> Summary

> The C proposal N1451 provides a new syntax for lambda expressions. While details of the proposal are unclear, it is clear that there are both significant commonalities and significant differences [NOTE: document's title is "Comparing Lambda in C Proposal N1451 and C++ FCD N3092"]. The syntax is in many places a shallow inconsistency. More deeply, the model of reference capture seems inherently incompatible. The N1451 model seems more appropriate to Smalltalk, from whence it originated, than to C/C++. If the C commitee chooses to modify the proposal to be more inline with C++, then syntactic changes to both C and C++ would provide considerable value to working programmers, who often fail to appreciate any differences in approach.

In summary, there seems to be one guy who has invested effort in a proposal, and all I can find is at best mixed reactions to this proposal, inside and outside of WG14.

While the stuff I listed in above comment is all simple or even simplifying the language, and that's what's already integrated in the working draft in the standard.

Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @04:04PM (#28294214)
There are still a couple of years until everything is voted in.

That is how ISO works, one guy writes a paper and then has to champion it.

If you are in an hurry, you can use clang's block extensions, or GCC's version thereof (nested functions).

In any case, C23 isn't K&R C.

Re:OCaml at Bloomberg by therealdrag0 on Monday August 23, 2021 @03:41PM (#28280923)
Sure. But I think it’s good that there is diversity of languages being used out there. No skin off my back for them to use OCaml so go for it!
Re:OCaml at Bloomberg by paulddraper on Monday August 23, 2021 @04:52PM (#28281773)
> "Why we like OCaml" page could have been written for C++

Okay, so they forgot the "isn't insanely complicated and abtruse" bullet point?

(EDIT: I don't mean to flame on C++. But slides notwithstanding, the difference between the two is pretty obvious.)

Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @03:27AM (#28285983)
Bloomberg is a major ISO C++ contributor as well.
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @03:17PM (#28280648)
‘Fast compilation speed’? Nah, lol
Re:OCaml at Bloomberg by fnord123 on Monday August 23, 2021 @03:44PM (#28280965)
OCaml compile speeds are not particularly fast.
Re:OCaml at Bloomberg by dwohnitmok on Monday August 23, 2021 @04:03PM (#28281206)
I'm curious do you have concrete data for this? I would love to see compile times for representative codebases of various sizes across languages and how they've changed across compiler versions.

From anecdotal experience I view OCaml's bytecode compile speeds to be on par with Go's (as a rule of thumb I expect about 1 second per 10k lines). Far slower than something like TCC, but quite fast among other languages.

Re:OCaml at Bloomberg by fnord123 on Monday August 23, 2021 @05:04PM (#28281909)
I do not have concrete data for a comparison of like for like projects being compiled with comparable lines of code, and complexity of the type system usage, running on identical machines.

As for your view of OCaml byte code compilation speed being on par with Go seems rather unlikely or I'm misunderstanding what you mean. Go is not dealing with anywhere as near a complex type system as OCaml and generates a lot more potato machine code (usually not using -mnative so you can know you can copy a binary to arbitrary machines).

Re:OCaml at Bloomberg by dwohnitmok on Monday August 23, 2021 @06:07PM (#28282594)
Hindley-Milner typechecking in practice is quite fast (as evidenced by ocamlc and Elm's compiler) and easily on par or faster than Go's typechecker (my rule of thumb for Elm code is usually 1 second per 100k lines).

In general HM-based type systems are both conceptually quite simple and can have quite fast implementations. What makes them seem "complex" is that languages with HM-based type systems also tend to make it hard to "go around" the type system and enforce much more rigid discipline around how your code can be written.

Re:OCaml at Bloomberg by reecko on Tuesday August 24, 2021 @03:26AM (#28285974)
One thing that helps OCaml here is that it requires definitions to precede usage (like C/C++). Go and most other languages don't have this requirement. Perhaps, this results in faster symbol table lookups. Moreover, OCaml boxes everything and doesn't produce monomorphized code for generic types. OCaml's code generation is also much simpler than the likes of LLVM or GCC.
Re:OCaml at Bloomberg by Zababa on Tuesday August 24, 2021 @11:51AM (#28290470)
> One thing that helps OCaml here is that it requires definitions to precede usage (like C/C++).

I think this is due to the influence of Pascal and/or Modula on the language.

Re:OCaml at Bloomberg by throwaway894345 on Monday August 23, 2021 @07:53PM (#28283554)
Isn’t pattern-matching alone combinatorial?
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @08:14PM (#28283696)
What is 'mnt pattern-matching'?

If you're asking about OCaml's pattern matching, it's compiled quite efficiently: https://www.cs.tufts.edu/comp/150FP/archive/luc-maranget/jun...

Re:OCaml at Bloomberg by throwaway894345 on Monday August 23, 2021 @08:20PM (#28283740)
Apple autocorrects poorly. I meant “isn’t pattern-matching”. And I was asking about checking exhaustiveness at compile time specifically, not about the compiled code.
Re:OCaml at Bloomberg by c-cube on Tuesday August 24, 2021 @11:46AM (#28290395)
Unless you generate code with very large pattern matches it's an absolute non issue in practice :-)
Re:OCaml at Bloomberg by dwohnitmok on Monday August 23, 2021 @08:04PM (#28283626)
There's all sorts of terrifying exponential things that affect HM typechecking in theory (e.g. pattern matching exhaustivity checking as you mention is directly equivalent to SAT, although this is technically not a part of HM typechecking, it is a feature in practice for most HM-inspired languages).

In practice it is actually very rare that they significantly affect compile times because it is very rare for the `n`-size to increase as the size of your codebase increases (these exponential blowups are generally limited to a single expression) for non-pathological code. Basically while you can have exponential blowups inside a single expression, I can't think of a time where you'll have exponential blowups across multiple expressions, which is what counts in a large codebase.

One of the times where big-O analysis doesn't accurately predict real-world runtimes.

Re:OCaml at Bloomberg by throwaway894345 on Monday August 23, 2021 @08:23PM (#28283754)
I agree that the Ns are typically small, but I don’t know how the implementation could type check as quickly as Go’s considerably simpler type system.
Re:OCaml at Bloomberg by dwohnitmok on Monday August 23, 2021 @09:38PM (#28284218)
Go's type system is actually of significant implementation complexity (in its details it's actually probably even more complex than Elm although less so than OCaml). In a typical implementation of HM the only nontrivial step (i.e. that isn't just a lookup and then checking if two constants are equal to each other) is union-find, i.e. a couple of set operations, but Go also has set operations it needs to do for type checking interfaces. So there isn't a clear performance win at a high level.
Re:OCaml at Bloomberg by throwaway894345 on Tuesday August 24, 2021 @08:31AM (#28287933)
I’m talking about computational complexity. Go might have more edge cases than Ocaml, but I don’t believe it doesn’t have to exhaustively check match statements, for example.

To be clear, I think pattern matching is a good thing.

Re:OCaml at Bloomberg by dwohnitmok on Tuesday August 24, 2021 @05:32PM (#28295266)
Indeed I was talking about computational complexity as well there when it came to set operations.

Go and HM-style type systems both have set operations they need to do that are of comparable practical computational complexity.

Exhaustivity checking without pattern matching (e.g. inserting wildcard expressions in every argument to a pattern other than the outermost tag) is computationally very straightforward and is at worst linear in the number of constructors a given type has. This is similar in computational complexity to Go's type checking of interfaces, which is also linear in the number of methods (since Go doesn't have any explicit interfaces it cannot simply do a name lookup).

  // This still checks for exhaustivity and is at worst 
  // linear in the number of `Case0`, `Case1`, etc.
  case thing of {
    Case0 x -> ...
    Case1 y -> ...
    Case2 z -> ...
  }

  // This is how you get equivalent to SAT, but is also 
  // comparatively rare
  case thing of {
    Case0 True False True -> ...
    Case1 True True True -> ...
    Case0 True True False -> ...
    // etc.
  }  
Exhaustivity checking in the presence of pattern matching is only non-linear in the number of parameters to the constructor, which in most code is only one (because beyond one usually you would use a record instead). So in practice there aren't any obvious computational edges that Go typechecking has.
Re:OCaml at Bloomberg by octachron on Tuesday August 24, 2021 @09:27AM (#28288545)
The HM type system is designed to be as fast and efficient as possible. And the OCaml typechecker is quite optimized (sometimes to the detriment of readability). Outside of GADTs heavy code, it feels unlikely to me that the exhaustiveness check matters much to the compilation time.

To add some data to the discussion, I have been recently measuring the compilation profile of some OCaml libraries, and the average time spent in the typechecker is around 40% (https://www.polychoron.fr/ocaml/2021/08/19/measuring_compila...).

Thus the complexity of the OCaml type system can only have a limited effect on OCaml compilation time.

And this measure does include interface files, where the compilation pipeline is reduced to just parsing, typechecking, and dumping the computed file to the disk.

Re:OCaml at Bloomberg by EduardoRFS on Monday August 23, 2021 @05:21PM (#28282141)
OCaml is much faster than Go in the bytecode mode, as you have interfaces files which drastically simplify the typing process.

The compiling pipeline of bytecode is basically typing -> lambda -> bytegen

Bytegen is really close to what Zinc does.

Re:OCaml at Bloomberg by reecko on Tuesday August 24, 2021 @02:31AM (#28285729)
> OCaml is much faster than Go in the bytecode mode

But doesn't the compiled code run slower in bytecode mode? I think that counts.

Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @03:30AM (#28285993)
Sure it does, bytecode is meant for development not for production builds.

The healthy mix of interpreter/JIT/AOT backends is what many languages miss on their toolchains.

Re:OCaml at Bloomberg by EduardoRFS on Monday August 23, 2021 @05:25PM (#28282179)
OCaml is really good at building in parallel. So even without that many files it can still compile using 32 threads.

Making so that a project with 20k loc is less than a second in debug mode. And recompile time in native(debug) mode is almost 100% linking time.

For bytecode you can have wild rebuild times, in the milisecond range.

Re:OCaml at Bloomberg by fnord123 on Monday August 23, 2021 @06:04PM (#28282568)
Pyre[1] is about 20k loc of ocaml[2].

    $ time make -C source -j8
    make: Entering directory '/home/fnord123/src/download/pyre-check/source'
    ../scripts/setup.sh --configure
    Build info: Linux x86_64 @ Mon Aug 23 2021 (development build)
    abort: no repository found in '/home/fnord123/src/download/pyre-check/source' (.hg not found)!
    Git commit: 1e4dd5a39db1631fd13a3a8df74d6e0f5d801fbc
    dune build @install -j auto --profile dev
           menhir parser/generator.{ml,mli}
    Warning: 31 states have shift/reduce conflicts.
    Warning: 5 states have reduce/reduce conflicts.
    Warning: 77 shift/reduce conflicts were arbitrarily resolved.
    Warning: 75 reduce/reduce conflicts were arbitrarily resolved.
    make: Leaving directory '/home/fnord123/src/download/pyre-check/source'

    real 0m43.700s
    user 4m3.030s
    sys 0m41.005s
I must be doing something wrong.

[1] https://github.com/facebook/pyre-check [2]

    $ tokei
    -------------------------------------------------------------------------------
     Language            Files        Lines         Code     Comments       Blanks
    -------------------------------------------------------------------------------
     Autoconf                2          235          204            3           28
     C                      15       242641       165361        60669        16611
     C Header               10        14267         2617        11094          556
     Coq                    10         2391         1968          220          203
     CSS                     5          713          540           44          129
     Dockerfile              2           71           42           11           18
     HTML                    2           35           30            0            5
     INI                     1           12            9            0            3
     Java                   31         2654         2080          267          307
     JavaScript              7          867          752           61           54
     JSON                   17          939          939            0            0
     Makefile                5          229          145           45           39
     Markdown               47         7213         7213            0            0
     OCaml                 791       229096       198302        10455        20339
     Python                398        61909        50119         2917         8873
     Shell                   5          111           59           34           18
     SVG                     2            2            2            0            0
     TeX                     4          929          642          129          158
     Plain Text              5          457          457            0            0
     TOML                    1            2            2            0            0
     TypeScript              2          130           84           20           26
    -------------------------------------------------------------------------------
     Total                1362       564903       431567        85969        47367
    -------------------------------------------------------------------------------
Re:OCaml at Bloomberg by Jtsummers on Monday August 23, 2021 @06:12PM (#28282656)
> Pyre[1] is about 20k loc of ocaml[2].

Reading your table, there are 198302 lines of OCaml code. That's about 10x larger than the 20k you claim. The 20339 in that row is the count of blank lines. I doubt they matter much here.

Re:OCaml at Bloomberg by fnord123 on Monday August 23, 2021 @06:25PM (#28282782)
Argh I misread the number of digits.
Re:OCaml at Bloomberg by dwohnitmok on Monday August 23, 2021 @07:18PM (#28283297)
I'd be curious if the pyre-check compilation is any faster for you either by removing the inlining optimization flag (the `-Oclassic` here https://github.com/facebook/pyre-check/blame/36243764ab81a82...) or whether there's a way to compile pyre-check to bytecode instead of the native compilation step (which unfortunately it looks like there's no easy way to modify pyre-check's build config to do so).
Re:OCaml at Bloomberg by zem on Monday August 23, 2021 @06:14PM (#28282678)
compared to what? it's definitely one of the fastest-compiling languages i use.
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @04:00PM (#28281161)
Compared to what?
Re:OCaml at Bloomberg by fnord123 on Monday August 23, 2021 @05:05PM (#28281917)
On par with Java but without maven startup time.
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @05:37PM (#28282306)
Admittedly I’m not citing actual numbers (but then again neither is anyone else here), but subjectively based on past experience, I highly doubt that. The OCaml compile is super parallelizable, with no forward references i.e. potential dependency cycles like in Java. My feeling is it blows Java out of the water.
Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @03:32AM (#28286000)
You don't need Maven to compile Java code, additionally when using Eclipse incremental compiler, files are compiled on save.
Re:OCaml at Bloomberg by rowanG077 on Monday August 23, 2021 @04:03PM (#28281195)
I really wouldn't call C++s type system expressive. And neither would I say it's community is small or enthusiastic. And compile times are fast in C++? What are you smoking?
Re:OCaml at Bloomberg by jcelerier on Monday August 23, 2021 @04:09PM (#28281281)
Can OCaml's type system express a type parametrized on a value, eg. like

  template<auto f> struct my_type{};

  using t1 = my_type<123>;
  constexpr t1 val1;
  using t2 = my_type<val1>;

?
Re:OCaml at Bloomberg by gopiandcode on Monday August 23, 2021 @07:38PM (#28283435)
It feels somewhat disingenuous to include a turing-complete meta-programming language (i.e macros) in your definition of the C++ type system.

Because vanilla OCaml doesn't have any mechanism for expressing compile-time computations, the same level of transformations aren't possible, but I wouldn't call this a limitation of the type-system, rather the meta-programming capabilities.

Although, you can somewhat approximate it with modules and functors:

     module type M = sig type t val t: t end

     let my_type (type a) (v: a) : (module M) =
       let module M = struct
         type t = a
         let t = v
       end in
       (module M : M)

     module T1 = (val my_type 123)
     type t1 = T1.t
     let val1 : t1 = T1.t
     module T2 = (val my_type val1)
     type t2 = T2.t
Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @12:54AM (#28285225)
> It feels somewhat disingenuous to include a turing-complete meta-programming language (i.e macros) in your definition of the C++ type system.

But this is literally what a type system is about ? TS definitions don't care about compile-time and run-time ; what you call "macros" are type-level functions which are a byproduct of the expressivity of C++'s TS.

Remember that expressivity of a type system is just the cardinality of the type set you can express with it.

Type systems where you can parametrize on nothing are less expressive than type systems that can parametrize on types, which are less expressive than TS which can parametrize on meta-types, which are less expressive than TS which can parametrize on meta-types and integers (C++98, Haskell afaik), which are less expressive than TS which can parametrize on meta-types and arbitrary compile-time values (C++20, soon Rust I believe ?), which I'd guess are less expressive than full-blown dependent types but I'd need to check the exact definition

Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @01:19AM (#28285360)
Actually you can extend OCaml with similar mechanisms via ppx, apparently op isn't aware of it.

https://ocamlverse.github.io/content/metaprogramming.html

Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @01:42AM (#28285484)
TIL about it, last time I wrote some OCaml camlp4 was still all the rage
Re:OCaml at Bloomberg by pjmlp on Tuesday August 24, 2021 @02:42AM (#28285793)
Yeah, it was decided to merge efforts and integrate into the compiler around the time the Real World OCaml book came out.
Re:OCaml at Bloomberg by bradrn on Tuesday August 24, 2021 @11:26AM (#28290101)
> TS which can parametrize on meta-types and integers (C++98, Haskell afaik)

Haskell also supports type-level strings and type errors, as well as arbitrary ADTs if defined with the -XDataKinds extension enabled. Not sure what you mean by ‘parametrizing on meta-types’ though.

Re:OCaml at Bloomberg by carnitine on Tuesday August 24, 2021 @03:43AM (#28286051)
Where does that definition of expressivity come from? As far as I can tell the cardinality of the ‘type set’ is omega_0 in both C++ and OCaml.
Re:OCaml at Bloomberg by rowanG077 on Monday August 23, 2021 @04:15PM (#28281331)
I haven't used ocaml but I think something is possible with GADTs. Beside the example you have given shows C++ templating prowess and not its type system. In general I wouldn't call a type system that doesn't support ADTs expressive.
Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @12:48AM (#28285204)
But GADTs are expressible in the C++ type system (thanks to templates which are just the C++ implementation of the parametrizable types typesystem-level property)
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @04:16PM (#28281349)
No, but on the other hand it doesn’t monomorphize generics and make the compiles dog slow and the binaries bloated :-)
Re:OCaml at Bloomberg by andrepd on Monday August 23, 2021 @05:22PM (#28282142)
Well, but it does make the code slower
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @05:32PM (#28282262)
I knew someone would say that :-) ‘Slower’ is super subjective. What is the actual performance requirement? And remember that the OP thread is talking about an extremely high-performance RPC system. Sure, it may not be as fast as C++, but again, what is the actual performance requirement. You don’t go around just throwing ‘Eh, not as fast as C++’ at everything you come across :-)
Re:OCaml at Bloomberg by rowanG077 on Monday August 23, 2021 @05:49PM (#28282418)
How is slower subjective? Performance of two pieces of code can be objectively measured. There is nothing subjective about it.
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @05:57PM (#28282503)
Who cares? What use is measuring the objective performance difference between two solutions if no one cares about the difference? That’s why I’m talking about the actual performance requirement.
Re:OCaml at Bloomberg by jcelerier on Monday August 23, 2021 @07:08PM (#28283207)
But what when people care ? I work in a field where individuals regularly spend 4 to 5 figures for a new CPU for a half-percent of single-core performance improvement ; computers will literally never be fast enough for what we want to do with them so our job is to leave exactly zero possibility for improvement through software
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @07:29PM (#28283376)
If you care about it, then obviously go to town on optimization, use an FPGA, whatever. But I notice you said 'CPU', which means there is a performance/cost tradeoff even in your field. Otherwise wouldn't you be using specialized hardware?

When we are talking about a general-purpose language like OCaml, then you come in talking about extreme HPC–you must realize it's not relevant in the discussion? Would you comment on threads about Golang talking about how it's not appropriate for HPC usecases?

Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @01:09AM (#28285308)
I mean, yes, FPGAs and dedicated hardware are researched and used in that field. The main reason CPUs are used "more" is due rather to convenience, and what people want to do not easily being doable on an FPGA ; for instance one of the often used programming languages there (Faust) just got an experimental FPGA port after 20+ years of existence.

But when talking about performance the point is to extract the absolute most performance possible of a given hardware, because you are building a product and you can only afford a.g. some ARM chip and need to get the most out of it to make your product's price fit for its target demographic (to, you know, make money for your business).

In particular, the main "competition" in that field is analog hardware which does not have "performance" issues (but others instead : an analog guitar distortion does not have latency but it does raise the noise floor in the signal) - everyone wants the best of both worlds and it is our job to make it happen

Re:OCaml at Bloomberg by rowanG077 on Monday August 23, 2021 @07:00PM (#28283139)
That's an incredible arrogant and close minded way to think about software. There are plenty of domains where every extra % of performance matters. Video games, HFT, robotics etc.
Re:OCaml at Bloomberg by gopiandcode on Monday August 23, 2021 @07:46PM (#28283497)
Even in these domains people still balance performance against the expressiveness of the language, or else why wouldn't everyone write their games/HFT/robotics in assembly for that "bare metal" performance?

For example, many popular game engines provide C# scripting engines _even though_ using a garbage collected language (even just for scripting) is slow (and throwing away % of performance) because the performance is _good enough_ for their usecases.

Re:OCaml at Bloomberg by rowanG077 on Monday August 23, 2021 @08:25PM (#28283768)
That's because scripts in a game are not usually a performance bottleneck if kept to best practices. And you can bet your ass both unity and unreal have some ASM in their guts.
Re:OCaml at Bloomberg by gopiandcode on Tuesday August 24, 2021 @12:08AM (#28285000)
Yes, my point exactly, and in the places where people use OCaml, the overhead from not monomorphising generics isn't a performance bottleneck.
Re:OCaml at Bloomberg by rowanG077 on Tuesday August 24, 2021 @12:59AM (#28285259)
That's a self fulfilling prophecy. Of course OCaml isn't used there... Because it can't hit the performance target.
Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @01:39AM (#28285473)
Exactly, I mainly work on a C++ software and for my PhD rewrote all the core algorithms in OCaml... Boy that was slow, I'm never ever touching that language again for anything that needs peak performance.
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @07:30PM (#28283384)
Yeah, that's why I asked, who cares? If you care about it, then obviously you need it. Also, https://news.ycombinator.com/item?id=28283376
Re:OCaml at Bloomberg by scns on Tuesday August 24, 2021 @01:37AM (#28285457)
Well, Jane Street do HFT in OCaml.
Re:OCaml at Bloomberg by krapht on Monday August 23, 2021 @06:16PM (#28282704)
This is a pretty obnoxious way to tell me you don't work on real-time systems without explicitly saying you don't work on real-time systems.
Re:OCaml at Bloomberg by yawaramin on Monday August 23, 2021 @06:31PM (#28282840)
I didn't realize we were exclusively talking about real-time systems? Do you think people you argue with on HN are so dumb that they would go around claiming high-level GC languages are suitable for real-time systems?
Re:OCaml at Bloomberg by jolux on Monday August 23, 2021 @06:50PM (#28283046)
I feel like if your concern is real-time systems, you should probably say you don’t think it’s suitable for real-time systems, instead of talking about performance differences that no one really disagrees but which don’t matter in practice for most applications anyways.
Re:OCaml at Bloomberg by detaro on Monday August 23, 2021 @06:32PM (#28282867)
Asking about the actual requirement sounds very much like what you do in real-time systems, vs just being happy with "faster"?
Re:OCaml at Bloomberg by rixed on Tuesday August 24, 2021 @02:25AM (#28285702)
Please do not argue like that. I understand you are a fan of the language, I love the OCaml language myself. But pretending execution speed does not matter is disserving the cause, especially since many people came to OCaml because it's a great trade off between execution speed, expressivity and safety.
Re:OCaml at Bloomberg by yawaramin on Tuesday August 24, 2021 @09:35AM (#28288654)
Please re-read my comment :-) Nowhere did I say:

> execution speed does not matter

What I actually said: what is the actual performance requirement?

I don’t get why this is such a hard concept for people in this thread :-) Obviously you should use the right tool for the job! If you have extreme HPC requirements, no one (except maybe Jane Street) is going to use OCaml for that. It’s a high-level GC language! When you come into a thread, have some basic context about what it’s about.

Re:OCaml at Bloomberg by maattdd on Tuesday August 24, 2021 @02:29AM (#28285717)
"Slow" can be subjective indeed, but not "slower".
Re:OCaml at Bloomberg by stonemetal12 on Monday August 23, 2021 @06:43PM (#28282977)
Not exactly types, but with functors you can parameterize modules on values. As far as I can tell it ends up being very similar.
Re:OCaml at Bloomberg by paulddraper on Monday August 23, 2021 @05:04PM (#28281907)
No, the type system parameterizes on types.
Re:OCaml at Bloomberg by adamwk on Monday August 23, 2021 @06:08PM (#28282611)
People are downvoting but the GP's point does not really have anything to do with type systems. I think this example is closer to macro expansion than a typesystem.
Re:OCaml at Bloomberg by jcelerier on Monday August 23, 2021 @07:04PM (#28283175)
How is paramerization of types on values not a typesystem-level property ? There's definitely nothing akin to macro expansion involved since you can do type-level computations that way
Re:OCaml at Bloomberg by throwaway17_17 on Monday August 23, 2021 @07:32PM (#28283398)
I’m pretty sure the implication is that since template instances are made specific at compile time and are done so in a way that is very analogous to AST based macro expansion. Specifically, C++ templates are a programming language which runs during the compilation of C++ code that acts by producing valid C++ AST components.
Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @01:37AM (#28285459)
I have never seen a definition of type system which cares about things being done at compile-time or runtime, or that there even is a compile-time or run-time
Re:OCaml at Bloomberg by rixed on Tuesday August 24, 2021 @02:29AM (#28285718)
Never heard of static vs dynamic type checks ?
Re:OCaml at Bloomberg by jcelerier on Tuesday August 24, 2021 @02:42AM (#28285786)
Expressiveness of type systems is about which types (and thus type checks) you can express, not when the type checking occurs
Re:OCaml at Bloomberg by LAC-Tech on Monday August 23, 2021 @08:23PM (#28283751)
I am guessing it could using PPX

https://ocamlverse.github.io/content/metaprogramming.html

In C++ the system for generics is the same system for metaprogramming. In OCaml they are two different systems.