Live data from Hacker News

Simplistic programming is underrated

lemire.me

31–40 of 93 posts

Re: Simplistic programming is underrated

#31
I really liked this, because it resonates with my approach.

I think I first realized the basics of this some time in college. As a teenager around '96 I discovered IRC, and hung around chatrooms being, well, a teenager. I discovered smileys, & how 2 use abbrevs to pack more in Also related, Pascal's comment in a quickly-written letter to a friend: "I would have written a shorter letter, but I did not have the time."

Also related, Kernighan's quote on debugging: "Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"

Ultimately, I must admit that I still try to show off in my work and presentation, but I have learned that a work that is beautiful by its simplicity and humility has way more staying power than a complicated and sophisticated one ;)

Re: Simplistic programming is underrated

#32
post #8
post #3

> I like the concept of “simplistic programming” by which I mean “programming that is so simple that people will criticize you for it”. At first, that sounds strange… can we really get criticized for being “too simple”? Of course, we do. Oh man, this hits home. I've attempted to be a voice of reason on this front so many times, I've practically given up on it. I've come to the conclusion that most programmers suffer…

Is map-reduce really less simple than a for-loop? I agree with your other examples, but I see these too things as totally equivalent (unless you're in a language that make a dog's dinner of this type of thing, like old C++).

I agree: one of these things is not like the other. Map / filter / collect is not better because it is "fancy" but because those operations match the semantic intent of most operations on collections while being constrained to do a single thing. Conversely, for loops are unconstrained and reflect no intent in particular.

Re: Simplistic programming is underrated

#33
First, you're not stupid/dumb/whatever.

This idea of simplistic programming obfuscates the reality that the enterprise of software programming is one of the most complex endeavors humans have undertook. We desire simplicity because the reality is terrifying: that programming is far too complex for us to manage. That we're not smart enough to keep up. If we keep on using simple tools this reality will only continue to get uglier.

When I first started programming it was all PEEK, POKE, GOTO 10. Life was simple. Single processor, some registers, main memory, and an incredibly slow disk drive. Mastery could be achieved with a book and a few weeks off in the summer.

Since then I've worked on Mozilla, Linux, Openstack... I've written interpreters and JIT compilers, graphics engines, REST APIs, databases, eventually consisted distributed programming systems... it has only exploded in complexity.

A modern computer is a microscopic distributed system. There are no less than four cores in most computers. Several hierarchies of caches. Multiple channels between cores, main memory, and other buses. There's a clock in there that's probably wrong and an application that is running and coordinating over the terribly slow network with other processes running on other computers... it's a bit much to take in.

And yet we manage to ship software constantly.

We can do that because of abstractions.

Some abstractions are harder to understand than others. Some are made up by other programmers and given strange names and come loaded with a bunch of jargon. Others borrow theirs from existing literature like, say, mathematics.

I think more programmers are becoming interested in functional programming techniques and are learning to get over the hump of learning them because they care deeply about reliability, correctness, and expressiveness and they still want to write quick, simple programs.

You can write 4M lines of carefully crafted C and hope you didn't miss a case or off-by-one error. And that you wrote the logic correctly.

Or you could write 30k lines of Haskell and know that only errors in the logic will be present at most. And with a little more effort you might even be able to encode your propositions in your types and cover your bases there too.

It might come with a lot of jargon and seemingly-impenetrable concepts but it's worth learning.

Re: Simplistic programming is underrated

#34
post #10
post #8

Earlier quoted context omitted.

Is map-reduce really less simple than a for-loop? I agree with your other examples, but I see these too things as totally equivalent (unless you're in a language that make a dog's dinner of this type of thing, like old C++).

