HNHacker News
TopNewBestAskShowJobs

runekaagaard

143 karma · joined March 26, 2012

submissionscomments
runekaagaard··on Sonnet 3.5: Please write an asteroids game
Remember back in the golden days when we all thought chatgpt-4o was the SCHNITZEL!? That feels so lame today </sarcasm>

The actual prompts were:

1. Write a asteroids game in artifacts. Dont use unsupported libraries.

2. Error: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.

3. The screen is black but i get the pretty game over prompt after a while.

4. Now i see the game on when the game over popup shows. I think something is layered on top of the canvas, maybe?

5. ReferenceError: Ship is not defined

AND its SUPER fast too. WOW!

runekaagaard··on EmacsConf Live Now
Brews coffee... Oh yes, Emacs is my forever editor. It was created before I was born and will (hopefully) join my digitally converted consciousness on humanity's travels to the stars!

I got tired of switching editors for different languages (PyCharm was too slow for JSX code) and decided to invest in getting Emacs to behave like a decent editor. That took a while :)

I've programmed in Python, Clojure, Nim, Cython, JS, JSX, and a host of other languages. LSP support is getting REALLY good with three strong contenders: the minimal eglot that is in Emacs core, lsp-mode which is the most complete solution, and lsp-bridge that is super fast.

The single thing I love about Emacs is that everything is text. I can do a project-wide search (find-file-in-project), turn off read-only mode, use delete-non-matching-lines to remove stuff I don't want, turn on read-only mode and peruse the remaining matches. Then I can turn on wgrep-ag mode in the search results buffer, search and replace changes, and commit them to all the files. It's a powerful concept.

We are not a single-editor shop, we have Vim, PyCharm, Sublime, etc.

Extra compatibility is just a package-install away, and the ecosystem is thriving. My must-have utilities are expand-region, iedit, multiple-cursors, whole-line-or-region, pdf-tools, try, find-file-in-project, helm-ag, rg, undo-fu, and the list goes on :)

It has great workflows for compilation, buffer (file) switching, window management, tiling, and SO much more. For me, at least, every new feature requires a lot of tinkering, but the setup has been extremely stable across Emacs versions. Emacs development is very active and in recent years has been going in a great direction.

A great book to get excited about Emacs is https://www.masteringemacs.org/. Oh, let's share configs too, here's mine: https://github.com/runekaagaard/dotfiles/blob/main/.emacs.d/... :)

runekaagaard··on Python Is Easy. Go Is Simple. Simple != Easy
A great typing system is generally a good thing if many people work on the same large project. I love how nim typings gets out of your way but are flexible enough to not tie you down.

That being said - by Rich Hickey - typing also add a lot of complexity and non-optimal bindings between stuff. Untyped incremental development with just simple scalar types, and a single list, map and set type is wonderful. Large refactorings, not so much.

Adding gradual typing to a project often gives you the worst of the two worlds. You still fear changing stuff, _and_ have lots of overhead doing all the typing. Either your project is fully type checked at compile time or it isn't.

Python match statements are useful for checking structure and de-duplicating the container name:

    result = {}        
    for temperature in temperatures:
        match temperature:
            case {"city": city, "temp": temp}:
                if temp >= max_temp:
                    result[city] = temp
Oh, and python typing has come a long way:

    from typing import List, TypedDict, Dict

    class Temperature(TypedDict):
        city: str
        temp: int

    def filter_temperatures(temperatures: List[Temperature], min_temp: int) -> Dict[str, int]:
        result = {}
        
        for temperature in temperatures:
            match temperature:
                case {"city": city, "temp": temp}:
                    if temp >= min_temp: # Most of the time >= is what people mean.
                        result[city] = temp
                case _:
                    raise ValueError(f"Wrong temperature format: {temperature}")

        return result

    my_temperatures: List[Temperature] = [
        {"city": "City1", "temp": 19},
        {"city": "City2", "temp": 22},
        {"city": "City3", "temp": 21},
    ]

    print(filter_temperatures(my_temperatures, 20))
    print(filter_temperatures([{"typecheck error": "and runtimeerror"}], 20))
runekaagaard··on Report on an Unidentified Space Station (1982)
How working with our 13 year old code base feels like for a new programmer :)
runekaagaard··on Show HN: Rocket Drone, a lunar lander type game for the web
Just perfect, don't change a thing about the steering! <3 Very rewarding!

