Live data from Hacker News

Motivation – Keli Language

keli-language.gitbook.io

151–160 of 300 posts

Re: Motivation – Keli Language

#151
post #5

When giving an example on how infix notation reads better: // This is obviously not too right ",".splitBy("1,2,3,4,5") // This should be right, because it reads out more naturally "1,2,3,4,5".splitBy(",") It's funny that in Python split works this way but join doesn't. This is because in the case of split both arguments are strings, but for join one of the arguments is a Sequence, which is a general protocol rather t…

Hmm, to me it seems that 'splitBy ","' should be a function that takes a string and returns a list of strings:

  splitBy "," : String -> List String
so it seems "clear" that the separator should be the first argument. But maybe I've just programmed functionally for too long?

As an alternative, perhaps there's space to introduce types to make this something like

  split : Pattern -> String -> List String

Re: Motivation – Keli Language

#152
post #10

Earlier quoted context omitted.

I get this might just boil down to preference but I absolutely hate named parameters. They’re biased towards new users of a language and quickly become painful to write once you’re familiar with the function call. Plus they don’t always improve writability outside of IDEs because you then have to memorise the parameter names and in some functions there’s several terms that could equally apply (if you’re using an IDE…

They are biased to new readers of a codebase, not of a language, which is really just another way of saying that the code is very readable.

I don’t think it’s fair to say what’s readable to new developers is the same as what’s readable to experienced developers nor even every developer.

For example the terse style of Sexpressions or C-style braces are off putting to some but after a short while they become second nature to visually parse (not saying all code should follow Those idioms, just using that as an example of how readability changes with experience). On the other hand I never found it as straightforward visually parsing the “word soup” of named arguments when using languages that favoured it. While those languages were easier to learn the basics, they quickly became tiresome to write larger code bases with.

But I guess this just boils down to personal preference.

Re: Motivation – Keli Language

#153
post #5

When giving an example on how infix notation reads better: // This is obviously not too right ",".splitBy("1,2,3,4,5") // This should be right, because it reads out more naturally "1,2,3,4,5".splitBy(",") It's funny that in Python split works this way but join doesn't. This is because in the case of split both arguments are strings, but for join one of the arguments is a Sequence, which is a general protocol rather t…

This particular set of examples is especially ambiguous because "splitBy" can be read two different ways: as a description of the result (noun having been split by a separator) or as an action (subject split direct object by a separator). Which one you choose will subtly affect the way you group the arguments. Conventions in functional programming tend to prefer the former, whereas imperative (including OOP) languages prefer the latter. Either way, however, the string which directly follows `splitBy` should be the separator. In the functional example:

    -- Is this correct?
    splitBy ","  "1,2,3,4,5"

    -- or this?
    splitBy "1,2,3,4,5"  ","
there really is no question that the first version is correct. Even oversimplifying as the article does and treating "basic English" as the only applicable domain knowledge, I'm not likely to read "split by ',' …" as an instruction to split the string "," by some other separator. To understand how the second string fits in you need more than basic English, because English doesn't have that sort of syntax. However, once you learn that it parses as `(splitBy ",") "1,2,3,4,5"` the result is pretty obvious.

In the OOP language example the second version with the string knowing how to split itself, as it were, does make more sense than the first version. The target of the method is always the subject, and the method name is usually read as a verb, with parameters as direct or indirect objects. (Read as: String "1,2,3,4,5" (S), split yourself (V) by the string "," (I.O.).) However, in functional programming the bias is exactly the opposite, because functional programming is about programming with first-class functions on data, not performing actions. You could easily arrange to write:

    "1,2,3,4,5" `splitBy` ","
in Haskell using infix notation, and it even reads fairly well reinterpreted as English prose. However, defining `splitBy` this way would imply the curried prefix version:

    splitBy ","
would not be a function that splits its input by ",", as one would expect, but rather one that splits "," by its input. Which just goes to show that not every function is well suited for both infix and prefix notation. Whichever version you choose needs to be used consistently. In general the convention has been to define multi-parameter functions such that they can easily be used as combinators, via currying, which seems fitting to me given the nature of functional programming. Functions which are designed to read well as infix operators usually require operator sections or `flip` to adapt them for use as combinators.

> I think, in general, requiring named arguments is a good thing.

I have no objection to optional named parameters, but making them required would necessarily eliminate currying and simple function composition, and that I have a problem with. Record parameters with named fields are generally sufficient for the situations where named parameters are useful, especially since they're ordinary data which you can manipulate at will and not some special syntax baked into the language just for function calls.

Re: Motivation – Keli Language

#155

I think it's great that Keli is designed with IDE support in mind. However I believe that this is only half of the reason why FP still doesn't really break through in the corporate world. The other reason is that many FP users are too enthusiastic about creating abstractions. This is of course something that FP is exceptionally well suited for. An api that was written to simply process a list of Orders into a Report…

The reason why FP still doesn't really break through in the corporate world is a marketing failure, in the strictest sense of the word marketing, which means prioritizing the right features to target the right market.

A large proportion of this talk is based on the book “Crossing the Chasm". The book was originally written for startups, and this talk adopts the book to an open source audience, especially Haskell developers.

Gabriel Gonzalez – How to market Haskell to a mainstream programmer: https://www.youtube.com/watch?v=fNpsgTIpODA

Re: Motivation – Keli Language

#156
With every new upcoming language, I always have the same ask; Please add a couple of section on what can we do with the language today.

Rust has amazing sites like arewegameyet or arewewebyet.

A single paragraph around what users can realistically do with this language and what are the most used packages in the ecosystem will be a great help to anyone curious about it.

Re: Motivation – Keli Language

#157

On the topic of language IDE support. One of the things I've noticed from working in a few languages professionally (Python, Ruby, Java, Elixir) is that the level of power required in an IDE seems to be a function of the language. My observation was that to feel comfortable in Java I tended to require a very powerful IDE (Intellej) to deal with refactoring and appeasing the type system. When I write Elixir, I feel co…

Having used IntelliJ, the biggest advantage of IDE for me is the speed with which the errors are surfaced allowing me to correct them way more quickly than I could ever do in vim. It is so much more easier to find where things went wrong and how. That lets me focus on the logic instead of wasting time on things like fixing misspellings. Also totally agree with the ease of refactoring - it basically gives you the time and confidence to iterate freely.

Re: Motivation – Keli Language

#158

On the post it says Haskell is not IDE friendly. It is really hard to make an IDE around Haskell or does it just that it lacks support?

It's just a matter of time investment imo. And with the current ghcide effort, that's already happening!

The argument that you need method-style syntax to have good IDE support is short-sighted. Haskell has something more powerful (typed holes), so a common thought is Haskell needs a different sort of IDE support and not expect it to feel the same as Java.

Re: Motivation – Keli Language

#159
If I want to do functional programming, I can do that just fine in most languages.

If I want to do imperative programming, I can do that just fine in most languages, except for functional programming languages.

Re: Motivation – Keli Language

#160

With every new upcoming language, I always have the same ask; Please add a couple of section on what can we do with the language today. Rust has amazing sites like arewegameyet or arewewebyet. A single paragraph around what users can realistically do with this language and what are the most used packages in the ecosystem will be a great help to anyone curious about it.

Wow, those sites are a really good idea. I wish tech was more honest with it's pro's and con's. Seems like most project maintainers want to be marketers than engineers sometimes...
Post reply on HN