top | item 36030153

Show HN: Ki Programming Language

40 points| ki_ | 2 years ago |github.com

Alpha preview for the ki programming language. Currently linux-x64, macos-x64 only. Windows users can use WSL for now. Feedback is much appreciated.

70 comments

order

bheadmaster|2 years ago

Always love to see people tinkering with their own languages. Everyone should write a language, at least once in their life :)

Skimmed through the docs. On the first look, the syntax seems to be a blend of Go and Rust.

Was confused by this sentence [0], perhaps some additional explanation/code example could help:

    When a value has ownership, it can be stored and used anywhere. But you can only store it in one place.
Aside from that, I'd really like to know about

1) concurrency support

2) memory management techniques

As those are the most interesting aspects of any C-like language to me.

Good luck!

[0] https://ki-lang.dev/docs/dev/borrow-ref

giancarlostoro|2 years ago

I say this every other programming language thread: Please, get some code examples up front and center, simple Hello World, and anything that shows whatever strong features your language has for organizing code like classes and so on.

Python, Racket and a few others do this really well. Even on the GitHub a simple short but significant enough code snippet would do wonders.

Maybe the syntax is exactly what I expect and I'll have more interest, or maybe its way off and I don't want to bother. Whatever the case, put some sample code up front and center.

keybored|2 years ago

I think it’s fine. It’s one link away, on the website.

Using the readme as a landing page kitchensink is a GitHubism.

theolivenbaum|2 years ago

Confused by the "C#: We do not use languages that expect you to install a 20GB IDE just to compile a 'hello world'." note, the .NET SDK is ~200MB last I checked, and Visual Studio is not required to compile C#. Seems like the https://ki-lang.dev/dist/download/linux/x64/latest build from Ki is ~40MB, so similarly sized.

ki_|2 years ago

i'll remove it ^_^ it seemed like they want you to use Visual studio and for me it was like 10GB+ for a minimal setup. idk.

arghwhat|2 years ago

An order of magnitude is not similarly sized. Neither size is worth complaining over though.

naasking|2 years ago

Reference counting is garbage collection. I mention this because the site claims no GC nut you claim I'm this thread that ref counting is sometimes used, which makes sense because borrowing sometimes isn't enough.

bheadmaster|2 years ago

While reference counting is technically a method of collecting garbage, in modern parlance the phrase "garbage collector" is mainly used for systems capable of collecting garbage of an arbitrary reference graphs, which reference counting by itself cannot do (cyclic references).

Atlas22|2 years ago

Not knocking Ki or any new language but what does it offer over existing systems? I see the criticism of a few languages on the website but they all boil down in reasoning to things like: garbage collection = bad, makefiles = bad. It also doesn't mention or demonstrate how Ki addresses the complaints. For example: if Ki doesn't do garbage collection or manual memory management, what does it do? Smart pointers/reference counting? How are circular references handled? (E.g. doubly linked list)

Would recommend removing the "Other" comparison as pretty much anything that can be said there is wildly inaccurate. Would also like to see comparison with Zig as it seems to have similar goals.

ki_|2 years ago

"It does not have any garbage collection and instead uses ownership combined with minimal ref counting to manage memory"

Because we only allow you to store values with ownership inside other objects, you cannot have a circular reference. It uses reference counting to know if something needs to be freed or not. But because we keep track of ownership and moved values we are able to run an algorithm that removes most of these counts.

janalsncm|2 years ago

> let num : u8 = 5; <-- auto converts to u8;

Can we please knock it off with reinventing different ways to declare a variable? This also irritates me about Rust. There’s nothing wrong with having syntax that looks like languages that have existed before. How about

[modifiers] [type] [variable name] = [initial value];

What I want in a programming language is not arbitrary new grammars, I want drop-in improvements to languages that already exist. C++ but with better dependency management. Python but statically typed (Mojo where you at?). PHP but standardize all the weirdness.

(Some or all of these rants could be out of date as my knowledge cutoff for languages ends at various times in the last 15 years.)

dllthomas|2 years ago

"let bindings" were present in ML in the 70s; I'm not sure whether they originated there or go back further. They've been used in many languages since, particularly those drawing on ML as a significant inspiration. It's not new, it's just borrowing from something you're unfamiliar with.

gavinhoward|2 years ago

As another commenter said, types before the variable has problems.

I don't like `let` because it's an extra four characters every time. But the

    [variable name]: [modifiers] [type] = [initial value];
only has one extra character and avoids all of the problems.

xigoi|2 years ago

Types before the name have several problems. And "let" is, like, one of the most common ways to declare variables.

lagniappe|2 years ago

> Go: Go is amazing. But it does have garbage collection, which can cause lag spikes in some cases. The creators were also very late on implementing common sense features, such as package versioning and generics. There are some other small mistakes, but the point is that we lack trust in their descission making.

