Live data from Hacker News

“Coding is basically just ifs and for loops.”

twitter.com

331–340 of 418 posts

Re: “Coding is basically just ifs and for loops.”

#332

Then what the fuck is a monad?!? Seriously I still don’t know what a monad is and apparently it’s just a bunch ifs and for loops, so I guess I’m pretty stupid.

I don't understand monads either.

They look like concise programming for mathematicians, which in my opinion, is tending towards set theory notation. https://xkcd.com/2545/

Personally I prefer more names, more XML tags, more comments, more parables, more hyperlinks, more different ways of expressing the same thing, to make it less ambiguous and easier to communicate and agree what we're all talking about.

Re: “Coding is basically just ifs and for loops.”

#333

"First a punch is just a punch, Then a punch is not only a punch, And finally a punch is just a punch" (heard from Bruce Lee) Basically it means that in the beginning we punch like we can.. then a martial arts student learns the proper and different ways to punch.. so a punch is no longer just a punch... Is a lot of instructions.. Then to sheer practice and repetition the right way to punch becomes second nature.. so…

One of my quips about programming was "it's all just ones and zeroes"

Re: “Coding is basically just ifs and for loops.”

#334

Earlier quoted context omitted.

Have you seen this? https://news.ycombinator.com/item?id=25788317 Seems like we lose a lot of good technology and progress for random reasons, like the “ram” of society is finite.

Thank you GhettoComputers for the link! And thank you Zhyl for the summary. Sounds like the 2 hard things in Computer Science returning! Cache invalidation, naming things, and off-by-one errors. [1] * "Knowledge is ephemeral": Cache invalidation * "tower of abstraction": naming things, indirection [2] Recommendations: * "Reduce complexity, reduce dependencies": minimise entropy, maximise connectedness * Learn: welcom…

The redirection he called an abstraction, and how it makes things easier to make, with less performance and in manh way it’s good, but there’s a point where it isn’t, and solutions like the idea of needing an AI to tell us everything shouldn’t be required.

I like how he talked about using bare metal to run games and not needing an OS, relying on an ISA, or how games were easier to at one point before excessive abstractions.

One very memorable comment he made was when he was asked about what he thought about the M1 chip running software faster, his response was that we could use current hardware and make it run 100x faster if it was well written. Huge part of the many reason I switched to Linux. ;)

Re: “Coding is basically just ifs and for loops.”

#335

Earlier quoted context omitted.

That’s what disappoints me in modern Java. There is practically no ifs. It makes it inaccessible to beginners on the project, and the streams are about twice as slow… just because devs think they are more clever if they pile 7 “.map()” to transform a list. list.stream().filter(Objects::nonNull).map(User::getUsername).filter(Objects::nonNull).filter(name -> name.contains(searchString)).map(name -> “We have found your…

the two snippets you posted do different things In a list John Jonhatan Joy searching for "Jo" returns all three of them in the first example, it stops when the first has been found in the second. Start including the tedious bits about adding found items to the list and the waste of intermediate variables and your "clear" code is wrapped around a lot of repetitions, that only add noise. It just happens that you are m…

The code he posted isn't actually valid because you can't "orElse" a list. That being said, I would presume it was meant to include a "findFirst". Something like

    list.stream().filter(Objects::nonNull)
        .map(User::getUsername).filter(Objects::nonNull)
        .findFirst(name -> name.contains(searchString))
        .map(name -> “We have found your user: “ + name)
        .orElse(“We haven’t found”);

Re: “Coding is basically just ifs and for loops.”

#338

Earlier quoted context omitted.

Q: What's the difference between a novice and an expert? A: The novice thinks twice before doing something stupid.

I don't understand this saying.

Often doing the stupid thing is the right thing to do, instead of thinking hard to do the smart thing that ultimately wont be needed and will be harder to understand.

So juniors thinks twice before doing stupid simple stuff. Intermediates thinks twice and does smart stuff. Seniors only does smart stuff where it is needed and does the stupid simple stuff without thinking in most places.

Re: “Coding is basically just ifs and for loops.”

#339

Earlier quoted context omitted.

That’s what disappoints me in modern Java. There is practically no ifs. It makes it inaccessible to beginners on the project, and the streams are about twice as slow… just because devs think they are more clever if they pile 7 “.map()” to transform a list. list.stream().filter(Objects::nonNull).map(User::getUsername).filter(Objects::nonNull).filter(name -> name.contains(searchString)).map(name -> “We have found your…

I don't write java, but assuming it has a null coalescing operator you can likely do all that in a single map in a way that is (in my opinion) cleaner and easier to read than both of your examples.

Kotlin does but sadly Java’s Optional has no syntactic sugar, so it ends up looking like

  Optional.ofNullable(user).map(User::getUsername).map(name -> name.contains(searchString))

Re: “Coding is basically just ifs and for loops.”

#340
post #139

Earlier quoted context omitted.

New developers write simple but shortsighted code. It gets the job done, but it will be painful to work with in the future. Intermediate developers, bitten by their past mistakes, decide to future proof their work. But they don’t just look one or two steps ahead, rather they try to look five steps ahead and identity problems that do not and may never exist. Consequently, they over-engineer, over-abstract, and over-co…

Q: What's the difference between a novice and an expert? A: The novice thinks twice before doing something stupid.

There is another important difference: the expert thinks twice before doing anything at all.
Post reply on HN