• 4 Posts
  • 60 Comments
Joined 1 year ago
cake
Cake day: June 18th, 2023

help-circle
  • The whitespace doesn’t bother me at all, but holy hell! Any time I’m trying to understand a Python program/library that’s anything above a couple thousand lines of code, I instantly feel a burning hate for dynamic typing.

    I love Python for scripting- in large part because of dynamic typing. IMO it’s just not a language made for building large infrastructures.


  • The whole “maybe if the homework can be done by a machine then its not worth doing” thing is such a gross misunderstanding. Students need to learn how the simple things work in order to be able to learn the more complex things later on. If you want people that are capable of solving problems the machine can’t do, you first have to teach them the things the machine can in fact do.

    In practice, compute analytical derivatives or do mildly complicated addition by hand. We have automatic differentiation and computers for those things. But I having learned how to do those things has been absolutely critical for me to build the foundation I needed in order to be able to solve complex problems that an AI is far from being able to solve.



  • I am/was in the same boat as you: For a long time, I just didn’t care that I was giving away a bunch of information in return for convenience, and didn’t get why people cared so much.

    I don’t really know what triggered it, but at some point I became painfully aware that the only goal these companies have is to squeeze every possible penny out of selling me. I started noticing that the stuff they ask you to confirm is 95% stuff they want because they can sell it, or use it to get you hooked to their service, and 5% (at best) stuff they need to make the service good for you.

    This triggered a change in my perspective: Now it pretty much makes me sick to my stomach to think about all the companies that are drooling over me, trying to make a buck by getting me to click something I’m not actually interested in, or don’t actually need.

    These people have a vested interest in manipulating me, and by giving them my data, I’m giving them the tools to do it. I don’t want to be manipulated or sold as a product: That’s what made me start caring about protecting my data.


  • This will sound dumb, but I’m saying it sincerely.

    I’ve had similar issues (without getting into details), but what worked for me was getting outside a couple times a week. By that I mean bringing a tent or hammock + tarp and sleeping outside a couple nights a week on workdays.

    To be specific: I sleep outside Monday-Tuesday and Wednesday-Thursday. On those days I also make my dinner at my campsite. What I’ve found is that my brain goes into a much more “primal” state of “monke outside in cold, monke get shit done”, and that it propagates into my day and week.

    The barrier to this is of course actually going outside, but I’ve been able to get to a place where I have a “deal with myself” about those two nights a week. I always have my pack ready, so it’s just about grabbing it and heading out- I think that’s key.

    I’m not saying this is a solution for everyone, but it’s done wonders for me. As of now, I get restless and feel bad if I’m in a situation where I can’t get outside at least once a week. It brings me a peace of mind and will to get stuff done that nothing else can.



  • For someone starting out, I would say that a major advantage of Python over any compiled language is that you can just create a file and start writing/running code. With C++ (which I’m also a heavy user of) you need to get over the hurdle of setting up a build system, which is simple enough when you know it, but can quickly be a high bar for an absolute beginner. That’s before you start looking at things like including/linking other libraries, which in Python is done with a simple import, but where you have to set up your build system properly to get things working in C++.

    Honestly, I’m still kind of confused that the beginner course at my old university still insists on giving out a pre-written makefile and vscode config files for everyone instead of spending the first week just showing people how to actually write and compile hello world using cmake. I remember my major hurdle when leaving that course was that I knew how to write basic C++, I just had no idea how to compile and link it when I could no longer use the makefile that we were explicitly told to never touch…





  • Yes, it’s a field. Specifically, a field containing human-readable information about what is going on in adjacent fields, much like a comment. I see no issue with putting such information in a json file.

    As for “you don’t comment by putting information in variables”: In Python, your objects have the __doc__ attribute, which is specifically used for this purpose.





  • In general I agree: ChatGPT sucks at writing code. However, when I want to throw together some simple stuff in a language I rarely write, I find it can save me quite some time. Typical examples would be something like

    “Write a bash script to rename all the files in the current directory according to <pattern>”, “Give me a regex pattern for <…>”, or “write a JavaScript function to do <stupid simple thing, but I never bothered to learn JS>”

    Especially using it as a regex pattern generator is nice. It can also be nice when learning a new language and you just need to check the syntax for something- often quicker than swimming though some Geeks4Geeks blog about why you should know how to do what you’re trying to do.


  • My test suite takes quite a bit of time, not because the code base is huge, but because it consists of a variety of mathematical models that should work under a range of conditions.

    This makes it very quick to write a test that’s basically “check that every pair of models gives the same output for the same conditions” or “check that re-ordering the inputs in a certain way does not change the output”.

    If you have 10 models, with three inputs that can be ordered 6 ways, you now suddenly have 60 tests that take maybe 2-3 sec each.

    Scaling up: It becomes very easy to write automated testing for a lot of stuff, so even if each individual test is relatively quick, they suddenly take 10-15 min to run total.

    The test suite now is ≈2000 unit/integration tests, and I have experienced uncovering an obscure bug because a single one of them failed.



  • This is a very “yes but still no” thing in my experience. Typically, I find that if I write “naive” C++ code, where I make no effort to optimise anything, I’ll outperform python code that I’ve spent time optimising by a factor of 10-30 (given that the code is reasonably complex, this obviously isn’t true for a simple matrix-multiplication where you can use numpy). If I spend some time on optimisation, I’ll typically be outperforming python by a factor of 50+.

    In the end, I’ve found it’s mostly about what kind of data structures you’re working with, and how you’re passing them around. If you’re primarily working with arrays of some sort and doing simple math with them, using some numpy and scipy magic can get you speeds that will beat naive C++ code. On the other hand, when you have custom data structures that you want to avoid unnecessarily copying, just rewriting the exact same code in C++ and passing things by reference can give you massive speedups.

    When I choose C++ over python, it’s not only because of speed. It’s also because I want a more explicitly typed language (which is easier to maintain), overloaded functions, and to actually know the memory layout of what I’m working with to some degree.



  • Of course, Li-ion batteries will never cover large-scale power demand. Not primarily because of lack of lithium, but because it’s a technology that scales far too poorly into the MWh/TWh scale, and has a far too short lifetime.

    The battery tech we need for truly large scale storage is different from what we need for small, portable storage. Stuff like redox-flow batteries are looking promising.

    There’s also hydrogen, with different storage methods being actively researched- from direct storage to using ammonia as a carrier.

    The issue with using mechanical storage (like pumped hydropower) is threefold (off the top of my head):

    1. It has ridiculously low energy density
    2. Even after > 100 years of pumps and turbines, the power loss in a pump/release cycle is very high.
    3. It’s heavily limited by geography

    I’m not saying pumped hydropower isn’t part of the solution: I believe the solution is that we need many solutions. I just think it’s important to point out that battery tech isn’t some monolithic thing, and that there are issues with pumped hydropower (and mechanical storage in general).