Live data from Hacker News

“Coding is basically just ifs and for loops.”

twitter.com

391–400 of 418 posts

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

#391

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…

What is more green? Coal or natural gas plants, AC lines that lose some power, building transformers, using AC to DC converters for all our power supplies, refining rare earth minerals to make decaying chemical cells, and using brushless motors (I think?) versus oil drilling with huge machines, refineries, transport and risks of oil spills, and building combustion engines? ICE looks like it can be way more efficient.

We don't need to guess, lots of time and energy has been put into answering this question:

https://evtool.ucsusa.org/

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

#392

Earlier quoted context omitted.

Despite being a joke, I know it's the "Ha Ha Only Serious" [0] sort. I can't help but think this is severely biased by the trends of "enterprise software," where you eventually "give up", and clock your 9–5 writing if+for making a fine living, but erroneously pass that off as a mature, Jedi-like way of thinking about programming, like the meme suggests. (And, consequently, you spend no less time debugging hairy, nest…

Meh, most business logic really is "if" and "foreach". That doesn't mean it's not complicated, as you say. But all that category theory stuff, at the end of the day, really is just an attempt to manage the complexity of lots of conditional branching and iteration.

If and loop aren't mathematical in the same sense as set theory and set operations are.

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

#393

Earlier quoted context omitted.

And that's also why a lot of Architecture Astronaut that looooved Java, didn't see Python coming.

Funny, I took over a modern python service and I was pretty shocked at what I inherited. Long gone are the days of "There's one way to do things". Instead, this thing would give the most "enterprisey" Spring JEE application a run for its money with its endless annotations, dependency injection magic, all sorts of pseudo-types - both the "built-in" Python 3 ones like Set and List, but also the libraries like Pydantic.…

> ...endless annotations, dependency injection magic, all sorts of pseudo-types

This sounds like what happens when a bunch of Java/C# developers jump over to python without learning the "python way" - this is more related to the developers than the project

> But nowadays, I don't think modern Python fits any use case real well

Python has effectively taken over the data science / machine learning space. For most use cases, the algorithms are massively more important than the language.

> poorly managed ecosystem and hodge-podge of tools like virtualenv, pyenv, poetry, etc. that never quite become standardized and

This is true, but Java and C# also have many issues in this respect. The move from Java 8->11 is particularly painful - many fundamental libraries related to security or connection handling were not backwards compatible. Many libraries now require multiple branches for different JDK levels. Maven and Nuget are about as good as pip - they all have weird edge cases.

I use both Java and Python on a daily basis - each has their strengths and weaknesses. Java is great if need long running processes with weeks/months of uptime, Python is great for backend data manipulation and analysis.

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

#394

Earlier quoted context omitted.

What is more green? Coal or natural gas plants, AC lines that lose some power, building transformers, using AC to DC converters for all our power supplies, refining rare earth minerals to make decaying chemical cells, and using brushless motors (I think?) versus oil drilling with huge machines, refineries, transport and risks of oil spills, and building combustion engines? ICE looks like it can be way more efficient.

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.

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

#395

In my twenties, I wanted to use all the cool PL techniques: meta-programming, reflection, monads, macros, type-level programming, etc. I'm getting older and now I want my programs to be 90–95% functions, arrays, structs, enums, and loops and only parsimoniously throw in more advanced language features.

So I hear you want Clojure.

I really don't.

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

#396

If you want to go even lower than that, coding is basically just saying yes or no in response to a yes or a no . Sure, that's oversimplifying it, but that's the smallest unit of information being changed during computation. But yes, once you learn the basics that are shared between most programming languages and don't get distracted by the nuances, it doesn't take that long to pick up a different language. Being prof…

All chemistry is just sharing electrons.

and electrons are just quarks, and quarks are just a state in a quantum field, and a quantum field is just...

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

#397

Earlier quoted context omitted.

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.

well actually I am not familiar with the phrase before, so maybe KineticLensman knows the proper meaning.

That said for that specific meaning I would prefer something like - The novice fears simplicity.

Maybe throw in a - The expert loves it - at the end.

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

#398

Earlier quoted context omitted.

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 snippets actually do the same thing, as long as you add a .findFirst() to the first example to make it valid Java code. Intermediate stream operations like map or filter are always lazy. And .findFirst() is a short-circuiting terminal operation, that does not need to consume all stream elements. https://docs.oracle.com/en/java/javase/11/docs/api/java.base...

obviously that was the point, if you don't even care to write correct code, you can make every piece of code look bad.

Truth is java streams and, even more, reactive java are the only two things that make java bearable, god save who invented them.

If I had to program java with for loops and list.add or null checks everywhere, I would probably kill myself on the spot.

But the amount of programmers taught to program like it's still 1995 it's so damn high

And I am closer to my 50s than my 40s, I can't understand why people fresh from uni say they can't understand something like

  list.stream() 
  .map(this::maybeGetUser)
  .filter(maybeUser -> userIsPresentAndNameStartsWith(maybeUser, prefix))
  .findFirst()
  .orElseThrow(new UserNotFoundException());

with the benefit of being lazy and only inspecting list items up to the first one that matches (and if you don't mutate any data, easily parallelizable)

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

#399
post #189
post #79

Earlier quoted context omitted.

- it's okay to use printing instead of a debugger - you don't need to write classes for everything - it's okay to write something in a more verbose way to make it clear for other people - your tools don't need to be perfect to get things done I need more of these, maybe some that aren't as reductionist as Carmacks's original post.

This post by Aaron Patterson made me realize it's fine to debug with print statements https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debugger... In rare cases I pull out a real debugger, but most of the time the right prints in the right places are just as good. I can also iterate much faster because I'm not jumping between the code the the debugger, or pulling the debugger out of the loop it's stuck in.

I've come to the conclusion that it's a good skill to have since it's (or logging which is basically the same) the only debugging method that's always guaranteed to be available. For example there's lots of build and CI tools out there that have no Real Debugger.
Post reply on HN