> Rust: Rust right now might be the best language out there right now. It's hard for us to criticize them because we lack the experience of building big rust projects. We do however think rust has a really slow compiler. We also think that rust might be too idealistic where it restricts the developer too much.

> C: C is obviously the best but... we dont always want to manage our own memory. Also their std-lib lacks alot of basic functions. You are forced to work with makefiles or similar build tools and most of those tools are very badly designed.

> C++: C++ is like a worse version of c. They do have the most features of any language, which allows the developers to write the greatest code and also the worst code. You let a developer work on a project for a year and suddenly you are looking at a codebase full of OOP, templates and the most hacky preprocessor logic you've ever seen. That developer says it's built using todays greatest standards, yet no one is able to understand the code at all. Sometimes you have to limit bad practices.

> Other: All other languages use garbage collection which makes them hard to use for millisecond realtime applications. Secondly, most languages allow you to have undefined behaviour.

I'm not sure if this section is really making the case you wanted to make. Either this needs to be rephrased or scrapped all together, it doesn't present the best foot forward because ideally you are recruiting people from these languages, and in your descriptions of them you make some very facile comparisons.

zerr|2 years ago

Why not make Swift a truly cross-platform language? I find it to be in a sweet spot between safety, performance and usability.

pacaro|2 years ago

Zig seems to have similar goals and be rather further along, thay would be a good comparison language. I feel that zig's error handling is cleaner that ki's

FpUser|2 years ago

>"Sometimes you have to limit bad practices."

The way to do it I think is to properly mentor / monitor juniors rather than tying up hands of experienced developers.

ki_|2 years ago

I removed this section from the website. As others said, the text is not good and not really helpful.

sebastianconcpt|2 years ago

V-lang doesn't have GC, and how it compares to it?

wiz21c|2 years ago

> LLVM is however really slow. There isnt much we can do about this except write our own IR compiler, which we would rather not do.

So compilation times are dominated by llvm so there won't be any significant improvement on compilation speed.

> Ki is a statically typed language. It's advantage over most languages is that you cannot have any undefined behaviour.

Java, C, C++ are statically typed. I understand it's not many languages, but they do represent a pretty large share of coders...

ModernMech|2 years ago

Word to the wise: stay away from reporting benchmarks against establish langs until your language is further along. It's often misleading when you see that your toy language is faster to compile / run than established languages, because what you'll find is that as your language grows and becomes more complete, your timings will times will go up.

Atlas22|2 years ago

Usually "no undefined behavior" also becomes an abrasion for performance when compilers grow to support more instruction sets.

chomp|2 years ago

This looks promising. If it ends up as Rust without the line noise, I’m 100% on board.

FpUser|2 years ago

This is the impression I have. Bus the site is way too slim. This language need more features and bigger standard lib. But I like the way the did with the ownership. Way more attractive than Rust. Having classes does not hurt either even though the implementation looks like very basic. Hopefully all of this will improve in the future.

pxeger1|2 years ago

I think the !! operator is redundant. If your language has a "never" type, then exit/return/break/panic should have a return type of never, so those expressions would be acceptable on the right hand side of !? anyway. I guess it's necessary if your language lacks a never type, or has a distinction between expressions and statements, although I don't know really why you would have either of those

frodowtf|2 years ago

Good effort. It feels like there is still a lot of improvement space for languages with a soundness+productivity focus.

Docs need some polishing tough. The comparison to other languages doesn't make the point of Ki clear to me.

Also, error handling feels like black-box magic with all those exclamation and question marks sprinkled everywhere. Those symbols seem vaguely chosen.

ki_|2 years ago

! ignores the function error (only possible with void return types)

!? provides an alternative value when the function errors

!! exits the current scope on an error, e.g. return,continue,exit,...

It doesnt seem that complex. Ofcourse, there is also '??' and '?!'. That might make it more difficult. It's not vague actually. if it starts with '!', it's a function error handler. if it starts with '?', it's a null-check.

fridental|2 years ago

If you like C but don't want to manage your memory yourself, why don't you take a look at glib/gobject?

wudangmonk|2 years ago

Less effort and and hassle to write a new language down to the compiler itself than to deal with glib/gobject. This is unironic btw.

e12e|2 years ago

Or zig.

return_to_monke|2 years ago

Why would someone choose this over Rust?

ki_|2 years ago

at the moment, if you want a non gc language with automatic memory management, rust is your only choice. ki is an alternative, but my goal is to make it a much simpler than rust. I need to spend some more time writing rust & ki in order to answer your question with full certainty.

haspok|2 years ago

Another brand new language with curly braces and semicolons... emphasizing line noise over information /sigh OK, ok, I'll show myself out.

Freebytes|2 years ago

What would you suggest instead? Please do not say Python. Using spaces for syntax is madness.