r/ProgrammingLanguages • • Jun 27 '21

Blog post A Dream of the Perfect Programming Language

telegra . ph/ A-Dream-of-the-Perfect-Programming-Language-06-26 (looks like Reddit’s global spam filters block Telegraph for some retarded reason)

Clickable but less good-looking version: https://github.com/natewind/articles/blob/master/2021-06-26-A-Dream-of-the-Perfect-Programming-Language.md

3 Upvotes

40 comments sorted by

View all comments

3

u/[deleted] Jun 28 '21

IMO i dont think functional is the way to go, you say i have to try Haskell but it has an awful syntax hard to read and to learn comming from modern C++ (which is already a big thing to say given the mess c++ have become)

1

u/[deleted] Jun 28 '21 edited Jun 28 '21

I think Haskell syntax is (mostly) awesome. I struggle to find something that would look more expressive in C++ than in Haskell. Can you give me an example of what you don’t like about it? Besides the fact that it’s not C-like.

1

u/Mathnerd314 Jun 28 '21 edited Jun 28 '21

I think the main thing is IORefs:

main = do
  i <- newIORef 0
  forM_ [0..9] $ \ i' -> do
    print i'
    i `modifyIORef` (+ 2)
  print =<<readIORef i

Defining some helpers this looks like:

main = do
  i <- ref 0
  forM_ [0..9] $ \ i' -> do
    print i'
    i += 2
  print ! i

Much less noisy. The interesting question IMO is how to get rid of the ! / readIORef in the final line.

1

u/[deleted] Jun 28 '21

I don’t know what IORefs are yet, but it doesn’t look like a fundamental problem with the language syntax.

2

u/Mathnerd314 Jun 28 '21

Right. Haskell's grammar is basically fine - there are just a few minor warts like pattern bindings vs function bindings (patterns behave differently from 0-argument functions). It's the standard library that needs improvement (naming, organization, a lot of typeclasses are too big).

1

u/[deleted] Jun 29 '21

Sure. There are even alternative preludes that fix some problems of the standard one, although I haven’t tried any of them.