Add some cool retro music and wait for Ludwig yelling at the game on stream ;)

runekaagaard··on Why Can't Database Tables Index Themselves? (2006)
Here you go :) https://zodb.org/en/latest/
runekaagaard··on Max Datom: Interactive Datomic Tutorial
Ah yes, makes me remember the amazing talk by Rich Hickey called "The database as a Value" [1]. I felt like my brain was reorganized after watching it.

The simplicity of Datomic is very appealing, it's just a timestamped series of EAV entries, and some fancy indexing. Avoiding the latency (the database over there issue) sounds like a big win. Most of the simplicity is made possible by only having one single synchronous writer which is a major drawback you have to be able to live with. Some write-heavy applications would struggle.

Related to the timetravel feature I've bookmarked a blog post by Valentin Waeselynck where he talks about some of the misconceptions and drawbacks. [2]. My company have a not super-great setup with triggers on MySQL, and have longed for MariaDBs SQL 2011 compliant Temporal Tables which looks very interesting [3]. I guess an advantage with Datomic is that you don't have to create an entire table history row when all you want is to update a single field.

I was interested enough in Datomic that I started building a Python bridge but never finished it [4]. An added bonus was that I learned about the Transit serialization format which was ALSO super inspiring [5].

  [1] https://www.youtube.com/watch?v=D6nYfttnVco
  [2] https://vvvvalvalval.github.io/posts/2017-07-08-Datomic-this-is-not-the-history-youre-looking-for.html
  [3] https://mariadb.com/resources/blog/temporal-tables-part-1/
  [4] https://github.com/runekaagaard/brygge/blob/master/src/jolle/example.py
  [5] https://cognitect.com/blog/2014/7/22/transit
runekaagaard··on Ask HN: Where can we find the unsexy jobs?
I totally agree, the range in number of servers/services/technologies different companies use to solve similar problems are SO wide.

After 12 years of growth we are still happily on:

  - 1 Ubuntu server
  - 1 MySQL db
  - 1 Django framework
  - Ansible for deployment
And thats mostly it. Due to Hetzner missing the 27002 certification we moved from metal to Amazon EC2 instances which was pretty uneventful. We also moved to Aurora and the point-in-time restores actually makes me sleep better at night. Relative to Hetzner it's a lot more expensive. Not at all a problem in the absolute sense.

Some years back I had a chance to talk with the CTO of a company very similar to ours, and their landscape was 400+ microservices, 50 servers managed by k8s on Azure Cloud, Service bridges, Workflow engines, 5 different DB engines, etc. It sounded very fascinating, but also quite complicated.

Some of my worst decisions over the years has been not having the balls to say no to current best-practices. I've learned the hard way that even though the pressure of using shining-new-thingTM can be immense it's so important to realise that everything always has pros and cons. The most important thing is trying to really understand _my_ specific problem and _then_ using the simplest and most obvious solution that can work.

Obligatory "Programmers are also human" link: https://www.youtube.com/watch?v=Uo3cL4nrGOk

runekaagaard··on Show HN: I made a puzzle game in HTML5
Super great, like the way shift works :)

Super fun to speedrun, has level 8 down to 3 seconds - would be nice if the counter also reset when you press reset.

edit: oh and miliseconds on the counter ;)

runekaagaard··on Show HN: I made a web game using emojis and no JS framework
Fast Flood No.3 → ⌛ → 20 seconds ▶ → 18 moves → 2 tries

Super fun!!!!

runekaagaard··on PHP Pipes in 156 Bytes
Wrote a python pipe operator after falling in love with elixir just the other day:

https://gist.github.com/runekaagaard/5a172eccfa2fdbcd625a3a0...

runekaagaard··on Andromeda Invaders: A 1980s-arcade-style game using HTML5, Canvas, Web Audio
Superfun, nice sound design. Maybe try to scale the number of bullets with number of enemies? The levels are super hard and luck-based the first 10 seconds and then drags on a bit.

lvl 7 on first try, mobile.

runekaagaard··on My out-of-body experience in a sensory deprivation tank
Playing a concert very important to me, I experienced my first out of body experience during the entire first number. I remember floating about 1 meter above my head and looking down on the piano and watching me play. Curious.
runekaagaard··on Step Away from Stack Overflow
What you do mean ugly :)

