Coder Social home page Coder Social logo

Comments (5)

matz avatar matz commented on August 18, 2024

The mruby core part should be implemented in (C99 - VC unsupported features) in principle, so we shouldn't need such platform specific headers. Time (for gettimeofday and gmtime_r) is exceptional, since C99 is far from complete here.

from mruby.

jonforums avatar jonforums commented on August 18, 2024

The benefit of enabling platform specific code organization really starts to shine when you're implementing portability via API abstraction. Of course the cost to this style is that the build system has to be made smarter. But non-build system developers/contributors (the majority) don't have to pay that cost to get the code organization benefits.

For example, say you'd like to implement cross platform function loading from shared libs via an API wrapper.

One style is the libuv style in which you use a platform specific header and platform specific source files:

Another style is the current lua style in which you #define\if defined the different platform specific API wrapper impl functions all in the same source file: http://www.lua.org/source/5.2/loadlib.c.html

And a related style is the current ruby plugin for vim style in which you rewrite the symbol name with a #ifdef\#define and try to use the same impl code in a single file:

Of those three styles, I find libuv's cleaner, smaller source files with minimal #ifdef to be more focused, more understandable, and more maintainable. Smaller, more focused source files tend to be kept fresh and updated because their complexity is less. For example, once a file grows in size and complexity similar to CRuby's file.c developers/contributors tend not refactor it because of (a) the fear of breaking things, and (b) it's sheer size makes it harder to reason about.

mruby source may never have to deal with this file size/complexity issue, but then again it may as devs try using mruby on a number of different platforms.

from mruby.

matz avatar matz commented on August 18, 2024

As a original implementer of I understand what you mean. We've tried so much to hide platform variety.
But the goal of mruby is to provide platform neutral implementation, except for a few corner cases,e.g. gettimeofday in time.c Platform dependent code, such as I/O, Sockets, etc. should be implemented outside of the core.

So my opinion is that mruby will not need such mechanism to hide the detail. On the other hand, the platform dependent extensions to mruby may use a tool such as autotool.

from mruby.

jonforums avatar jonforums commented on August 18, 2024

OK, thanks for more info on mruby's goals wrt platform dependent code.

And I really hope extensions don't use autotools as it unnecessarily complicates multi platform support. As you can guess, I think it's a poor choice vs. cmake...it should be banned from mruby ;)

Please close this issue so it doesn't attract bikeshedding and distract from implementation.

from mruby.

matz avatar matz commented on August 18, 2024

Yes, and I hope cmake will make us happy.

from mruby.

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.