News for hackers. Stuff that matters.
Re:Write Junior Code by reikonomusha on Sunday December 29, 2019 @07:19PM (#21909671)
This might be a little bit of a “hot-take”, but if idiomatic code written by a competent senior engineer remains inscrutable and unmodifiable after around 2 weeks of training an engineer who is at the beginning of their professional career, then that language is probably a bad choice to use in production. If lenses, MTL, fancy concurrency are “the way” to do things in Haskell, and those require an extraordinary amount of time to learn, then Haskell may not be a good choice for production code from a sociological POV.

I haven’t used Haskell professionally so I can’t actually weigh in on the veracity of the prominence of difficult-to-learn code. I do know about using another “weird” language though: Common Lisp. We at Rigetti took a bet with Common Lisp and it passes the “senior-written idiomatic code can be junior-learned and modified” smoke test with flying colors. Every group of interns and every new grad that has become involved in the tens of thousands of lines of code has been able to contribute substantially in less than two weeks.

Re:Write Junior Code by weavie on Monday December 30, 2019 @04:27AM (#21912075)
As someone who works with a ton of Common Lisp and a bit of Haskell, sure Common Lisp may seem easier to read at a surface level but my god am I a lot more hesitant to make any changes to our code base. Unintended side effects are everywhere.

It takes a lot of discipline to write good Common Lisp code.

With Haskell, some of the code may be a bit harder to read at first, but I always have the type signatures to help me. Quite often I dont even need to read the code because the types give me enough of the story.

I am a lot more comfortable to modify code knowing that it just isnt going to break something I wasnt aware of. Far less discipline is required to write good Haskell code. As long as the project is set up so that you don't write everything in IO, you are pretty much good to go.

I would be a lot more confident throwing a junior at a Haskell code base than a Common Lisp one knowing that they would be far less likely to break things.

It does take a bit longer to learn Haskell, but in my opinion, once you get over the hump it is oh so worth it!

Re:Write Junior Code by reikonomusha on Monday December 30, 2019 @12:32PM (#21915068)
I think good mentorship, good code review, and good tests are critical to anything, including Common Lisp. We are very strict about that and we’ve had excellent results. Non-sense and language game-playing is quickly and earnestly called out, and everybody lives a better developer life.

I’ve been on Lisp teams where that wasn’t the case and it was a free-for-all with macros and other things. That was a disaster and the code base was a gigantic Rube Goldberg contraption. But bad hygiene is possible in any environment, though Lisp has the capacity to amplify it.

Re:Write Junior Code by SaxonRobber on Sunday December 29, 2019 @08:36PM (#21910043)
Part of the trouble with Haskell is the prevalence of syntactic sugar. It is incredibly easy to make code that is tiny and indecipherable because it relies upon functions which are compositions of higher-ordered functions with monads and obscure operators that no other language has. And on top of that Haskell is lazily evaluated, which complicates it further.

And don’t even start with point-free style, a style where parameters are left implicit. For a reader point-free is appalling and way too clever.

I would say junior Haskell should be unsophisticated. Leave out the higher order abstractions and write longer code which a reader at a lower level has a hope of deciphering.

Re:Write Junior Code by monoideism on Sunday December 29, 2019 @10:33PM (#21910610)
> For a reader point-free is appalling and way too clever.

I used to believe this, but as I started to read more and more Haskell, I realized that I just had to get used to that style of writing Haskell. I now read it fine, in general. Learning to read point-free is a learnable skill.

Tons of non standard sigils, on the other hand, is a bane.

Re:Write Junior Code by 3fe9a03ccd14ca5 on Sunday December 29, 2019 @11:45PM (#21910882)
> I realized that I just had to get used to that style of writing Haskell. I now read it fine, in general.

The question of course is how true is this for the general engineering community?

Reminds me in some ways of survivor bias: those that stick successfully with Haskell tend to see the shortcomings perhaps as virtues.

Re:Write Junior Code by crimsonalucard on Wednesday January 01, 2020 @11:41AM (#21928826)
I think it's true in general. Point free style is just different from other programming styles it's not particularly unreadable.

Haskell definitely has issues, but I agree with the parent on his opinion on point free style.

Re:Write Junior Code by monoideism on Monday December 30, 2019 @12:08AM (#21910952)
I don’t think Haskell will ever be a language used by the general software development community.

For the record, my primary languages now is OCaml (and to a much lesser extent, functional Scala). But I like reading Haskell code. There are a lot of good ideas there (and no, my Scala/OCaml isn’t loaded down with custom sigils).

Re:Write Junior Code by millstone on Sunday December 29, 2019 @10:59PM (#21910713)
There's definitely a vein of deliberate unreadability. Types and parameters are often labelled positionally instead of given meaningful names. For example the graph library fgl uses typenames 'a' and 'b' instead of useful names like 'NodeLabel' and 'EdgeLabel'.
Re:Write Junior Code by monoideism on Monday December 30, 2019 @12:06AM (#21910944)
OK, those are poor stylistic practices, but they’re orthogonal to point-free style.
Re:Write Junior Code by edflsafoiewq on Monday December 30, 2019 @12:43AM (#21911084)
It is related. In point-free style the "omitted" parameters have to be distinguished positionally; they have no names at all, not even 'a' or 'b'.
Re:Write Junior Code by monoideism on Monday December 30, 2019 @10:52AM (#21914120)
> In point-free style the "omitted" parameters have to be distinguished positionally; they have no names at all, not even 'a' or 'b

Yes, that's literally the definition of point-free style.

I was referring to labeling function parameters `a` and `b`.

Also, when I checked, that's actually not what the FGL library does. It labels type parameters with `a` and `b`. Labeling generics and type parameters with letters of the alphabet is pretty typical for a wide range of languages (ie, `T` in Java, etc.). Arguably, it's a bad idea, but it's by no means unique to Haskell.

Re:Write Junior Code by nmca on Monday December 30, 2019 @05:44AM (#21912454)
^^^^^ This is extremely insightful, and now ranks as the most accurate and succinct explanation I've seen of why point-free is terrible.
Re:Write Junior Code by monoideism on Monday December 30, 2019 @11:01AM (#21914209)
It's not extremely insightful. It's literally the definition of point-free style.

Also, Haskell doesn't have labeled/keyword function parameters, regardless of whether or not you use point-free style. Sometimes, people pass in a record to achieve a similar effect, but in general, passing in a ton of parameters goes against idiomatic Haskell style.

Re:Write Junior Code by TeMPOraL on Sunday December 29, 2019 @07:38PM (#21909775)
Or, just don't hire junior developers :).

This reminds me of what my boss from my second-ever job told me when he tasked me with starting a new project: "I know I promised you you'll get to choose your own tech stack, but you're going to write it in PHP; I know you'd like something better, perhaps Ruby, but when it comes to hiring developers to help you, I'll have to pay a Ruby developer $X, and I can get PHP developers for $X/2".

I guess it makes business sense for bottom-feeder development. In my case, it burned me out completely.

Anyway, I work in Common Lisp professionally these days too, and we don't shy away from using both simple and moderately-complex macros. There's nothing magic in them. Sure, tracing a problem with the expansion of someone else's macros can be a cognitively taxing work, but you're going to have to do this kind of work somewhere anyway - if not here, then when trying to figure out a convoluted call graph of 20 functions or methods that macro would have abstracted away for you (which was a common thing to do at my previous job, involving Enterprise Java).

Re:Write Junior Code by nine_k on Sunday December 29, 2019 @08:57PM (#21910128)
Not hiring junior developers makes sense when you are still unfolding, and have a really small engineering team (< 5-7 people).

As you grow, you will see that not all work is equally important, and you want your more senior guys work on harder problems. And you will also note a number of good, smart developers applying to you who do not yet have the experience of a senior engineer, but could quickly grow.

Then you can start hiring junior engineers, and nurture them.

[Edit: grammar]

Re:Write Junior Code by nicoburns on Sunday December 29, 2019 @09:59PM (#21910428)
I'm currently working for a company whose first 4 technical hires (other than the CTO, who wasn't always involved in day-to-day development) were juniors. This was a terrible idea, as there are basic architectural mistakes baked into the codebase all over the place, and lots of issues with data integrity and things that only work most of the time. They'd have been better off with a single senior.

Agree that it makes sense to hire juniors once you've grown though.

Re:Write Junior Code by gravypod on Sunday December 29, 2019 @08:32PM (#21910024)
If no one hires junior developers then how will we make new developers?

If no one writers code that junior developers can understand, then how can we hire junior developers?

Re:Write Junior Code by eru on Sunday December 29, 2019 @11:48PM (#21910890)
> If no one hires junior developers then how will we make new developers?

Independent of the serious answer given by BurningFrog, it's also useful to understand that what's best for the world at large is not necessarily best for your company.

Re:Write Junior Code by BurningFrog on Sunday December 29, 2019 @09:29PM (#21910295)
The suggestion was to not hire junior for certain projects, where that makes sense.

This does not at all imply that no one should ever hire them. So get up from that slippery slope and start walking again!

Re:Write Junior Code by mcqueenjordan on Sunday December 29, 2019 @08:35PM (#21910036)
> Or, just don't hire junior developers :).

1. You miss a lot of great talent this way.

2. Growing and developing juniors is part of what makes a "senior."

3. This isn't sustainable advice -- if noone is hiring juniors, then where are the new seniors coming from?

Re:Write Junior Code by Eikon on Sunday December 29, 2019 @08:46PM (#21910074)
> 3. This isn't sustainable advice -- if noone is hiring juniors, then where are the new seniors coming from?

Well, as much as it is short sighted, the really is that letting some other company spend money training juniors is money you don’t have to spend.

Re:Write Junior Code by michaelmrose on Monday December 30, 2019 @01:47AM (#21911330)
If this is truly a profitable choice why are you assuming anyone will do it?
Re:Write Junior Code by kortilla on Monday December 30, 2019 @05:35AM (#21912410)
Because there are companies doing boring work that have huge developer infrastructure in place to help cheaper juniors do the mundane stuff (i.e. all of the big tech companies).
Re:Write Junior Code by Rapzid on Monday December 30, 2019 @12:36AM (#21911059)
"Junior" might as well be an IQ classification.. How many people change their IQ?

The reality is something nobody really talks about.. When a company doesn't want to hire a "junior" it doesn't mean they don't want to hire somebody without X amount of experience in a tech stack or without X amount of experience in the industry.. They don't want to hire people bellow a certain aptitude.

Many "juniors" will never be "senior". Even if they get the title and salary. We all know "seniors" in salary and title only.

Some people are inexperienced "seniors" year one.

Re:Write Junior Code by TeMPOraL on Monday December 30, 2019 @04:14AM (#21911989)
Viewing it from this lens, it still doesn't make sense to sacrifice productivity of people "with aptitude" for the sake of expanding your hiring pool to include people "without aptitude". Instead of bringing down everything to the lowest common denominator, one can try to assign different types of work to people with different levels of aptitude (or care).

(Personally, I feel what makes "forever juniors" isn't aptitude, but lack of care. I don't see it as flaw of character - the factors like structural anti-intellectualism in the industry, lack of enthusiasm due to work being meaningless, and that not everyone is into programming beyond it being a 9-to-5 job all contribute to some people not learning. This suggests to me that expecting people to learn and making learning part of their jobs - actual part, with paid time set aside for it - can overcome this problem.)

Re:Write Junior Code by nsomaru on Monday December 30, 2019 @05:12AM (#21912310)
> anti-intellectualism in the industry

Could you expand upon this point?

Re:Write Junior Code by TeMPOraL on Monday December 30, 2019 @07:07AM (#21912762)
A bit more here: https://news.ycombinator.com/item?id=21909816.

But the gist of it is: the industry prefers to work with dumbest tools possible and throw cheapest bodies they can get at a problem, instead of expecting people to keep learning, improving themselves, and applying these improvements to their work. This article is an example of that - it advocates discarding advanced tools given to the programmer by Haskell, in favor of writing dumb code that's easily digestible for beginners. Most of the advice about avoiding "clever code" is a form of that too.

I find it a penny-wise, pound-foolish approach, because when you do this trade-off, you're losing in two places. First of all, you handicap your skilled team members. But secondly, the cost (in terms of time, money and incidental complexity) of a project grows faster than linear with the number of people you get involved in it. It'll be O(n!) if you do it naively, O(n logn) if you arrange people into hierarchies, but the problems still grow faster than they're solved as you scale up.

The alternative approach I'm encouraging is to make responsible but full use of the power of the tools you have, and if this goes over the head of some new hire, then teach them until they understand and can make use of that power too. Embrace and encourage learning as a part of this job (actual, expected, and paid-for part). Push the industry upwards, instead of dragging it down.

Re:Write Junior Code by mikojan on Monday December 30, 2019 @05:26AM (#21912370)
> How many people change their IQ?

Literally all of them. However, if someone never progresses to "senior" they might've just lost interest in software development. People in general are remarkable at learning about subjects arousing their curiosity. This is an important fact, too, because environments can be designed specifically to foster just that. Not everything will be working for everybody, of course, and some might never develop an interest in that field again. But that's okay, too.

Re:Write Junior Code by sanderjd on Monday December 30, 2019 @11:16AM (#21914327)
This isn't forbidden knowledge, it's just not correct. People learn and grow with experience. Some projects can't afford to support many, or any, people in that growth stage. But lots of projects can afford it, and the investment in their growth makes sense. I think it is probably also true that some people never become competent enough for many projects, but in my experience that is diminishingly rare, whereas junior developers who are still developing their skills are extremely common (unsurprisingly, since more and more people enter the field constantly).
Re:Write Junior Code by zackmorris on Monday December 30, 2019 @04:20PM (#21916807)
Funny, I've done my best work in PHP. But, I have a semester of Scheme under my belt and have been doing object-oriented programming (or more precisely, moving away from it) for decades.

I really, really wish there was a rapid application development language like PHP or Go written over a functional language like LISP.

I've thought about writing one, and get all the way through it in my head until I come up to the inevitable problem with monads. I believe I can make it work by treating the monads as imaginary numbers with hidden contents and never really solve the problem of mutability, but I don't know what that would look like in practice yet. The language itself would basically be Javascript without mutable variables. There would be no async/await, instead, everything would be synchronous blocking with message-oriented streams in place of messages. Like the Actor model but executing immediately as a graph so it's fully deterministic.

Facebook kind of made one called Skip, although I feel like they might have been working on another one with a "z" in its name, or maybe someone else was, can't remember:

http://skiplang.com

Re:Write Junior Code by MaxGabriel on Sunday December 29, 2019 @11:07PM (#21910735)
> lenses, MTL, fancy concurrency are “the way” to do things in Haskell, and those require an extraordinary amount of time to learn, then Haskell may not be a good choice for production code from a sociological POV.

I don’t think this is the right take. Haskell is not Python—there isn’t a single way to do things such that you can say there’s one way, and it does or doesn’t work.

Haskell gives you a lot of flexibility to write code how you would like it. In my experience starting a company in Haskell, there is a subset of it which allows you to be very productive, and also get very high guarantees about the correctness of your code. I strongly recommend it.

Re:Write Junior Code by 3fe9a03ccd14ca5 on Sunday December 29, 2019 @11:47PM (#21910885)
> In my experience starting a company in Haskell

Since you have first hand knowledge of the problems outlined in the article, can you comment on how easy it is to hire non-senior Haskell engineers? And how quickly do they come up to speed in a senior devs codebase?

Re:Write Junior Code by MaxGabriel on Monday December 30, 2019 @03:53PM (#21916629)
Sort of. So far most of our hires have Haskell experience. Haskell was the main reason programmers would want to join us, so they would be naturally experienced in Haskell.

I’ll have a better idea of how non-Haskellers, including very junior engineers, pick up Haskell later this year.

Based on our limited sample size so far, I think people become productive within 4–6 weeks or so.

Re:Write Junior Code by didibus on Sunday December 29, 2019 @10:41PM (#21910645)
Now, I'm not particularly a fan of Haskell, but I think it is disingenuous to compare it apple to apple. Most junior devs had multiple years of training in imperative OOP languages prior to joining a company. So if they join a place that uses C#, and they don't know C#, but they already know how every single feature and concept of C# works, well ya, they'll be proficient in two weeks.

Similarly, had they'd been thought functional programming, some category theory, and a bit more about type theory, etc., then they'd probably be able to ramp up to Haskell in two weeks as well.

On one hand, they come knowing all the concepts and only having to learn a syntax and tool-chain. On the other, they know none of the concepts, and have to learn them all as well as learning the tooling and syntax.

Re:Write Junior Code by square_usual on Monday December 30, 2019 @12:07AM (#21910949)
GP's comment talks about how Lisp passes the two week test. Not really apples to apples with Haskell, to be sure, but it still is significantly different from C#.
Re:Write Junior Code by reikonomusha on Monday December 30, 2019 @01:09AM (#21911197)
I agree that if our educational institutions changed with respect to what’s taught around programming fundamentals, advanced Haskell would be easier to digest more quickly for someone just coming out of school. My point is sort of that that’s not the case, which potentially makes Haskell a tougher sell for the graduates of today.
Re:Write Junior Code by TrackerFF on Monday December 30, 2019 @05:20AM (#21912348)
I think a problem might be that the jr. devs don't even get the chance to look at the code, because they're not getting hired based on their lack of experience (ref. the laundry list of advanced requirements).

It reminds me of the Manager - HR pipeline, where HR people get a description of technical stuff to input in their job listings, and then proceed to gatekeep applicants away from the positions, because they don't match x % of their technical laundry list.

Re:Write Junior Code by sukilot on Sunday December 29, 2019 @07:21PM (#21909681)
Do you use On Lisp (hi, 'pg!) type stuff, with heavy macros? I don't believe a new hire can learn an On Lisp-esque custom embedded language in 2 weeks.
Re:Write Junior Code by reikonomusha on Sunday December 29, 2019 @07:27PM (#21909714)
No. Good idiomatic Lisp code might use some macros for domain-specific applications, and if those aren’t increasing readability, then they have no place in production code. A few prominent macros we do use:

- A macro to define a string lexer (aka tokenizer) for a programming language

- A macro to define peephole optimizations of linear instruction code

- A macro to define friendly looking bindings to Fortran functions

- A macro to generate highly optimized complex double precision matrix arithmetic code for inner loops

We do use “standard” macros, mostly from the ALEXANDRIA library. But these are idiomatic and have been used since at least the 80s. (Some of these are macros that On Lisp defines from scratch.)

Re:Write Junior Code by eru on Sunday December 29, 2019 @11:51PM (#21910899)
That sounds mostly like you'd want to be using something like functions, but Lisp ain't a strong enough language, so you have to use macros?

(Just for comparison, in Haskell you would probably do most of these without macros. They do have (something like) macros in Haskell, though. They are not quite as natural as in Lisp, mostly because of differences in syntax.)

Re:Write Junior Code by reikonomusha on Monday December 30, 2019 @01:06AM (#21911185)
It’s true that in a lazy functional language you can get by with fewer syntactic extensions for common programming patterns, but it doesn’t, at the end of the day, actually solve the problem of syntactic extension or code generation.
Re:Write Junior Code by eru on Tuesday December 31, 2019 @02:36AM (#21919551)
It's not just laziness, though that helps. It's also bunch of other idioms and features. (I've programmed in a strict variant of Haskell for a while.)

Ideally, a language like Haskell would actually be total by default; ie all computations are finite. For those computations, the compiler can freely choose evaluation strategies without affecting semantics.

For potentially infinite calculations, you'd go into a mode that's somewhat similar to how IO is segregated in existing Haskell.

(There's some more complications about things like infinite event-loops, that can be solved very similarly; and for some things you might want the user to provide proofs that they are indeed finite, instead of just overriding the compiler's judgement with an unsafe cast.)

Re:Write Junior Code by jgodbout on Sunday December 29, 2019 @09:18PM (#21910233)
Fixing your Lisp: (let ((pg! "Paul Graham!")) `(hi ,pg!))
Re:Write Junior Code by jgodbout on Sunday December 29, 2019 @09:19PM (#21910242)
Or, really `(hi ,pg!) but please capture that pg!
Re:Write Junior Code by OJFord on Monday December 30, 2019 @09:17AM (#21913449)
> then Haskell may not be a good choice

Or a Haskell-illiterate hire, or two weeks' max acceptable 'ramping up time', may not be a good choice.