Live data from Hacker News

An Opinionated Treatise on Cosmos, a New Programming Language

medium.com

31–40 of 66 posts

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#31
post #27
post #26

It is cute, but you can't design a language for toy problems or you run into problems with bigger software. I kind of stopped reading here: "Since it is declarative code, update returns a new world w2 instead of merely modifying w1. The funny thing is, just by doing this our code becomes 200% better. For example, you can now modify the code to store all world states in a list!" Uh huh. Try doing that with a nontrivia…

I should clarify before people respond antagonistically ... as someone who is designing a programming language, I think it's great any time someone is making languages and trying out new ideas. That part is great, if you want to make a functional imperative declarative loosely strongly typed language then hey, go for it. But I think one has a responsibility not to try and sell one's project as something it's not, whi…

> But if you are going to say something like "just by doing this our code becomes 200% better", with a straight face

I think this is something a lot of people here are having a hard time with: The article is not being said with a straight face. The unsolved problem of elegant I'm-holding-back-a-funny-face font technology has confounded the Internet for forty five years and still counting.

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#32
post #23

Thanks for the replies. A few comments: 1. I might have gotten a bit carried away when writing some parts of the article. 2. "Functors" are the same as functors from Prolog. Note that Prolog lists are functors too. They also may enable the language to have an 'Option' type like in some functional languages.

I think I'm having an internet crisis ... I read your article, and examined your project, and I've spent the last hour convinced that Cosmos is a very smart joke. Forgive me if this is insulting, because either way (real or a prank), your project is impressive. Can you help me out? Otherwise, I'll spend all night thinking that nondeterministic monads are the new hotness and then I'll need to quit programming and star…

Modelling nondeterminism with monads is a fairly standard use of monads. Specifically, you can model multiple possible results with a (lazy) list, and list is a monad. That's about it.

Sleep well!

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#33
Does Cosmos have any characteristics that would allow easy JIT speed optimizations? I would love to see language design go green by allowing easy optimizations that help us save both our valuable electricity and our time.

Are there design patterns that would allow us to more easily enable JIT for performance or even multithreading or GPU usage? V8, FTL and SpiderMonkey have all significantly sped up javascript performance making for much more efficient execution and better user experience. Python and PHP seem harder to adapt to JIT compilers as Facebook keeps working on HHVM for PHP and JITs for Python like PyPy lots of compatibility issues with existing libraries.

p.s. I for one really appreciate the entertainment value of exaggerated and opinionated style as long as the author realizes it is partly for entertainment, calls it out in the title and clearly isn't taking themselves too seriously. I already read enough serious and earnest tech articles...

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#34
This is a genius writeup. My earlier limited experience with logic programming resulted in lots of confusion and "what's the use?". Because of this, I would probably have me not even click the link if the word "logic" had been in the title (and I suspect I'm not alone in that).

Instead, the author starts with the familiar concepts and very gradually and comfortably flows into logic programming concepts, making me go "hey! that's handy!". That's a feeling I've never had with logic programming before, and I didn't even give Cosmos a try yet.

Hats off! I'm definitely going to play around with this.

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#35
I was confused by this example:

    rel p(s, x)
     if(s = ‘a’) //this is sugar for [(s=’a’ and x=0) or x=2]
      x = 0
     else
      x = 2
Why does it transform to

     [(s=’a’ and x=0) or x=2]
and not

     [(s=’a’ and x=0) or (s!=’a’ and x=2)]
(or whatever "not equals" is in Cosmos)?

In any language I know, "else" means "do this when the guard was _not_ true", and not "nondeterministically maybe do this other thing instead, if you want". Did I simply misunderstand it? (note that I got lost at the "soft cut" part, but did I get it right that "choose ... else" is closer to what I'd expect "if .. else" to do?)

Given that accessibility to people used to imperative languages is a core goal, I'm not sure that the choice of making "else" mean "yeah whatever" is the best one. Maybe it's better to replace it by a different keyword entirely ("if.. or.." maybe). On a related note, just in case you're not familiar with it, I believe that maybe the "if.. fi" construct in Dijkstra's Guarded Command Language[0] is an easy way to get imperative-thinking people to embrace nondeterminism. It feels a lot like normal imperative "if", except there is no "else". If you want "else", you need to add another guard explicitly, with the negation of your first guard. This way, it's easy for people to grasp that the order of the guarded commands have no meaning. It also makes introducing nondeterminism very explicit.

[0] http://en.wikipedia.org/wiki/Guarded_Command_Language#Select...

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#37

Thanks for the replies. A few comments: 1. I might have gotten a bit carried away when writing some parts of the article. 2. "Functors" are the same as functors from Prolog. Note that Prolog lists are functors too. They also may enable the language to have an 'Option' type like in some functional languages.

1. Please keep getting carried away

2. I completely didn't understand how a functor can make a list. Note, to me, a functor is a C++ class that overrides operator(). I loved how your writeup allowed me to understand Cosmos concepts _without_ learning Prolog, so an introduction to functors (maybe a later blog post?) would be warmly appreciated :-)

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#38
post #26

It is cute, but you can't design a language for toy problems or you run into problems with bigger software. I kind of stopped reading here: "Since it is declarative code, update returns a new world w2 instead of merely modifying w1. The funny thing is, just by doing this our code becomes 200% better. For example, you can now modify the code to store all world states in a list!" Uh huh. Try doing that with a nontrivia…

James Hague wrote about Pac-Man in a functional style (http://prog21.dadgum.com/23.html). He also wrote about the speed of an image decoder written in Erlang (a functional language) that was surprisingly fast (http://www.dadgum.com/james/performance.html).

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#39

Does Cosmos have any characteristics that would allow easy JIT speed optimizations? I would love to see language design go green by allowing easy optimizations that help us save both our valuable electricity and our time. Are there design patterns that would allow us to more easily enable JIT for performance or even multithreading or GPU usage? V8, FTL and SpiderMonkey have all significantly sped up javascript perfor…

[deleted]

Re: An Opinionated Treatise on Cosmos, a New Programming Language

#40

> If you only have a single feature then you only need to learn one thing and it can only go wrong one way. I beg to differ. You can definitely go wrong in more ways with Lua tables because they stand in for modules, arrays, and maps.

Well, I've been writing Lua code for a few years now and I think that the ways you can go right with Table usage far outweigh any liabilities that newcomers to the language will suffer as they learn to do powerful things with the simple features. As long as you know what modules, arrays, or maps are, and what uses they can provide, then you can't really screw things up too much with the Lua table. But of course, that's expecting a lot from a modern language user ..
Post reply on HN