Live data from Hacker News

The computers are fast, but you don't know it

shvbsle.in

211–220 of 819 posts

Re: The computers are fast, but you don't know it

#211
post #180

Earlier quoted context omitted.

It's not "twice as long" in any syntactic sense, and readability is easily fixed: Enumerable.Range(1,50) .Where(e => e % 4 == 0 && e % 3 == 0) .Skip(1) .Select(e => e + 1) That's very understandable, it's clear what it does, and if your complaint is that dotnet prefers to name expressions like Skip rather than magic syntax, we can disagree on what make things readable and easy to maintain.

It's literally "twice as long" syntactically. 120 vs. 67 characters. And again, you keep omitting the rest of the line. (Why?) What you should've written in response was: var y = Enumerable.Range(1,50) .Where(e => e % 4 == 0 && e % 3 == 0) .Skip(1) .Select(e => e + 1) .ToArray(); Compare: y = [t[1] for t in enumerate(range(1, 50, 4)) if t[0] % 3 == 0][2:] And (again), my complaint isn't about LINQ or numbers or these…

The ToArray is unneccessay, it's much more idiomatic dotnet to deal with IEnumerable all the way through.

The only meaningful difference in lengths is that C# doesn't have an Enumable.Range(start, stop, increment) overload but it's easy enough to write one, and then it'd be essentially the same length.

Re: The computers are fast, but you don't know it

#212
post #6

I've been lightly banging the drum the last few years that a lot of programmers don't seem to understand how fast computers are, and often ship code that is just miserably slower than it needs to be, like the code in this article, because they simply don't realize that their code ought to be much, much faster. There's still a lot of very early-2000s ideas of how fast computers are floating around. I've wondered how m…

Python allows one to save development time in exchange for execution time

I've not found that to be the case. The first draft might get done faster, but then I spend more time debugging issues in dynamic languages that only show up at runtime that the compiler would find in other languages. And then more time optimizing the code, adding caching, moving to more advanced algorithms, and rewriting parts in C just to get it to run at a reasonable speed when the naive approach I implement in other languages is fast enough on first try.

For most tasks, modern mid-level statically typed languages like C#, Go, Kotlin really are the sweet spot for productivity. Languages like Python, Ruby and JS are a false economy that appear more productive than they really are.

Re: The computers are fast, but you don't know it

#213
post #77

Earlier quoted context omitted.

It's not only a matter of 750ms instead of 200ms. I'm astonished every time I open some tool like Visual Studio, SAP Power Designer, or Libre Office that can stay for the most part of a minute on its loading screen. What do those tools even do for that long? They can read enough data from the disk to overflow my computer's main memory a few times during it.

I remember a video of a guy running an old version of Visual C++ on an equally old version of Windows, in a VM on modern hardware, to try Windows development "the old way". It took about one frame to launch. One. Frame. By the way, Apple isn't much better. Xcode takes around 15 seconds to launch on an M1 Max. edit: probably this video https://youtu.be/j_4iTovYJtc?t=282

It's at the end of Casey Muratori's Visual Studio rant: https://youtu.be/GC-0tCy4P1U

Not only Visual Studio s up instantly in an older version of Windows running in a VM. Debugger values update instantly there as well, something that Visual Studio can no longer do.

Re: The computers are fast, but you don't know it

#214
post #84

most likely misused pandas / numpy,as long as you stay in numpy land,it is quite fast.

Use C or C++ or Rust or even Java and you don't have to worry about any of this. You can just write the obvious thing with your normal set of tools and it will be good enough.

Re: The computers are fast, but you don't know it

#215
post #211

Earlier quoted context omitted.

It's literally "twice as long" syntactically. 120 vs. 67 characters. And again, you keep omitting the rest of the line. (Why?) What you should've written in response was: var y = Enumerable.Range(1,50) .Where(e => e % 4 == 0 && e % 3 == 0) .Skip(1) .Select(e => e + 1) .ToArray(); Compare: y = [t[1] for t in enumerate(range(1, 50, 4)) if t[0] % 3 == 0][2:] And (again), my complaint isn't about LINQ or numbers or these…

The ToArray is unneccessay, it's much more idiomatic dotnet to deal with IEnumerable all the way through. The only meaningful difference in lengths is that C# doesn't have an Enumable.Range(start, stop, increment) overload but it's easy enough to write one, and then it'd be essentially the same length.

"Unnecessary"? You can't just change the problem! I was asking for the equivalent of some particular piece of code using a list, not a different one using a generator. Sometimes you want a generator, sometimes you want an array. In either language.

Re: The computers are fast, but you don't know it

#216

Earlier quoted context omitted.

Dozens of instances of a C GUI can launch in the time it takes to launch a hello world python program.

