Hacker News new | past | comments | ask | show | jobs | submit login
Mirth – a type-safe concatenative purely functional programming language (github.com/mirth-lang)
119 points by agentofuser on July 12, 2019 | hide | past | favorite | 73 comments



I was interested by the title, but it really needs a quick-start + examples in the readme.


Came here to say this. Majority of engineers will bounce immediately once they see there is no code snippets in the README, nor an examples folder.


To be frank, the src/ folder is the compiler for Mirth written in Mirth, so there's your example code. However, I do agree that a quick introduction would not be out of place.


But the first thing I want to about C is not a compiler written in C. That's an unfriendly intro to almost any language.

I want to see a procedure call, "Hello world" I/O, some math or string manipulation, and how to run that myself.

After that I can look at compiler sources.


LISP is a notable exception. Btw, I do believe a compiler should be one of the examples of a new language.


Are you saying that lisps are an exception to needing to see some small examples at first when looking at a new language? Why do you think they're an exception?


In LISP-like languages a compiler/interpeter is a simple example.


https://github.com/sbcl/sbcl/tree/master/src/compiler

Doesn't look simple to me.

This one is in one file, but more than half a megabyte of code spanning close to 12000 lines:

https://github.com/clisp-lang/clisp/blob/master/src/compiler...

The Emacs Lisp byte compiler also doesn't look like a good small example for neophytes:

http://git.savannah.gnu.org/cgit/emacs.git/tree/lisp/emacs-l...


FWIW, concatinative languages are even simpler than Lisp.


True, and that would be a good thing for the README to emphasize. It's mentioned, but in passing.

But even so, I know I'd like a good reference of what primitive operations are, the type system, and what's provided by the Prelude.


I've looked at some basic library code that is implemented as part of the compiler, and... well, I'm not sure about this. The syntax does not really seem reminiscent of concatenative languages ala FORTH, so in what sense is this a "concatenative" language? The documentation doesn't say - there is no documentation to speak of. I'm not going to dismiss the effort that has been put into this already, but I'd sure like to see some more overall polish applied - then it could even be reposted to HN, and perhaps garner far more useful critiques.


Are we looking at the same thing? It’s definitely a post-fix stack based language. It just also has strong ML-like types.


I think even beyond that, I didn't see a link to any docs in the readme. It may be cool, but I can't use it if there's nothing to tell me how.


I found some more information in posts on the patreon page, but not a good intro.



I have no idea how to read or make sense of these definitions. I mean semantically and grammatically. What should I read if I want to understand those snippets and how/why they do define what an addition is?


The first confusing thing is the type signatures. Concatenative languages pass everything around with a stack so here the double dash separates a top part of the stack before application from what the application of the word transforms that bit of the stack into, so:

  succ : Nat -- Nat
means that if you can prove there is a Nat, n on the top of the stack, you can do succ to replace that with a Nat, succ n. Similarly we have:

  + : Nat Nat -- Nat
Which says if you have two Nats on the top of the stack you can do + to get a single Nat.

The next weird thing is pattern matching. + is defined with two cases. The first is:

  zero + = id
Which makes some sense: to add zero to x, do nothing. Making up a variable syntax it would look like:

  <x> zero + = <x>
The pattern matching on the next line is harder:

  succ + = + succ
Which (making up syntax again) says that if your stack looks like:

  m n
And n = succ k:

  m (succ k)
And you do +, you “unapply” succ to get a “stack” that looks like:

  m k succ
With the application of + shown:

  m k succ +
And this matches the pattern above so we transform:

  m k + succ
And evaluate:

  (m+k) succ
  (m+k+1)
  (m+n)
I think this is a rough idea of how the basic types work:

  Denote a “stack” of types (e.g. Nat Nat above) as [a], and single types a.
  If e : [a] -- [b] then for any [c], e : [c] [a] -- [c] [b]
  If dashes are omitted from a type a, it is the same as the type -- a (ie [b] -- [b] a for any [b])
  If e : [a] -- [b] and f : [b] -- [c] then e f : [a] -- [c]

  To define a word w : [a] -- [b], e w = f is a valid clause if:
  1. e has type [c] -- [a]
  2. f has type [c] -- [b]
  3. e is a valid pattern (ie made out of constructors (?))
I guess the rest of the typing rules are more complicated.


The syntax is a bit peculiar, but they defined the union type Nat, defined the function + which takes two Nats and returns a Nat (which they defined in a thoroughly confusing point-free way because the language is concatenative), and demonstrated the associativity of +.

If you read any introduction to dependent types, they will do this.


Ok, now I get it... I was just lost in the syntax.


It's unbelievable how many languages are introduced without an example on the homepage. Imagine an Apple homepage without any iPhone pictures.


It's unbelievable how entitled people can be towards things that are published for free by authors who owe them nothing.

Mirth hasn't been released. I found it and decided to share it.