I think so, consider[1]: var r = array.map(x => x*x).reduce((total, num) => total + num, 0); vs its for-loop counterpart: var r = 0.0; for (var j = 0; j Maybe I'm just not as smart as everyone else, but I only have to keep like two things in my mind when looking at the for loop (easy), whereas in the map-reduce case, I need to have a very "holistic" view of what's going on (hard). [1] https://stackoverflow.com/questi…

This is interesting to me because the map reduce has way less cognitive load for me.

With map reduce I see the following:

- We've got an array

- We're going to loop through it and square everything

- We're going to take that and add it all together

- The result is r

When I read the for-loop counterpart:

- We have a variable called r that we're initializing to 0

- We're starting a loop with j as the index initialized to 0 iterating through an array

- We've got a variable x on each iteration that is the current position in the array

- We're adding the square of x to r

Maybe it's a personal quirk. for-loops make me feel stupid.

Re: Simplistic programming is underrated

#35
post #7

I agree that overcomplicating code is bad, but then again, what is "simplistic"? Let's talk Python. To me, using comprehensions is way simpler than loops. Using for i, item in enumerate(my_list): # do some stuff with i and item is way simpler than for i in range(len(my_list)): # do some stuff with i and my_list[i] And still, I bet that most C/Java folks will look at these things with disdain. Also, higher-order funct…

Counter: This is what incrementally leads to voodoo Perl scripts that only the one magician who wrote it can read. Sure all those tools are great individually. But nobody else knows what they are, so maintaining it is impossible.

In a trivial example like this, between two similar executions, I'd tend toward the C-like one for readability. Only use the language feature if it really saves a lot of lines or abstractions etc.

So java8 if I could rewrite 100 lines of code so that a whole function is just one lambda and nothing else, sure go for it. That's just a StackOverflow away for anyone. But I wouldn't toss in a lambda with a bunch of (insert new language feature) all on one line. I wouldn't expect another programmer to know all that yet.

Re: Simplistic programming is underrated

#36
post #3

> I like the concept of “simplistic programming” by which I mean “programming that is so simple that people will criticize you for it”. At first, that sounds strange… can we really get criticized for being “too simple”? Of course, we do. Oh man, this hits home. I've attempted to be a voice of reason on this front so many times, I've practically given up on it. I've come to the conclusion that most programmers suffer…

suffer from an intellectual Napoleon complex

I call it the low talent to ego ratio.

While I disagree on the map -> reduce I agree on the other positions you articulated.

Re: Simplistic programming is underrated

#37
post #10

Earlier quoted context omitted.

I think so, consider[1]: var r = array.map(x => x*x).reduce((total, num) => total + num, 0); vs its for-loop counterpart: var r = 0.0; for (var j = 0; j Maybe I'm just not as smart as everyone else, but I only have to keep like two things in my mind when looking at the for loop (easy), whereas in the map-reduce case, I need to have a very "holistic" view of what's going on (hard). [1] https://stackoverflow.com/questi…

I think your giving a bad map reduce example. It is written in a very immature functional programming style. It should be written like this, IMO: var r = array .map(square) .reduce(sum, 0); Differences: 1. Separating out actions by line 2. Pass named functions that describe what they do

Eliminating the map, named functions or not, makes it pretty clear:

var r = array.reduce((total, num) => total + (num * num), 0);

Re: Simplistic programming is underrated

#38
post #10
post #8

Earlier quoted context omitted.

Is map-reduce really less simple than a for-loop? I agree with your other examples, but I see these too things as totally equivalent (unless you're in a language that make a dog's dinner of this type of thing, like old C++).

I think so, consider[1]: var r = array.map(x => x*x).reduce((total, num) => total + num, 0); vs its for-loop counterpart: var r = 0.0; for (var j = 0; j Maybe I'm just not as smart as everyone else, but I only have to keep like two things in my mind when looking at the for loop (easy), whereas in the map-reduce case, I need to have a very "holistic" view of what's going on (hard). [1] https://stackoverflow.com/questi…

The for loop is definitely easier to debug if that is necessary. Map reduce is more concise of course.

Re: Simplistic programming is underrated

#39
post #10

Earlier quoted context omitted.

I think so, consider[1]: var r = array.map(x => x*x).reduce((total, num) => total + num, 0); vs its for-loop counterpart: var r = 0.0; for (var j = 0; j Maybe I'm just not as smart as everyone else, but I only have to keep like two things in my mind when looking at the for loop (easy), whereas in the map-reduce case, I need to have a very "holistic" view of what's going on (hard). [1] https://stackoverflow.com/questi…

This is interesting to me because the map reduce has way less cognitive load for me. With map reduce I see the following: - We've got an array - We're going to loop through it and square everything - We're going to take that and add it all together - The result is r When I read the for-loop counterpart: - We have a variable called r that we're initializing to 0 - We're starting a loop with j as the index initialized…

The biggest issue I have is with this step:

> - We're going to take that and add it all together

Here, we have an imaginary variable: namely, "that." Something that we need to keep track of and is not explicitly referenced anywhere. It's relatively easy when you only have one of these things, but with complex map-reducer logic, you can end up having a whole bunch of these.

In the for-loop, everything I use is explicitly referenced. There's no "that" -- everything is "r" or "x" or "j."

Re: Simplistic programming is underrated

#40
post #3

> I like the concept of “simplistic programming” by which I mean “programming that is so simple that people will criticize you for it”. At first, that sounds strange… can we really get criticized for being “too simple”? Of course, we do. Oh man, this hits home. I've attempted to be a voice of reason on this front so many times, I've practically given up on it. I've come to the conclusion that most programmers suffer…

People are constantly quizzed on map-reduce, spark type of stuff in interviews.

Resume 1:

> Did simplistic programming using for loops.

Resume 2:

> Map reduce using spark.

Guess which resume gets picked up by filters? Noone wants to get caught with their pants down when they have to look for their next job.

Pressure to "keep up" is unfortunate reality of our profession. Resume Driven Development is a thing.

Post reply on HN