September 2022:
This has spread to a far wider audience than I had anticipated - probably my fault for using a title that is in hindsight catnip for link aggregators. I wrote this back in 2021 just as a bunch of personal thoughts of my experiences using Rust over the years (not always well thought through), and don't intend on trying to push them further, outside of personal experiments and projects.
Managing a living language is challenging and difficult work, and I am grateful for all the hard work that the Rust community and contributors put in given the difficult constraints they work within. Many of the things I listed below are not new, and there's been plenty of difficult discussions about many of them over the years, and some are being worked on or postponed, or rejected for various good reasons. For more thoughts, please see my comment below.
{-# LANGUAGE BlockArguments #-} | |
module Main where | |
main :: IO () | |
main = do | |
babyShark | |
do do do do do do babyShark | |
do do do do do do babyShark | |
do do do do do do babyShark |
module ChrisPenner where | |
import Data.Array ((!)) | |
import Data.Foldable (for_, foldl', maximumBy) | |
import Data.List (sort) | |
import Data.Map.Strict (Map) | |
import Data.Ord (comparing) | |
import qualified Data.Array as A | |
import qualified Data.Map.Strict as Map |
I want to write something to celebrate the latest and I hope the last release of wstunnel, a TCP/UDP tunneling websocket tool, and share with you at the same time my story with Haskell and OpenSource projects.
This open source project is not my only one, but is found to my hearth because it brought me joy, despair, proud, shame and further reach that I wasn't even expecting at first. If you have not noticed, the program is written in Haskell. I started learning it, well 8 years ago now..., when I was studying abroad in South Korea. At the time I was struggling with the feeling that I was not enough, I already knew C++ and Java, but was feeling like stagnating while there was so much more that I wasn't knowing. I wanted to be more and thus I needed to dedicate myself to learn more in order to be better. This fear of stagnation is still present in me even today, and if you are working as a programmer, I t
#!/bin/bash | |
if [[ $# -ne 2 ]]; then | |
cat >&2 <<EOF | |
Transplant a branch from one root to another. | |
Handy if you've done a squash-merge and need to rebase <from> the old branch <onto> the new master. | |
Usage: | |
git transplant <from> <to> | |
where: |
---------------- Базовое ---------------------- | |
type Число = Int | |
type Строка = Text | |
type Строчное = Show | |
type ИО = IO | |
type Сравнимое = Eq | |
type Упорядоченное = Ord | |
печатать :: Строчное значение => значение -> ИО () | |
печатать = print |
Do not get bogged down in microoptimizations before you've assessed any macro optimizations that are available. IO and the choice of algorithm dominate any low level changes you may make. In the end you have to think hard about your code!
Before starting to optimize:
- Is the -O2 flag on ?
- Profile: which part of the code is the slow one.
- Use the best algorithm in that part.
- Optimize: implement it in the most efficient way.
An "invertible syntax description" is something that can be used to both parse and generate a syntax.
For example, instead of defining separate toJson
and fromJson
functions for a given data type, an invertible syntax description could be used to provide both.
There are many Haskell libraries that provide this functionality or something close to it.
As far as I can tell most of them are at least inspired by Invertible syntax descriptions by Tillmann Rendel and Klaus Ostermann.
Personally I am interested in using these for HTTP routing.
I frequently want to be able to define a route such as /episodes/:id.json
, dispatch based on that route, and generate links to that route.
Doing so manually is tedious and error prone.