> Mirth hasn't been released. I found it and decided to share it.

So you are actually doing it a disservice. Perhaps the author intended a larger release with better docs and examples (or no release at all if it’s a toy project).

But now it will be yet another “ah, one of those languages with no documentation or viable use cases”.

Languages are a dime a dozen, there are several of then on HN each weak. “How dare you demand something from something made for free” is not a credible defence for anything.


A Forth-y with types, let alone dependent types, are not ‘a dime a dozen’.


Oh wow, cool. Have been hoping for another concaternative functional language. It really feels like one of those underrepresented language types. Always hoped to create something in Kitten but never got around to it and the development was mostly dead last time I looked at it. The way these languages both keeps all the simplicity of a lisp and the strong abstractions of modern functional languages, while still feeling and being close to the metal in a way most func langs never can is something I feel should be better explored. Though I don't see any example code on the README... Seems quite early so it's understandable, but would love to see more about it.


> Always hoped to create something in Kitten but never got around to it and the development was mostly dead last time I looked at it.

You can still use Factor http://factorcode.org/


The creator of Factor left years ago to work on Swift I think.

I think it is still maintained, but slow releases.


The "Development release" of Factor is the best version to use. I'll see about releasing point versions more often.


Thanks! I only looked at it a little awhile back, but thought it was really cool...as a newbie I need more of an intro text to leverage it.


I thought for a second this was a post on Mirth Connect and I had flashbacks to doing hl7 integrations.

https://en.m.wikipedia.org/wiki/Mirth_Connect


Well now it's called NextGen Connect™, so I guess there's no more naming conflict :)


Yeah, but everyone in the industry still calls it Mirth.

Personally, I'm a Qvera man myself, but there's a cost to entry there (unless their free Standard edition does what you need).


Hah! So did I! I'm working on Mirth Connect right now.


Same here. For a second I wondered if they had produced a new language. :)


But, but...when do you get to actually use all these awesome languages?

> Forth, Haskell, Idris, Rust, Lisp.

All great. I would do anything to find a shop that actually uses any one of these instead of the usual boring stuff.

Seriously, how would one proceed to find such places?


A number of places use Haskell. There's a list at https://wiki.haskell.org/Haskell_in_industry.


Academic research :)

And personal FOSS projects of course.


1. Pick one of those langs.

2. Build a product.

3. ???

4. Profit.


1. Done

2. Done

3. ???

4. It's open source (damn it!)


Well next time make something that you can turn into a viable business and build an org around that lang and that culture.

Be the change you want to see!


Very random question. It’s the first I come across a concatenative programming language. Is SQL also concatenative in a way? I am thinking what you can do by chaining subqueries together for instance using “WITH”.


Not at all. "Concatenative"[1] is a property of a language syntax; broadly speaking, it holds that an arbitrary expression in the program text can be understood as a sequence of words, and any subsequence is in some sense meaningful; that is, the semantics of the expression as a whole is derived by "concatenating" the semantics of each word, and this semantic "concatenation" is consistent in that it can be used to provide a semantics to any subsequence.

[1] https://en.wikipedia.org/wiki/Concatenative_programming_lang...

This all works well for untyped languages (FORTH is untyped, as an example), but once you add in reasonably complex types you can't really use "sequences" alone, anymore; the directly comparable property is instead true of string diagrams. And once you add some more complexity, you even have to deal with, e.g. proof nets. There are ways to simplify textual syntaxes like e.g. typed lambda calculus along 'concatenative' lines, but mostly these are simple tweaks (De Bruijn notation, and/or De Bruijn indexes) that don't really create a "different" language.


Would you be willing to point me to some research/articles related to your statement about complex types? I'm (also) working on a statically-typed, concatenative programming language. It's for fun. I'd like to learn more about this topic.


See https://arxiv.org/abs/0903.0340 for a basic introduction to the issues, and https://arxiv.org/abs/0908.3347 for a slightly more extensive treatment, also mentioning proof nets. This does not explicitly say that these diagrams can be understood as the equivalent to sequences in something FORTH-like, but this is in fact what the papers are pointing out in a general sense, so I see it as a rather trivial remark.


Thank you!


FORTH was (I think?) one of the first concatenative languages, if not the first.

Interestingly, PostScript is also concatenative.

If you've ever used an RPN calculator, you almost understand how concatenative languages work!


I love the syntax.

Does anyone know how Github chooses which languages to adopt in their language detector?



This will change everything!


Why do we need yet another language instead of improving the existing ones?


Your profile says you like tinkering, yet you don't understand why others would tinker and experiment with new things?

Do you only give yourself a pass for tinkering instead of using your precious free-time to credentialize in and improve existing software?


Man, I don't know if it's against site guidelines, but I've never liked using people's bios - even if public on HN - as ammunition against their comments. Isn't it better to just respond to the content of the comments themselves?


