News for hackers. Stuff that matters.
Re:Half a million lines of Go by doggodaddo78 on Sunday May 16, 2021 @01:11PM (#27175164)
Depending on functionality delivered, it sounds over-engineered if their codebase is 500 KLoC. Bragging about removing LoC would be better.
Re:Half a million lines of Go by dangoor on Sunday May 16, 2021 @02:56PM (#27176055)
> Depending on functionality delivered

This comes up often in Hacker News discussions, though usually without the qualifier I've quoted above, which I appreciate you adding. It's really easy to underestimate how much there is beneath the surface of almost any product.

People start by looking at Khan Academy and thinking "it's just a collection of videos, and even those are hosted on YouTube." But we've also got exercises and articles. Mostly created in-house, in a CMS that can handle the needs of creating math and science content. Translated into dozens of languages mostly by volunteers. Organized into courses based on, in some cases, regional curriculum.

We need to keep track of which content a learner has worked with and which skills they've mastered so that we can help them keep improving.

We connect with The College Board to help with specific SAT prep based on test results you've had.

Accounts can be logged into using Clever, which is common in school districts. They can be connected to Google Classroom, and teachers can assign content (and manage classes on the site).

We offer higher-level reporting for school districts, plus special tooling to get all of the district's students loaded into Khan Academy.

Around all of these features are the inevitable tricky edges. All of this needs to be able to handle millions of users every month.

In the process of doing this port, we _are_ actually deprecating some old and outdated stuff. Our site is 10+ years old. But most of what we have are features used by lots of people all the time.

Re:Half a million lines of Go by doggodaddo78 on Tuesday May 18, 2021 @11:00PM (#27204045)
I wonder if there's redundancies in terms of MVC patterns or there's just a lot of worker and irregular processes that don't fit neatly into MVC.

Another thing is to be careful about deprecation and feature roadmapping that's developer-whim-/assumption-led instead of customer-led. It's too easy to say "nobody uses this" or "it's not important because nobody uses it" when it can be vital to certain users.

(600 moons ago, I took the SAT-I without studying or prep: 800 math. English... let's not go there.)

Re:Half a million lines of Go by dangoor on Wednesday May 19, 2021 @08:33AM (#27207669)
I don't think we have many redundancies, especially after all of this upgrade work.

When we deprecate user-facing functionality, that's done with our product managers making the call, and involves usage data and a lot of coordination with our user support people. It's always a tough call, because someone out there won't be happy, but we have to choose the best path forward we can see at every given moment.

Re:Half a million lines of Go by doggodaddo78 on Tuesday May 25, 2021 @01:03PM (#27279369)
That's true. Can't please all of the people all of the time without an infinite amount of effort. "Perfect is the enemy..." I do try to think about important but less popular features (like bulk operations for heavy users) and accessibility concerns like deafness, blindness (screen readers, contrast, and fonts), colorblindness, photosensitive epilepsy, dyslexia, nonnative speakers (more icons and pictures), and reasonable device support.
Re:Half a million lines of Go by avl999 on Sunday May 16, 2021 @02:00PM (#27175628)
They are referencing the LoC metric to show that they are not using it for some toy CLI app used by 2 members in the team and therefore justifying the reason for this blogpost. 500k LOC doesn't seem that unreasonable, not sure how you can call it "over-engineered" without even knowing what the system is actually doing or having access to their architecture.
Re:Half a million lines of Go by thr1123 on Sunday May 16, 2021 @02:38PM (#27175938)
or maybe even toy apps becomes eccessively verbose in go, given the abundance of if err != nil and 5-rows cycles instead of item.map(fn)
Re:Half a million lines of Go by rajandatta on Sunday May 16, 2021 @07:13PM (#27178087)
This is a silly.comment unless you know the application and the domain. Excellent answer on all the things the go into an Internet facing app. Plus Education is a tricky area because the outcomes are complex - what are the paths to a certificate, diploma, certificate. Khan Academy probably wound up writing the original Python code themselves instead of a COTS product.

I'm not a big fan of LOC as a metric. You certainly can't compare languages. But the point that this is a large app and the builders are happy with their product and choice says a lot.

YMMV

Re:Half a million lines of Go by theshrike79 on Monday May 17, 2021 @08:26AM (#27182656)
Yes, writing it in KhanLang would've been just the KhanLang stdlib and:

  khanacademy.start()
Just 1 LoC! =)
Re:Half a million lines of Go by thiht on Sunday May 16, 2021 @02:24PM (#27175837)
Agree, 500kloc seems excessive. Maybe they're counting dependencies somehow? Or maybe there's a lot of hidden complexity but in the case of Khan Academy I don't have enough imagination to see where.
Re:Half a million lines of Go by nine_k on Sunday May 16, 2021 @07:08PM (#27178052)
Let's remember that every function call that can return an error normally takes these three extra lines:

  if err != nil {
    return err
  }
Re:Half a million lines of Go by doggodaddo78 on Tuesday May 18, 2021 @11:03PM (#27204066)
This is part of what I found absurd about Go. Pointless language minimalism optimization that causes N times more work for all users.

I threw in the towel and went to Rust.

Re:Half a million lines of Go by gher-shyu3i on Sunday May 16, 2021 @01:13PM (#27175184)
It's the nature of golang to be verbose like that. It has very low code density, meaning it takes writing a lot of code to express something that could have been expressed in a much more concise manner in a stronger modeling language like Java or C#.
Re:Half a million lines of Go by throwaway894345 on Sunday May 16, 2021 @01:36PM (#27175408)
I'm strongly of the opinion that people make much too big a deal out of line counts and character counts. I'm very doubtful that there will be a significant difference in quality between two equally-complex programs which differ only in that one is more terse.
Re:Half a million lines of Go by erik_seaberg on Sunday May 16, 2021 @11:37PM (#27179843)
The line count determines how much code I have to speed-read at 3 AM because prod is down. My issue with boilerplate is that we have lots of tools for generating it but no well-supported way to summarize it back to something human-readable.

I should be focusing on a high-level description of the problem, and the compiler should be filling in as much of the solution as it possibly can. My brain is made of meat and will never get any faster, so this is the only way for the profession to progress.

Re:Half a million lines of Go by doggodaddo78 on Tuesday May 18, 2021 @11:06PM (#27204079)
The codebase should be as small as possible: least surprise, readability, security, new features, and debugging.

The other way for the profession to progress is to eliminate humans (mostly) with self-programming machines (effectively, a technological singularity).

Re:Half a million lines of Go by throwaway894345 on Monday May 17, 2021 @08:36AM (#27182733)
> The line count determines how much code I have to speed-read at 3 AM because prod is down.

I disagree, it’s purely a count of newline characters per my original point (e.g., a third of the lines are just `}` or `]`).

> My issue with boilerplate is that we have lots of tools for generating it but no well-supported way to summarize it back to something human-readable

In my experience, it’s pretty easy to understand `if err != nil { return err }` and the like at a glance. Similarly a for loop that maps a `[]T` to a `[]U`.

I also dispute whether a long chain of .map().foldr().etc() is intrinsically more intuitive than a for loop, especially when the code needs to short circuit. Don’t get me wrong, I like using Rust-style iterator combinators in my hobby time, but it’s because they make me feel clever not because they are more readable than Go-style for loops.

TL;DR, I agree that our brains aren’t getting faster and that readability is important, I just don’t think newlines or the lackthereof are the measure of readability.

Re:Half a million lines of Go by gher-shyu3i on Tuesday May 18, 2021 @08:03AM (#27193554)
> it’s purely a count of newline characters per my original point

It's not simply that. Compare in golang:

    var res int
    if <some condition> {
       res = foo()
    } else {
       res = bar()
    }
to what other languages offer like

    let res = if <some condition> { foo() } else { bar() };
The golang version is both more verbose, and more error prone.

These things add up. Let alone how it takes dozens of lines of code in golang to implement what essentially is a sequence of map/filter/groupBy. The logic in languages that support the latter immediately stands out, whereas in golang you have to read it line by line to figure out what's going on.

What's ironic is that even with the proposal to add some of those to golang, they're still going to be vastly inferior to the implementations we have in Java/C#/Scala/etc. because they don't compose in golang, and are still going to be very awkward to read.

Re:Half a million lines of Go by throwaway894345 on Tuesday May 18, 2021 @11:32AM (#27196017)
I definitely like the ternary version, but to my original point I think people make too big a deal about it. With respect to map/filter/groupBy, I rarely find that solutions are clearer when expressed as chains of iterator combinators like these rather than a single for loop, especially when you're dealing with multiple collections and dealing with errors (short-circuiting). I'm writing a lot of Rust lately, and I definitely find myself dealing with this a lot in practice.