Comments (5)
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.
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:
- unix: https://github.com/joyent/libuv/blob/master/src/unix/dl.c
- windows: https://github.com/joyent/libuv/blob/master/src/win/dl.c
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:
- http://code.google.com/p/vim/source/browse/src/if_ruby.c#55
- http://code.google.com/p/vim/source/browse/src/if_ruby.c#466
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.
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.
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.
Yes, and I hope cmake will make us happy.
from mruby.
Related Issues (20)
- Null pointer dereference involving Struct.new()
- Null pointer dereference in mrb_string_value_cstr
- Stack overflow in mrb_vm_exec HOT 1
- [Question] Get receiver object for different levels of calling stack
- Will YARP(prism) be used as a built-in parser for mruby in the future? HOT 2
- Why not stop updating the Copyright years? (著作年の更新をやめませんか?) HOT 3
- Incorrect symbolic sinks in binary built on Linux HOT 3
- 'Remote branch HEAD not found in upstream origin' error on build HOT 3
- binding.eval() handles `def` expressions differently from CRuby HOT 2
- mrb_fixnum resulting in different values depending on the boxing setting HOT 2
- fails to call superclass of wrapped method HOT 2
- `ensure` section is not executed if the function exits via a return in a proc HOT 3
- VM crashes with bread after #6101 HOT 1
- Function unable to take either Hash or named parameter variant HOT 2
- Beginner docs? HOT 2
- `String#unpack1` returns an array instead of a single string HOT 2
- ARM-based macOS: Unable to build `mruby-compiler`: `syntax error, unexpected identifier, expecting string` HOT 2
- pre-commit failure from prettier
- mrb_load_irep_file does not work on Windows HOT 2
- Infinite loop in String#index with binary data when MRB_UTF8_STRING is enabled HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mruby.