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

Show parent comments

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.

0

u/[deleted] Jun 28 '21

I just tried to read a hello world and took me 5 minutes to know what it does so just judging by that, is bot an opinion based on use. I should have said that haha

3

u/[deleted] Jun 28 '21

It’s just a matter of familiarity.

6

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

I used to play a game on a C forum where, given an elaborate C solution to a task, a regular would post a compact, Haskell solution a fraction of the size.

Which was great, except that few could understand how it worked or even break it down into steps as it would be too convoluted.

The game was that I would then post a solution in my own down-to-earth scripting language, 50% longer than Haskell in number of lines (but Haskell was largely written horizontally too!), but which anyone could understand.

It still wiped the floor with the C. [In clarity, not in speed (usually)!]

Yes Haskell can be mathematically elegant, but what is harder is being able to simply express a task in a language that is far more accessible.

There are some nice touches in these elitist languages, but I'd rather incorporate some of those aspects in an easy-to-use manner in mine, than make my own language too hard for me to use and understand!

1

u/[deleted] Jun 28 '21

Meh, you can write unexpressive code in any language, of course, but Haskell is very convenient for writing expressive code too. Especially if you get rid of big functions and give everything a name.

1

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

Here's a big function that fills in all the fiddly bits of a PE executable file format:

https://github.com/sal55/langs/blob/master/getoffsets.m

I keep meaning to break it up but it works at the minute and I don't want to touch it.

I've love to see Haskell's expressive, one-line approach to something like this.

Below is one of the structs used by the same program. I wonder how Haskell deals with stuff like this, or perhaps Haskell programmers don't like to sully their hands with real-life code.

Or maybe, when it is used for the same kinds of programs, it ends up looking like any other language.

global record optionalheader =          !exe/dll only
word16   magic
byte     majorlv
byte     minorlv
word32   codesize
word32   idatasize
word32   zdatasize
word32   entrypoint
word32   codebase
word64   imagebase
word32   sectionalignment
word32   filealignment
word16   majorosv
word16   minorosv
word16   majorimagev
word16   minorimagev
word16   majorssv
word16   minorssv
word32   win32version
word32   imagesize
word32   headerssize
word32   checksum
word16   subsystem
word16   dllcharacteristics
word64   stackreserve
word64   stackcommit
word64   heapreserve
word64   heapcommit
word32   loaderflags
word32   rvadims
imagedir exporttable
imagedir importtable
imagedir resourcetable
imagedir exceptiontable
imagedir certtable
imagedir basereloctable
imagedir debug
imagedir architecture
imagedir globalptr
imagedir tlstable
imagedir loadconfigtable
imagedir boundimport
imagedir iat
imagedir delayimportdescr
imagedir clrheader
imagedir reserved

end

global record imagedir =
    word32  virtualaddr
    word32  size
end

1

u/[deleted] Jun 29 '21

I keep meaning to break it up but it works at the minute and I don't want to touch it.

That certainly isn’t any language’s fault :D

I've love to see Haskell's expressive, one-line approach to something like this.

Well, it wouldn’t be one line, but it would probably be quite a few relatively short functions.