News for hackers. Stuff that matters.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by galaxyLogic on Saturday June 15, 2019 @09:02PM (#20193189)
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 are true "on average" .

The author does note he "knew (they) were highly competent". So they were not exactly novices in their language of choice. Writing a compiler is not a task for novices in general.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by tigershark on Sunday June 16, 2019 @12:42AM (#20193889)
There were people with 2k to 10k loc of experience in some language. That seems extremely low for any meaningful comparison and I would really hope that “average” programmers have way more experience than that... I think I was pretty junior after writing north of 100k loc and working on 1M loc projects. And for sure I don’t consider myself highly competent in F# after writing some thousands lines. I agree with the conclusions when they say that the design decisions are much more important than the language of choice. But I still firmly believe that the language makes a very big difference in real world projects. In toy throw away projects obviously metaprogramming cuts a lot of locs.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by jodrellblank on Sunday June 16, 2019 @06:27AM (#20194831)
When reading about APL recently, arcfide - the chap working on a GPU compiler - has expressed that he likes APL's terse code because you can throw it away and rewrite it without too much trouble. His compiler is around 750 lines of code after 6 years of development, but[1]:

"If you look at the GitHub contributions that I've made, I've made 2967 of about 3000 commits to the compiler source over that time frame. In that time I've added roughly 4,062,847 lines of code to the code base, and deleted roughly 3,753,677 line of code. [..] It means that for every one of those 750 lines, I've had to examine, rework, and reject around 5400 lines of code."

Yet a 750 loc codebase sounds like someone with very little experience and a few days or a long weekend.

I'm not saying only the trivial "some languages are denser than others", but also that it would be interesting to compare projects in total lines of code written including all commit history, and that it would be interesting to compare people's experiences and project designs in terms of "how many times something got implemented in several ways before settling on a final version", or "writing once and the design got set in concrete because it was too big to bother changing", how many prototypes that work differently were explored before deciding - and what that does to people's skills, and to project designs.

I'm guessing thousands of lines of F# would make you more skilled than the same thousands of lines of C#, even moreso if the F# was higher-abstraction than the C#, would you agree?

[1] - https://www.sacrideo.us/smaller-code-better-code/

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by nybble41 on Monday June 17, 2019 @01:06PM (#20205039)
> Yet a 750 loc codebase sounds like someone with very little experience and a few days or a long weekend.

For the purpose of evaluating experience you count the total amount of code written, not the final codebase size. Four million lines of code is a fair bit of experience in any language, even if most of those lines were later deleted or replaced.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by WalterBright on Sunday June 16, 2019 @03:24PM (#20197372)
The code I initially get to work is often pretty large and complex. Then going over it again, I can see how to shrink it and make it elegant. And then again, then again.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by Intermernet on Sunday June 16, 2019 @10:08AM (#20195507)
That's the best example of why loc is the worst indicator of both work and talent available. Thanks!
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by ginnungagap on Sunday June 16, 2019 @10:32AM (#20195629)
The github link in [1] is dead, where is the repo now? I was curious about that compiler
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by jodrellblank on Sunday June 16, 2019 @02:53PM (#20197200)
It would be unfair to leave it without the link to the HN discussion where he explains in detail his reasons for writing it that way and defends against a lot of criticism, and video stream walkthrough of the codebase as of a couple of years ago

https://news.ycombinator.com/item?id=13797797

https://news.ycombinator.com/item?id=13638086

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by vedantroy on Sunday June 16, 2019 @12:06PM (#20196152)
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by speedplane on Sunday June 16, 2019 @02:38AM (#20194155)
> There were people with 2k to 10k loc of experience in some language. That seems extremely low for any meaningful comparison ...

It's low if you're comparing languages based on the skills of experienced programmers, but most programmers are not terribly experienced. A comparison of languages by programmers that are novices to the language is still meaningful. A language that is easier for a novice to pick up and write good code is at the very least one good measure for the quality of the language.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by StreamBright on Sunday June 16, 2019 @05:23AM (#20194655)
Sure but 100k LOC Java is bot equal to 100k LOC Rust or Clojure because there is a huge discrepancy between expressiveness of those languages.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by pjmlp on Sunday June 16, 2019 @06:53AM (#20194885)
It also depends if one is using Java 12 or Java 1.4 programming style.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by StreamBright on Sunday June 16, 2019 @09:24AM (#20195316)
Exactly. Even within the same lang, it does not work.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by nybble41 on Sunday June 16, 2019 @12:41AM (#20193888)
> So they were not exactly novices in their language of choice.

The Haskell team had "maybe a couple thousand lines of Haskell each" at the start. This one project ended up being 9.7k lines, so it constitutes half of their collective experience with the language. I'd say that counts as "novice" in terms of prior Haskell experience. Under the circumstances I think they did remarkably well to produce a thoroughly tested and maintainable end product in just twice the lines of code of the quick-and-dirty Python implementation.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by danielscrubs on Sunday June 16, 2019 @04:41AM (#20194533)
I thought it very amusing that the teams focus would reflect the language: The Python implementation was as you say quick-and-dirty, while the Haskell one "caught a few edge cases that our team did not" and the C++-team did "optimizations on their IR".
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by anaphor on Saturday June 15, 2019 @09:22PM (#20193244)
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 Python.

FTA:

> Another interesting thing to note is that at the start of every offering of the course the professor says that students can use any language that can run on the school servers, but issues a warning that teams using Haskell have the highest variance in mark of any language, with many teams using Haskell overestimating their ability and crashing and burning then getting a terrible mark, more than any other language, while some Haskell teams do quite well and get perfect like my friends.

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by galaxyLogic on Saturday June 15, 2019 @10:18PM (#20193455)
> 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,... by anaphor on Saturday June 15, 2019 @10:30PM (#20193488)
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,... by willtim on Sunday June 16, 2019 @03:00AM (#20194218)
Sounds like he (edit: or more accurately, the university) has hasn't taught them enough functional programming and Haskell.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by epse on Sunday June 16, 2019 @03:20AM (#20194292)
He teaches compilers. Not programming or fp, so definitely not the professors fault
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by willtim on Sunday June 16, 2019 @03:52AM (#20194373)
Yes, but it's still a great pity, as Haskell, a descendent of ML (the "meta-language") is a suberb fit for writing a compiler.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by anaphor on Sunday June 16, 2019 @02:36PM (#20197119)
It's my understanding that UW offers some undergrad courses in Racket, but apparently they're optional so if you hadn't taken that course you might not know much about functional programming.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by 256 on Sunday June 16, 2019 @03:15PM (#20197315)
There is a mandatory compilers-lite course at UW and he teaches the advanced version of it, where the project is to fill in pieces of a Scala-lite compiler written in Scala.
Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by nine_k on Sunday June 16, 2019 @12:27AM (#20193834)
I'd say that "on average" results may be very misleading, in formal statistics and in results like this. Variance and median are very important: see comments about Haskell downthread. (Ideally you have a histogram.)

In particular, some languages with a good average may contain pitfalls that could lead to abysmal outlier results (e.g. C++ or Scala, in entirely different ways), some would keep you from doing really dangerous things but also would not let you achieve spectacular things (e.g. Go).

Re:Comparing the Same Project in Rust, Haskell, C++, Python,... by 59nadir on Sunday June 16, 2019 @02:20AM (#20194113)
> So they were not exactly novices in their language of choice. Writing a compiler is not a task for novices in general.

Only having a few thousand lines of code written in Haskell very much makes you a novice. With that said, writing a compiler in Haskell is actually pretty trivial. It's at the very least considerably easier than most other languages.