Yes but what kind of comparison is that: 1. How often do you need to execute 1000 GUI instances? 2. How often do you need to print "hello world"? The right tool for the right job.

This is a discussion about computers being slow. As in a person asks a computer to do something and the human waits while the computer does it.

So python isn't the right tool for any job that involves human interaction.

Re: The computers are fast, but you don't know it

#217
Maybe it's been stated already by someone else here but I really hope that CO2 pricing on the major Cloud platforms will help with this. It boils down to resources used (like energy) and waste/CO2 generated.

Software/System Developers using 'good enough' stacks/solutions are externalising costs for their own benefit.

Making those externalities transparent will drive alot of the transformation needed.

Re: The computers are fast, but you don't know it

#218
post #11

Yup. We have gotten into the habit of leaving a lot of potential performance on the floor in the interest of productivity/accessibility. What always amazes me is when I have to work with a person who only speaks Python or only speaks JS and is completely unaware of the actual performance potential of a system. I think a lot of people just accept the performance they get as normal even if they are doing things that ta…

> I think a lot of people just accept the performance they get as normal even if they are doing things that take 1000x (or worse) the time and/or space than it could (even without heroic work). Habit is a very powerful force. Performance is somewhat abstract, as in "just throw more CPUs at it" / it works for me (on my top of the line PC). But people will happily keep on using unergonomic tools just because they've al…

It's the downside to choosing boring tech. It costs believable dollars to migrate and unbelievable dollars to keep course. There is a happy medium, I believe, that is better than "pissing away the competitive edge."

Re: The computers are fast, but you don't know it

#219
post #165

Earlier quoted context omitted.

I agree tooling makes a huge difference but I specifically said this with the understanding that you're using C# with Visual Studio. Some stuff will be easier in C#, but a lot of other stuff just isn't as easy as in Python. At the risk of setting up a strawman for people to punch down, try comparing how easy it is to do the equivalent of something like this in C#, and feel free to use as much IDE magic as you'd like:…

Here's a one liner in c# for that: Enumerable.Range(1,50).Where((x,i) => i % 4 == 0).Where(e => e % 3 == 0).Skip(1).Select(e => e+4) Okay, so you might consider that last e+4 cheating and against the spirit, but I couldn't be bothered to spend money upgrading my linqpad to support the latest .net with Enumerable.Chunk which makes taking two at a time easier for the first part. Edit: more in spirit: Enumerable.Range(1…

If I understand dataflow's example correctly you don't need the Select at the end:

  var x = Enumerable.Range(1,50)
          .Where((num, index) => num % 4 == 1 && index % 3 == 0)
          .Skip(2)
          .ToArray();
That computes the same thing as their Python snippet: [25,37,49]. Of course, what this is actually computing is whether the number is congruent to 1 modulo 4 and 3 so it was a weird example, but here's how you'd really want to write it (since a number congruent to 1 modulo 4 and 3 is the same as being congruent to 1 module 12):

  var x = Enumerable.Range(1,50)
          .Where(num => num % 12 == 1)
          .Skip(2)
          .ToArray();
Rewriting that Python example to be a bit clearer for a proper one-to-one comparison:

  y = [t for t in range(1, 50, 4) if t % 3 == 1][2:]
That enumerate wrapper was unnecessary. I don't recall a way, in LINQ, to generate only every 4th number in a range, but I also haven't used C# in a few years so my memory is rusty on LINQ anyways.

Re: The computers are fast, but you don't know it

#220
post #165

Earlier quoted context omitted.

Here's a one liner in c# for that: Enumerable.Range(1,50).Where((x,i) => i % 4 == 0).Where(e => e % 3 == 0).Skip(1).Select(e => e+4) Okay, so you might consider that last e+4 cheating and against the spirit, but I couldn't be bothered to spend money upgrading my linqpad to support the latest .net with Enumerable.Chunk which makes taking two at a time easier for the first part. Edit: more in spirit: Enumerable.Range(1…

Nah that part I'm not worried about. The "cheating" is omitting the rest of the line. What you really needed was: var y = Enumerable.Range(1, 50).Where((x, i) => i % 4 == 0).Where(e => e % 3 == 0).Skip(1).Select(e => e + 4).ToArray(); Compare that against: y = [t[1] for t in enumerate(range(1, 50, 4)) if t[0] % 3 == 0][2:] It's almost twice as long, and doesn't exactly make up for it with readability either.

What you're missing is that C# example works on any Enumerable. And it's very hard to explain how damn important and impressive this is without trying it first.

Yes, it's more verbose, but I can swap that initial array for a List, or a collection, or even an external async datasource, and my code will not change. It will be the same Select.Where....

Post reply on HN