Please, I just want to see a program with a dozen lines of code to see what it looks like. Of course, more extended examples with the intended usage would also be very welcomed.
I eventually found this: https://github.com/kocircuit/kocircuit/blob/master/lessons/e... but I think it should be much easier to arrive there.
Here's a post by the Fields medallist Tim Gowers:
Also, looking at installation instructions, it is bootstrapped by Go, so it does seem it is still in some prototype phase.
I would say, let's give them a year or two.
Language, as language, looks clear enough for me, but it is hard to judge from little I saw.
The poster shared it to HN because they want other people to look at it. Which is fine, but they're asking for our attention, and they need to respect that fact—and us—and not waste our time. Sharing a new language but making us dig around to understand one of the most fundamental things about the language—what the code looks like—does not respect us, our time, or our attention. If that's a problem, they can keep it a private repo, and not share it on HN.
Lua's great little language but writing ~= instead of != is simply annoying. In this "Ko" language, it looks like they do returns with a colon, as in "return: x" -- why??? I won't even go into Rust picking up Perl's bad habit of looking like line noise with all the ASCII sigil usage in advanced code.
Also, any language which doesn't have a "hello world" example in its front page is doomed. Even such a wide-spread language as Python has code snippets practically first thing on its web page! This is not by accident!
I would sympathize with using =/= for "not equal" because it is ASCII art for the traditional mathematical notation of using an equal sign with a line through it. Though it might be better just to permit carefully selected unicode characters such as https://www.fileformat.info/info/unicode/char/2260/index.htm
=/= is disappointing as art because it is too wide, but it has obvious mnemonic power.
Would you object to =/= as "arbitrary uncommon syntax" because it is poor art? Does its mnemonic power save it from the criticism of being "new for the sake of new"
How is it evaluating? Eager? Lazy?
What values are supported? Records? What flavor? Modules?
Not to steal any thunder, but I've been prototyping a language very built on this idea.
> Genericity means that functions do not have to declare argument and return value types, which makes them highly reusable.
Thanks for being kind about pointing out my massive presupposition
I'm also suspicious of the fact that it's implemented in Go. I would think that someone who knew functional programming well enough to create a new language would implement the language in Haskell or OCaml or even Standard ML.
Also the type system looks pretty bad. No algebraic data types.
Well, that's not entirely correct. I assume you mean they run on the JVM? Language like scala are actually written IN scala. The only thing that is in java is the interpreter but the entire compiler is scala.
I don't think this is true. Java is not a good language for compilers in any case, and it would cause me to trust the language less, especially if they were claiming it was a "functional programming language"
Could you elaborate?
If that choice becomes perceivable to anyone but the authors and maintainers of the language itself, I'd say that's a first class failing, isn't it?
The quality of a language should be a pure function of the language itself; the interpreter doesn't (or rather, shouldn't) enter into it.
| Author's competence |
+--------------+ | | +---------+
|Implementation| <-+ +-> |Product |
| language | |language |
I am not weighing in here on what specifically the choice of Haskell, OCaml, or Go say about author's competence; I am simply addressing your point that the choice shouldn't matter at all—unless you are convinced that the knowledge of PL theory and design principles is uniformly distributed across all language communities.
Apparently reading papers from the past 30 years is a "huge academic bias."
I'd honestly be fine if it was implemented in Racket too.
> inability to come up with a usable language or at least there exists a negative correlation with those languages.
No one has ever actually offered me a substantive argument that Haskell is unusable. It always seems to be "well, I don't personally understand it, and that means it's unusable" Uhh okay.
The fact that it has a "let" keyword does make it "academic" to me. I'm fairly sure we can now have compilers that don't need such hints to be explicitly provided. Rust enjoys its let keyword so much they have a "If let" syntax.
Languages that use random punctuation without providing real benefit could also use a cleanup. Lua with ~= is a good example: Tilde in mathematics means "approximate". In C != means "not equal". So lua's designers can be accused of either never seeing C or deliberately choosing something different. Given that Lua is implemented in C they can't easily claim ignorance.
Archaic and awkward ways of expressing code shouldn't be propagated into new languages unless here is a clear benefit. Have a look at Erlang. Excellent overall but has lots of old warts from yesteryear you wouldn't want in a modern language. Eg look at its string syntax / naming rules. Now compare it to Elixir. Modern. Same VM.
Moving with the times is useful. Future languages shouldn't be adding debris everywhere just to be different.
(As a reader, it's also really nice to be able to see "there's a new variable being created here" at a glance. Ambiguity is a human problem as well as a computer problem.)
Skimming some of the .ko files, I like that it seems readable and familiar (even if there are some oddities). No matter how much time I spend with Haskell and OCaml, I always spend conscious effort trying to mentally parse the source code.
Something I noticed while working on it is that the declarative style is not always the most comfortable way to describe things, and well-written imperative code is declarative in its own way. Somewhere in most useful programs, it helps to have the imperative escape hatch until you can support the best declarative expression.
Random observations in no particular order:
- The simple assignment syntax looks somewhat procedural and is easy to read in small hunks at a time, but is still functional. I like this. This meshes well with the very real limits of how the human brain can parse things.
- I wish there were type declarations. There's a type system, but it seems to be all inference. Type declarations just at the function inputs and outputs (and leaving it pure inference in the middle) would promote readability when you've got no compiler in hand and are just eyeballing the pure text, in my opinion.
- I'm surprised by the inclusion of a system of nonlocal returns (panic/recover). It still looks relatively functional, but A) boy that's not an area where the word "relatively" is comfortable to use and B) I shudder to think what the inferred types will tend to explode into when using this feature (an Either of an Either of an Either of a ...?) in a nontrivial program (and the examples don't really shed light on that either, due to the "all inference" model leaving us with no plain text declarations of types in sight).
- I haven't seen any examples yet of what happens and how you're supposed to resolve it when the type inference can't quite figure it out. There seem to be some examples of doing explicit casts which seems to be a workaround for this, but I don't see it discussed very clearly.
- The quick and easy syntax for returning new record/structure types seems nice. Though I'm again a tad worried that the range of types I could end up producing would get pretty large.
- The syntax holistically seems to keep things from "drifting to the right", which seems to be a common readability cramp that emerges in many functional languages. Nice.
- Using the term "Variety" for roughly "closure" is... very nonobvious to me. But I shouldn't nitpick on terminology. (And for what it's worth, I read the protobuf that Ko uses internally to define its types of types before anything else, and so maybe I'd be less surprised if I had encountered it from from the docs and lessons first.)
Caveat: these are all "hot takes" from the couple dozen minutes of digging I've done so far. I might be reading some things wrong or have missed some documentation, so take these comments with a grain of salt and do your own looking as well.
Overall, this seems neat, but simultaneously leaves me a little worried that I'd be able to too easily write things in which the type inference finds something that compiles, but isn't the type that I would've declared.
I'd be really interested to see what this shapes up like if combined with some system for explicit type declaration. Gluing Ko together with a serial data schema like Protobuf and using Ko for "migrations" seems like it could be a really useful combination, for example.
I'll agree this isn't ready yet to be the first example of functional parallelism in someone's life, but I'm pretty excited to play with this computational model.
Another language I saw recently that has this promise was Pony which uses an actor and message passing model to try to accomplish this but it doesn't actually prevent you from hitting the case, instead it'll just kill a random actor until the deadlock is gone . This can work but it needs to be up front that you MUST write your software to be ready to be killed at any time and continue to function.
It's really an impossible situation to completely "solve", given that doing so would require a solution to the halting problem. So it's always a fun place for me to start looking at any new language if they talk about locks and dead-locks. So far I think Haskell and Rust (and probably other ML family) have the best balance being struck since you can opt in to statically proving this if you restrict those parts of your program but you're not required to do so by the language itself.
https://github.com/kocircuit/kocircuit/blob/master/lessons/1... : You might want to consider using Go syntax whenever it is not a problem. 'import "package" as foo' rather than 'import foo "package"' is just pointless change, unless there's more to the "as" statement later.
https://github.com/kocircuit/kocircuit/blob/master/lessons/1... : Whoa, I have to type the name of all the arguments I want to use to every function on every invocation? That's a level of noise I'm not interested in. In https://github.com/kocircuit/kocircuit/blob/master/lessons/1... it is claimed this is necessary to support default arguments, but see Python's function argument invocations. (And be sure you see all of it; for instance, it is little known that you can:
>>> def f(x):
... return x * 2
>>> f(x = 2)
Coming back after reading on, I see you let Eq and Sum and such get by without argument names. Generally a language should not reserve privileges for itself that it does not grant to its users without a really good reason.
https://github.com/kocircuit/kocircuit/blob/master/lessons/1... : I literally have no idea how you are using the word "monadic" in this section; it is neither the proper mathematical term, nor the very close Haskell term, nor any subsequent misunderstanding I've ever seen of the Haskell term ported into other languages, nor can I particularly connect it to the philosophical meaning, nor do I (glancing ahead) see any other documentation for it. My search was not exhaustive, but taking such liberties with a term like that sets off a lot of flags for me.
https://github.com/kocircuit/kocircuit/blob/master/lessons/1... : This is, IMHO, a rather dirty hack around trying to copy the way pure Haskell code can implement definitions without much concern for order, while at the same time having side effects in the code. That "DoubleGreeting" on the bottom is getting really ugly (and I mean in terms of the semantics of what is being represented there, not the surface syntax layer), and it's still in the sample code, where things should be looking artifically fake-pretty because the real-world hasn't intruded yet. It's a solution to a problem that shouldn't have been introduced in the first place.
https://github.com/kocircuit/kocircuit/blob/master/lessons/3... : I expect "repeated assignment" will be difficult to follow with nested structures. Also, what happens if I move yearOfBirth below the repeated "occupations"? My point here is not that there isn't an answer; it's that I can come up with 3 or 4, which is the real problem.
https://github.com/kocircuit/kocircuit/blob/master/lessons/3... : Variety is a bad name for this concept. It's too close to the well-defined "variant" term and causes serious concept clash in my head. "Function object" or something, maybe. "Closure" might work, haven't studied it closely enough to be sure.
https://github.com/kocircuit/kocircuit/blob/master/lessons/3... : This appears to mean that the "null" value is forced into all types, which makes this, surprisingly, even worse than Go itself on this front, which at least has a few types of values that can't be null.
https://github.com/kocircuit/kocircuit/blob/master/lessons/3... : At scale, you can't provide a generic hashing function. It's appealing, but it really can't be done. At best you can provide an interface. Don't even provide a default implementation. Java has had a long history of problems with that.
General comment: Using the functions for flow control is OK, but combining that with arbitrarily-reorderable function argument parameters is crazy. Anyone who writes If(else: ..., when: ..., then: ...) is just insane anyhow, so don't even allow it in the syntax/grammar, because it will happen. It seems to me you basically have an imperative language trying to look functional, while I see little to nothing "functional" about it, and you'd be better off just being an imperative language and take advantage of structured programming's implicit control flow <-> source code layout correspondence. You're paying the price for some things you're not successfully taking advantage of.
https://github.com/kocircuit/kocircuit/blob/master/lessons/5... : Re: arg0, arg1, arg2, etc., another solution to a problem that should simply have not been introduced.
My summation is that even in the examples, I'm seeing a lot of little quibbles stack up and become some big problems, and that's before I'm trying to actually code in this. I'd suggest some more thinking about the language's goals, and ensuring that every feature is in harmony with that goal and everything not necessary for it has been cut, because that is not where this language is right now.