HN user

maattdd

479 karma
Posts6
Comments117
View on HN

I don't know much of PHP, but reaching "Rust/Go" performance is not simply because they have AOT compiler, but because the semantic of the language itself allows efficient compilation.

Many attempts has been made for an AOT compiler for Python and Ruby, but they don't reach those performance because of this.

Bugs Apple loves 6 months ago

I'm (and millions other people) are using macOS with a classic scroll wheel mouse perfectly fine. Are you sure there is not something messing with the trackpad at the same time ? (this looking erratically random?)

I've been updating my HN bot (watch comments for keywords and post to Slack/Discord) written in Crystal to use raw SQL instead of unmaintained ORM.

Turns out the whole app needs only ~ 10 SQL requests, and it's way funier to write modern SQL than fighting the ORM.

The new code looks like this :

    db_message = Model.save_new_message!(@conf.db, DbButler::Hn, item, DbState::Processing)
Than I have a Model module with all the interactions with the DB
    def self.save_new_message!(db, butler, external_id, state) : Message
        sql = {{ read_file "./db/save_new_message.sql" }}
        db.query_one(sql, butler.to_s.downcase, external_id, state.to_s.downcase, as: Message)
   end
(thanks to Crystal ability to read a file at compile time - I can write raw SQL in a file with syntax highlithing and maybe typesafe if I connect the DB to the editor)

The land page is not ready, but the bot has been working for me for months https://newsbutler.xyz/

My sum type example is exactly this (but I didn't use C++ std::variant<> syntax to not confuse the reader).

The most common example of a sum type is the "Expression problem" - please read some literature before commenting on a topic.

(Btw, it's called sum type for a reason: summation. The cardinality of the sum type is the sum of the cardinality of its variants)