[{"thing": k, "count": v} for k, v in [[c, c.update({x["thing"]: x["count"]})] for c in [Counter()] for x in response][0][0].items()]

runekaagaard··on Step Away from Stack Overflow
This does the trick in a (for me) not confusing way:

    from collections import Counter

    response = [
        {
            "thing": "A",
            "count": 4,
        },
        {
            "thing": "B",
            "count": 2,
        },
        {
            "thing": "A",
            "count": 6,
        },
    ]

    counter = Counter()
    for x in response:
        counter[x["thing"]] += x["count"]

    newlist = [{"thing": k, "count": v} for k, v in
               counter.items()]
    print(newlist)
runekaagaard··on Brython – A Python 3 implementation for client-side web programming
Er2
runekaagaard··on Ask HN: What did you make during lockdown?
I got a good bit of work in on https://github.com/runekaagaard/hypergen (a Python liveview) and https://github.com/runekaagaard/django-treeform (a declarative data transformation tool).
runekaagaard··on Show HN: Speedsums
And here's a cheat: http://pastebin.com/483UcMLx
runekaagaard··on Addition of 1 and 1 in PHP
What? No dependency injection framework? Pft! :)
runekaagaard··on Why Elite:Dangerous isn't just another computer game
OMG... I logged 1000+ hours with the Amiga 500 on this back in the day.
runekaagaard··on Speeding up PHP with the HipHop VM
Slightly OT, sorry. phc was such a nice project, and vastly unappreciated. Your cleanup of PHP's grammar was a piece of art which I spend a long time perusing through and trying to understand! phc could have largely benefited the PHP community as a whole and it's such a shame it couldn't gain (enough) traction!

Never got a chance to say thx, so THX!

runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
Nope that is way too magic. It will go away. :)
runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
Thank you so, so, so much for actual constructive criticism!!!

> The concatenating assignment operator "%=" shouldn't change. It should stay the same ".="

The reason for using "%" was that I wanted to use "." for objects:

  instance.my_method()
I don't think "%" will be used as much due in Snow, due to the new "smart strings":

  "{a_variable} and {a_method()}"
> Accessing instance variables/methods should be by using '@' rather than '.' as that is becoming an > implied standard and php folk are already used to using '.' for string concatenation.

This looks weird, no:

  @instance@var@subvar@sub_method()
and what about accessing static vars and methods?

> The setting of parameter types and defaults on methods is too heavy and not what people expect. I would put them back into method declaration.

Yes it's heavy, but as you always need to have a docblock to write "acceptable" PHP code, I chose not to duplicate the argument names.

> This doesn't make a lot of sense.

No this should go, I decided that a couple of weeks too. But the problem its trying to solve is a real one. Your proposal looks good, but how would it work on a new variable?

runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
Well actually 15, as it seems fair to remove the comments in Snow too. About it being readable, I think that has a lot to do with experience. For me the Snow version is clear as day ;)
runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
I completely agree, will change all the pri, pub, arr, etc. to private, public, array, etc.
runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
The original reason for "<-" was to have it implement a "inner return", that should be "<--". Now I think there should only be one return type, but "<-" still looks ok to me as it points the value back as trying to "return" it :)
runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
The whole journey of trying to "fix" PHP has indeed seemed difficult. Mostly because so much information is pushed to the syntax of the language. Where in python the "." operator is used both to designate namespace, calling methods and calling "static" methods, PHP has three different operators "\", "->" and "::". Has it been worth it? Personally: A big yes, thinking about languages is fun. Practically: When it's complete, I think I will like it better than PHP, but still prefer a lot of other scripting languages like Coffescript, Lua, Python, etc.
runekaagaard··on PHP-Snow - A concise, dry and beautiful language that compiles to PHP
WOW, I'm on hackernews, wow! I completely agree on not shortening array, object, private, public, etc. I reached a similar decision a while ago, but didn't get around to fixing the docs.

I like shortening fn though, as it often makes the difference if an expression containing an anonymous function can fit on one 80 character line or not.

About the "!_->" syntax in the validation part of the function definition. Recently I've decided to remove the entire validation part, because the syntax is too specific and weird. I still like the defining of arguments on top of the function because it removes duplicate argument names between docblocks and code. The idea of validation together with the argument defintion is still sound i think though.

← PreviousPage 2 of 2