Page 3 of 3

Posted: Sun Apr 01, 2007 12:53 am
by Colonel Kernel
Dex wrote:So what this for http://www.dslinux.org/bugs/
Do not get me wrong, i am not saying C is not portable, it's very portable, just like a tent is very portable, but tents make s**t home's :lol: .
I think you're missing the point. Let's say you have a bug that requires you to fix 300 lines of code (maybe it's a bad one). If that bug is a logic bug and not architecture-specific, you'd have to fix it in all code lines for all architectures. If you use a portable language like C, you're going to be fixing about 300 lines of code. If you use asm for each code line, you'll have to fix about n times the amount of code, where n is the numbers of architectures you support.

Again, this is not a concern for hobbyists, but in commercial-grade software development you'd be hard pressed to find enough experts on your various architectures to keep all the code lines well-maintained. A lot more people know C, so it becomes a lot more cost-effective to maintain platform specific code written in C.

If you're saying that asm code tends to have fewer bugs than C code, that's another argument altogether (one I'm not even going to waste my time on...).

Posted: Sun Apr 01, 2007 4:47 am
by AndrewAPrice
ehird wrote:
niteice wrote:
Alboin wrote:An internal scripting language for use in the OS sounds pretty cool....
My plan was to embed Lua in the kernel. One would be able to modify the entire kernel on-the-fly, uploading new code at any point. Insecure? Quite. It would be awesome to actually pull off though :D
I could start porting emacs to use lua if you wanted ;)

(Actually, after finishing a basic "learning OS" I'm going to try something like that... kernel upgrades without rebooting!)
You could write a Lua interpreter that runs directly runs on the hardware, and use GRUB to pass it a startup script. Then have as much as your kernel as possible and all your device drivers big Lua scripts. An interpreted kernel would run awfully slow.

Posted: Sun Apr 01, 2007 2:27 pm
by niteice
MessiahAndrw wrote:An interpreted kernel would run awfully slow.
LuaJIT solves that (even though the standard Lua VM is rather speedy anyway).

Posted: Sun Apr 01, 2007 2:32 pm
by ehird
niteice wrote:
MessiahAndrw wrote:An interpreted kernel would run awfully slow.
LuaJIT solves that (even though the standard Lua VM is rather speedy anyway).
Ok. I am using that as my interpreter. Very cool ;)

Edit: Looking at the lua code, it doesn't actually use much! It uses standard C headers, sure, but none that can't be relatively easily coded (apart from maybe malloc). LuaJIT shouldn't use much more, either. So, with a few patches to the source code, statically linking Lua into a basic kernel would be possible... and that's that.

Posted: Tue Apr 03, 2007 5:53 pm
by ~
Colonel Kernel wrote:
Dex wrote:So what this for http://www.dslinux.org/bugs/
Do not get me wrong, i am not saying C is not portable, it's very portable, just like a tent is very portable, but tents make s**t home's :lol: .
I think you're missing the point. Let's say you have a bug that requires you to fix 300 lines of code (maybe it's a bad one). If that bug is a logic bug and not architecture-specific, you'd have to fix it in all code lines for all architectures. If you use a portable language like C, you're going to be fixing about 300 lines of code. If you use asm for each code line, you'll have to fix about n times the amount of code, where n is the numbers of architectures you support.
What about starting only with one architecture and, when it's really bug-free (with fairly complete design) start to port to another architectures? That should help make for a more predictable situation.

Posted: Tue Apr 03, 2007 6:02 pm
by mystran
ehird wrote: Edit: Looking at the lua code, it doesn't actually use much! It uses standard C headers, sure, but none that can't be relatively easily coded (apart from maybe malloc). LuaJIT shouldn't use much more, either. So, with a few patches to the source code, statically linking Lua into a basic kernel would be possible... and that's that.
You could try writing a minimal program with embedded lua, linked in statically, then ask objdump to list symbols it imports from system libraries, to get an idea of what you need to implement.

IIRC you can leave most of the stuff like files and whatever out of the interpreter if you want, which should reduce the amount of code that you need to supply.

Posted: Tue Apr 03, 2007 7:08 pm
by anon19287473
niteice wrote:
MessiahAndrw wrote:An interpreted kernel would run awfully slow.
LuaJIT solves that (even though the standard Lua VM is rather speedy anyway).
*partially joking* who cares about performance, in another year, the new computers will be fast enough to run my software, *cough* vista *cough*

This mentality works to an extent, in that (some) speed needs to be sacrificed for convenience, but its not an excuse to be a lazy coder!

Posted: Tue Apr 03, 2007 7:16 pm
by Colonel Kernel
~ wrote:What about starting only with one architecture and, when it's really bug-free (with fairly complete design) start to port to another architectures?
Heh... As a commercial software developer, I have to laugh pretty hard about something being "really bug-free". :D Especially when new features keep getting added over time (to which the same argument applies).

Posted: Wed Apr 04, 2007 12:08 pm
by Assembler
Combuster wrote: I like assembly because you can easily see what something does. Since register calling conventions are far easier than passing on the stack i have been avoiding C, to the point that when it pays off, basic has become more suitable for the task.
Remember, u need to push & pop the registers u've used in your code, so it would end up with the same number of pushes & pops as the C would do.

Sorry, my reply comes too late, but i've to comment :D

Thanks

Posted: Wed Apr 04, 2007 2:46 pm
by mystran
Assembler wrote: Remember, u need to push & pop the registers u've used in your code, so it would end up with the same number of pushes & pops as the C would do.
Except that if you check the output of a typical compiler, it doesn't necessary push/pop at all. Having tried writing a compiler, it's often easier to simply address from the stack pointer, generating loads/stores with offset, and then just adjust the stack pointer separately for function calls. On modern computers this is usually just as fast (if not faster) than using push/pop.

The advantage of the method is that you can allocate/deallocate space in the stack simply by adjusting a variable inside the compiler, without generating any code. You only need to touch the location when you want to load/store a value, and you can't cache it in a register, and you only need to touch the stack pointer when you need to adjust it for a call.

Ofcourse you can use the same method when writing in assembler, and on architectures that don't offer push/pop, you kinda have to. Not that it makes the spirit of your statement any less valid. Just thought I'd mention.

Posted: Thu Apr 05, 2007 10:06 pm
by AndrewAPrice
anon19287473 wrote:
niteice wrote:
MessiahAndrw wrote:An interpreted kernel would run awfully slow.
LuaJIT solves that (even though the standard Lua VM is rather speedy anyway).
*partially joking* who cares about performance, in another year, the new computers will be fast enough to run my software, *cough* vista *cough*

This mentality works to an extent, in that (some) speed needs to be sacrificed for convenience, but its not an excuse to be a lazy coder!
I agree..

If you must interpret your kernel in LUA and you see a use for it (or just to prove it can be done), then sure, sacrifice some performance and go ahead - amaze us all! But, if you're just just a lazy coder and think it's easier to write tens of thousands of lines of bloated LUA code than using C/ASM, you'll be popular for all the wrong reasons..