Kona – An open-source implementation of the K programming language (github.com)

programming

128 ups - 51 downs = 77 votes

66 comments submitted at 13:33:53 on Jan 18, 2014 by sumstozero

  • [-]
  • ctangent
  • 38 Points
  • 15:40:15, 18 January

This is truly some of the worst C code I've ever seen. WTF

  • [-]
  • dirkt
  • 11 Points
  • 15:48:39, 18 January

I think people who love some kind of language also try to program in other languages the same way. Hence the huge amount of defines that make it totally unreadable for anyone not used to that way of thinking.

IIRC, the source code of J (another variant of APL) is written in a similar style.

But then, both J and K look like random character noise to me. :-)

  • [-]
  • theseoafs
  • 4 Points
  • 16:26:39, 18 January

> I think people who love some kind of language also try to program in other languages the same way. Hence the huge amount of defines that make it totally unreadable for anyone not used to that way of thinking.

The macros make it unreadable for anyone who isn't the author.

  • [-]
  • pygy_
  • 7 Points
  • 18:23:35, 18 January

Four people have significatly contributed to Kona.... Five more provided small patches.

  • [-]
  • sumstozero
  • 4 Points
  • 17:10:33, 18 January

Well that's not exactly true; you could read the macros.

  • [-]
  • ctangent
  • 22 Points
  • 17:42:48, 18 January

When is #define R return ever okay?

  • [-]
  • pygy_
  • 5 Points
  • 19:03:53, 18 January

Whenever you want to have fun in your free time?

  • [-]
  • sumstozero
  • -4 Points
  • 18:20:35, 18 January

When it helps you solve your problem?

The C code here is certainly unconventional but without a comparable work it's hard to judge.

All conventions are just conventions.

  • [-]
  • ctangent
  • 11 Points
  • 18:29:11, 18 January

What kind of problems do you have that prevent you from writing "return" instead of "R"?

  • [-]
  • Megatron_McLargeHuge
  • 4 Points
  • 22:45:08, 18 January

He's trying to write K in C. Obviously if you're writing a Pascal compiler in C you would use

#define begin {
#define end }

/s

  • [-]
  • sumstozero
  • -4 Points
  • 18:42:22, 18 January

Prevents. Nothing. But depending on the context it may be clearer if it fits in with the algorithms that you're writing.

  • [-]
  • theseoafs
  • 11 Points
  • 19:05:22, 18 January

There is no "algorithm" wherein "R" expresses more clearly that you want to return a value than "return" -- especially considering you're writing C, which has had a "return" keyword for thirty years.

  • [-]
  • sumstozero
  • -5 Points
  • 19:16:19, 18 January

Beware of absolutes.

The creation of problem-oriented syntax can be a very powerful tool.

If you're transcribing an algorithm from a paper then it makes sense to stay as close as possible to that form; it's common in maths to invent some new notation, and it's not difficult to imagine something like ... R(f(n*m)) ... , combined with other macros that introduce conditionality, being used in such a context.

At the end of the day his clearly makes sense for someone writing K.

Making a language runtime that someone who knows the language but doesn't know C could start to understand makes sense. It's arguably even a good idea.

Wouldn't you like the Python runtime to be more easily understandable by Python programmers, if such a thing were possible?

  • [-]
  • theseoafs
  • 7 Points
  • 19:15:10, 18 January

> The C code here is certainly unconventional but without a comparable work it's hard to judge.

Comparable work? There are literally thousands of open-source C implementations of programming languages online for you to peruse. You will find that none of them look like the codebase for this particular project -- that's for a reason.

  • [-]
  • sumstozero
  • -3 Points
  • 19:22:27, 18 January

That's comparing pythons and haskells.

Comparing an implementation of K written in idiomatic C would be useful. If we then found that the this implementation was far longer, or shorter, or that it encode the ideas better, or worse, then we would have a useful result. All we can say otherwise is that this isn't idiomatic C. Which even if you are enjoying your little circle jerk, isn't a very interesting statement.

  • [-]
  • Meta_Bot
  • 1 Points
  • 01:21:07, 19 January

This comment has been linked to in 1 subreddit (at the time of comment generation):


This comment was posted by a bot, see /r/Meta_Bot for more info.