Live data from Hacker News

“Coding is basically just ifs and for loops.”

twitter.com

401–410 of 418 posts

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

#401
post #357

Earlier quoted context omitted.

ICE has thousands of uses, they aren't just for cars. An example? Up above the treeline, there are communities relying on diesel for power. Solar is a no go, with months of darkness. Wind turbines are hard to maintain at -50C, and snow and ice can impede them. Even electric cars can only cover some of car use-cases, both due to range and refuel time issues. Expect ICE in 2050 still. And in most places, electric cars…

> And in most places, electric cars take petrol out of the car, and instead, see things like coal or natural gas burned, to make the electricity to charge them. This is true, but also a good thing, while you present it as at best a wash and possibly a negative. Coal powered EVs are better than gasoline ICEs in most situations, and nobody has a 100% coal grid anymore so the benefits are even greater. There's lots of r…

> Coal powered EVs are better than gasoline ICEs in most situations

Are you taking in account battery disposal?

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

#402

Thats why i am seeing DB schemas without indexes lately. End of the day people with this kinda thinking make others to fix the broken code that they left behind. As a senior software engineer i had to spend a lot of time at night fixing code written by junior devs and interns. the code that company and devs (just ifs and loops gang) proud of was a pain in the ass for me so i quit the job entirly and do freelancing th…

4K LoC is small.

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

#403

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.

A monad is just a monoid in the category of endofunctors... duh!

A monad is like when your cat poops on the carpet, so you wrap your cat in toilet paper. Then your cat has kittens, and the kittens are born with toilet paper wrapped around them!

No here’s a better explanation:

A monad is like when you have a clock, but it’s broken and goes too fast. So you rewind it, and the next morning you wake up and it’s 5000 BC.

Or here’s a better explanation:

A monad is like when Donald Trump won the election, and then stacked the Supreme Court, and now we’re totally fucked!

That’s it! That’s exactly what a monad is!

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

#404

Earlier quoted context omitted.

Hard disagree. For loops do not have guarantees about in-place mutation; that’s why they require a full read. Anything that starts with a map/filter is guaranteed to only apply to the thing that it is assigned to. That’s more than worth its weight in grey hairs. EDIT: “full read” includes “everywhere else this array is used, which can have far-reaching consequences if it was passed into the containing function by ref…

Most temporary variables are single assignment, and many newer procedural languages do have variable declaration syntax for single-assignment variables. Such as Javascript's `let`. Another wide-spread syntax feature is for-loops over collections like `for item in list`, again being extremely easy to read and not requiring any assignments. So, accidental in-place mutation is not an issue in practice. But, in-place mut…

DB queries are a good analogy, especially if we qualify them as atomic operations. I’m hard-pressed to find a situation where procedural mutation-in-place makes more logical sense than an atomic update of the whole list, so why not make atomic updates the default?

It’s different if you’re working in lower-level code. I don’t intend to trivialize performance; the option to “go procedural” should be available. I just think it’s the wrong default. Operating systems and some kinds of Big Data need those perf boosts.

But for your run-of-the-mill CRUD app, map/filter is both clearer and safer than a for loop. Strong language support encourages this both algorithmically and syntactically—unlike what Java did, which is what I originally replied to.

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

#405

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.

It's like if you wrapped every statement ending in ; in a C program with the same macro.

I’m a Python programmer. We don’t have macros … or semicolons.

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

#406

Earlier quoted context omitted.

We don't need to guess, lots of time and energy has been put into answering this question: https://evtool.ucsusa.org/

They don’t even have a Toyota Corolla or Camry in the miniature database.

In the list of electric vehicles, I wonder why not?

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

#407
post #401

Earlier quoted context omitted.

> And in most places, electric cars take petrol out of the car, and instead, see things like coal or natural gas burned, to make the electricity to charge them. This is true, but also a good thing, while you present it as at best a wash and possibly a negative. Coal powered EVs are better than gasoline ICEs in most situations, and nobody has a 100% coal grid anymore so the benefits are even greater. There's lots of r…

> Coal powered EVs are better than gasoline ICEs in most situations Are you taking in account battery disposal?

Yes. It's actually one of the things that makes EVs greener. A lump of valuable metals in one relatively easy to access and pure form is a lot greener thing to have than a decade of combusted fossil fuels.

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

#409

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…

That’s a failure of Java’s language design, not a failure of the functional/declarative paradigm. Your for loop can do all kinds of damage to the list, and you have to read it all to find out what it does. Saner languages make the functional version more expressive.p: return first(users.filter(u => contains(u.name, searchString)) I’m not saying JS is a sane language; it has an anemic standard library without a robust…

[deleted]

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

#410

"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…

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…

Scala is super readable

   users.find(_.name.contains(str))
Post reply on HN