Live data from Hacker News

Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

thume.ca

101–110 of 384 posts

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#101

I think the big big result from this study is: "Python: half the size !". A dynamic language like Python is better here, 2x better. I assume similar results would apply to other dynamic languages like JavaScript, Lisp, Smalltalk, Groovy etc. This does not say that static typing should not be used but I think it shows unequivocally that there is a considerable extra development cost associated with static typing. You…

Given that they had two Rust versions where one was a third the size of the other, I don't think you should consider that a big result.

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#102
post #72

Earlier quoted context omitted.

That is all true. At the same time here the groups were allowed to use the language of their choice. Presumably they chose languages they felt they were competent in. Of course an expert of a given programming language can write much better in it than a novice. But a comparison like this is not necessarily about comparing top-programmers in every language, but average programmers, because we want to know results that…

The article says that the instructor for the course cautioned against using Haskell because some people overestimated their competency with it. I think it is actually very likely that people would chose a programming language or system for reasons other than how competent they are with it. E.g. to seem "smart" because you wrote your compiler in Haskell, even though you actually have much more experience with Java or…

> would chose a programming language or system for reasons other than how competent they are with it

Good point these were students so they were eager to learn new things. Can't blame them.

At the same time much of programming is learning new things continually. Some things are harder to learn and master than others. Seems like Haskell might be one such thing, based on what the professor says.

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#103
post #11

> I think the smaller differences are also large enough to rule out extraordinary claims, like the ones I’ve read that say writing a compiler in Haskell takes less than half the code of C++ by virtue of the language Specifically the "by virtue of the language" part: Seems to me like it's unreasonable to claim the languages are on equal footing because fancy parser libraries aren't allowed to be used for the project.…

My understanding is that in production compilers, hand rolled parsers are the norm. Parsing libraries are cool, but just aren’t used for big projects.

Excluding the lens library (as per the article) is unusual, it provides natural getter/setter and row polymorphism type functionality.

More anecdotally, I’d argue parsing libraries are common, just look at the prevalence of attoparsec and others. But most parsing libraries in the ecosystem are parser combinator libraries which don’t support as performance and nice error messages that compilers need

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#105
post #29

Earlier quoted context omitted.

And a good professor would have flunked them for poor judgment.

My professor was definitely a good professor and no way they would have done that. It clearly would have been done as an added challenge for themselves for fun and there's no reason to penalize that.

It's definitely fun: you can also take part of the challenge to be figuring out what parts of the full language are worth adding to make the overall job easier (so you're not taking the language subset as set in stone). When I did this for Python I started out in unrestricted Python, gradually both increasing what's implemented and reducing what's used. (Result at https://codewords.recurse.com/issues/seven/dragon-taming-wit...)

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#106

Earlier quoted context omitted.

A typical translation of C++ code into D reduces the line count by a substantial amount, simply because D doesn't require .h files.

What are relative compile times like? Building Chromium atm, and to be honest I'd be happy if it were written in a trillion lines of BASIC if that would somehow achieve even a 10x build time speedup.

D is known for having an extremely fast compiler. In fact, Walter Bright wrote one of the fastest C++ compilers (the Digital Mars C++ compiler) before he wrote D.

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#107
post #72

Earlier quoted context omitted.

The article says that the instructor for the course cautioned against using Haskell because some people overestimated their competency with it. I think it is actually very likely that people would chose a programming language or system for reasons other than how competent they are with it. E.g. to seem "smart" because you wrote your compiler in Haskell, even though you actually have much more experience with Java or…

> would chose a programming language or system for reasons other than how competent they are with it Good point these were students so they were eager to learn new things. Can't blame them. At the same time much of programming is learning new things continually. Some things are harder to learn and master than others. Seems like Haskell might be one such thing, based on what the professor says.

Yeah, I think the problem comes when you try to learn too many new things at once. If you're still learning about compilers, then trying to learn about functional programming on top of that is just asking for trouble.

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#108
post #11

> I think the smaller differences are also large enough to rule out extraordinary claims, like the ones I’ve read that say writing a compiler in Haskell takes less than half the code of C++ by virtue of the language Specifically the "by virtue of the language" part: Seems to me like it's unreasonable to claim the languages are on equal footing because fancy parser libraries aren't allowed to be used for the project.…

My understanding is that in production compilers, hand rolled parsers are the norm. Parsing libraries are cool, but just aren’t used for big projects.

Both OCaml and GHC use parser generators. It is incorrect to suggest production compilers hand roll parsers.

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#109
post #88
post #82

Earlier quoted context omitted.

Seems like a bit of a bold claim when the author themselves directly contradicts that in their own conclusion: > I think my overall takeaway is that design decisions make a much larger difference than the language After all, Scala was 0.7x the size and is one of the most strongly statically typed languages. So you could almost invert your conclusion and say the big result is "Python only saved 20% code lines over ful…

One factor on why Python only saves 20%. Scala has a very rich standard library. Python doesn't. An example is: https://stackoverflow.com/questions/363944/python-idiom-to-r... Ruby would have been a better example of how succinct a dynamic-typed language can be. (I made a similar comment on the parent level.)

I'm not sure what your example is illustrating. The SO question asks for the idiomatic one-liner to get the first non-null element of a list. The accepted answer does that.

    next(iter(your_list), None)
This is 100% standard library.

Re: Comparing the Same Project in Rust, Haskell, C++, Python, Scala and OCaml

#110
post #20

Loved this part and thought it was hysterical - > Since my team had all interned at Jane Street the other language we considered using was OCaml, we decided on Rust but I was curious about how OCaml might have turned out so I talked to someone else I knew had interned at Jane Street and they indeed did their compiler in OCaml with two other former Jane Street interns. Relatedly this is why I get annoyed at people tha…

Can you expand a little? I fail to see the connection between the quote and your conclusion.

Jane Street only interviews and hires really exceptional engineers. A team of exceptional engineers in a single CS class, even if it is at a school like Waterloo, would imply that the 10x phenomenon isn't a myth but a somewhat mundane reality in certain circles.
Post reply on HN