GithubHelp home page GithubHelp logo

Comments (6)

dumblob avatar dumblob commented on June 11, 2024

This makes sense to me for several reasons:

  1. it allows simpler, cleaner, and safer interfacing with other languages and libraries
  2. it does allow arbitrary use of \0
  3. it shouldn't constrain C users as they can can use e.g. the sds string trick to avoid the error-prone tracking of string length in separate variables

from nuklear.

Hejsil avatar Hejsil commented on June 11, 2024

Another thing that would be nice with this change would be if all sizes where of type size_t. This also makes interfacing certain safer languages simpler (I can avoid an @intCast in Zig). It is also semantically more correct as I assume there is no way a length would ever be negative. strlen also returns size_t :)

One small con with such a change would be that C defines behavior for unsigned int overflows but signed int overflow is undefined. Operations on signed integers can optimize better because of this.

from nuklear.

Temtaime avatar Temtaime commented on June 11, 2024

Personally i don't see any reasons to not use null terminated strings. They are simple and fit very well as this is simple C gui library.
No reasons to overcomplicate it.

from nuklear.

dumblob avatar dumblob commented on June 11, 2024

Personally i don't see any reasons to not use null terminated strings.

There is one. And it's very important one. Bindings to other languages. Nowadays "nobody" is writing GUIs in C. But libraries are written in C because of easy interoperability. And so is Nuklear.

No reasons to overcomplicate it.

Feel free to design a better solution conforming to the above mentioned requirement.

from nuklear.

Temtaime avatar Temtaime commented on June 11, 2024

C null terminated string is a standard. Every programming language has utilities for interoperability with it. I'm using Nuklear with Dlang and there's no pain with its API at all.
You don't insist to rewrite windows API for example, isn't it?

from nuklear.

dumblob avatar dumblob commented on June 11, 2024

Every programming language has utilities for interoperability with it.

They do, but as you said with "having utilities". That's just a nice way of saying they don't support null-terminated buffers/strings as first class citizens. And I fully agree.

You don't insist to rewrite windows API for example, isn't it?

I don't follow - Nuklear has nothing to do with Windows API.

from nuklear.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.