There is always a person or two at the bottom of every thread like this that loves to spew hate towards people that like to share interesting side-projects, usually in a "you are wasting your time because your project has no immediate value to ME, go spend it serving my interests instead" sort of way. Claiming to also be a tinkerer in your public bio on the same website is gross, and IMO fair game to point it out.


IIRC, site guidelines don't specifically say "no ad hominems," but it seems to be generally understood that "no ad hominems" is the correct interpretation of this guideline:

When disagreeing, please reply to the argument instead of calling names. "That is idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3."

https://news.ycombinator.com/newsguidelines.html


Trying to start from common ground isn’t “ammunition” imho.

Although it depends on how it is phrased of course.


> I've never liked using people's bios - even if public on HN - as ammunition against their comments

I'm inclined to agree, but in the case of outright hypocrisy I think the point deserves to be made, because hypocrisy is literally the worst


I like tinkering but I don't add to the mess by open sourcing yet another language.


"Please don't post shallow dismissals, especially of other people's work."

https://news.ycombinator.com/newsguidelines.html


I know you are a gigantic egomaniac and I'm wasting my time writing this, but if you could ever repress your inflated sense of (mis)justice for two seconds, you might notice that the poster actually asked a perfectly valid question.

With the context presented so far (zero, for those keeping score at home), there's no reason to assume that the poster is dismissive of the project being discussed.

Why IS Mirth needed, when we can improve other languages? This is actually a perfect segue for proponents of Mirth to explain the niche the language occupies and it's pros and cons for users/engineers.

Thanks for making HN cancer, dang. Honestly, you're jumping up random asses on the internet that you'll never meet nor matter to is why the quality of discussion on HN has reached the trough it seems comfortably rested in. But hey. You posted the guidelines. You're a hero.


>I know you are a gigantic egomaniac and I'm wasting my time writing this, but if you could ever repress your inflated sense of (mis)justice for two seconds, you might notice that the poster actually asked a perfectly valid question.

Also a perfectly trivial one, an insulting one, and one that has been asked countless times, and that has no real place in a post presenting a new language but goes to meta yak shaving philosophy.

(A question like "what are Mirths differentiating points, what new does it bring" would be an acceptable version -- but that wasn't what was asked).

Note that by starting with "I know you are a gigantic egomaniac" and "inflated sense" and "Thanks for making HN cancer", you already show that you don't have a valid contribution to the discussion either. It even seems like the content of the discussion was secondary, just needed to vent at someone...


Seeing as his account is 11 hours old as of my writing this and that this is his only comment I have a little paranoid-detective feeling that this may be from PC, just an alt account, even if not they are clearly a very angry person


Not as far as I can tell. There are users whose emotions have taken this form for whatever reason, and they show up like superheroes in arbitrary scenes.

That comment was killed automatically by HN's anti-troll software, but I unkilled it last night. Maybe that was a mistake since it led to more offtopicness.


Wow.. and you don't feel like the comment you made is contributing to the problem?

If you want to live in a society where respect trickles up instead of violence trickling down then you mustn't express yourself with violence.


Insults like this are very annoying to read. If you think the moderation is too strict and is hurting HN's environment, then say that. There's no need to be so mean about it.


I think that history has taught us that the best way to get existing languages to improve is to demonstrate the value of a paradigm or feature out-of-band in some other language, possibly a new one.


I see your point. This is what happens now with Java.


You could look at it as a POC: ideas from experimental or niche languages sometimes find their ways into existing mainstream languages.


What language are you going to try and improve? Add static types to Python? Or make Java purely functional? Often one needs to start again. Mirth looks much better than most.


There exist other languages in the category, e.g. https://kittenlang.org/, http://www.factorcode.org/, https://github.com/cdiggins/cat-language, https://en.m.wikipedia.org/wiki/Joy_(programming_language). I assume the parent poster referred to improving those (or at least explaining which deficiencies of those myrth is addressing).

(In case you didn't already, you can read about this family of languages in http://evincarofautumn.blogspot.com/2012/02/why-concatenativ...)

I'm personally happy that somebody is doing more research in this field.


Note that none of these languages have dependent types and that feature is sometimes impossible to add in full generic power after the fact without completely breaking existing code.


I think there is some misunderstood. I just saw mentions of java and python and I just wanted to add some pointers for people who might not know that myrth lives in a void. I didn't want to imply that there is no point in writing a new language.


Does mirth? I've been perusing the code and haven't seen anything like that so far.


Unrelated, do you speak Ithkuil?


I am only recently aware of Patreon because of that V-lang stuff that has been hyping around on Reddit and here; this however seems very interesting to me. In my spare time I have been working on something similar for a long time but this looks, at first glance, clean and well done compared to my own efforts. Will have a play when I really wake up.

Another nice one (again imho) is [0].

[0] https://www.patreon.com/csaba_hruska




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: