# if kernel rewritten from scratch



## darkshadow (Oct 24, 2010)

Will it be rewritten using c++? Or another language?


----------



## richardpl (Oct 24, 2010)

I recently read how rewritting stuff hurts.

Rewriting kernel in c++ is dumbest idea ever.


----------



## darkshadow (Oct 24, 2010)

*heee*

Don't misunderstand me, I just meant if it happens for some reason, what will they choose?


----------



## Beastie (Oct 24, 2010)

.NET Framework


----------



## aragon (Oct 24, 2010)

Who cares, and who could possibly even know?


----------



## Oxyd (Oct 24, 2010)

_Why_ would anyone want to rewrite it?

It would take lots of time, lots of effort, it would stall any real development for a long time (devs would be busy rewriting, instead of adding new features and fixing bugs), it would introduce new bugs and it would bring us nothing.

Why do you think the kernel -- and supposedly the rest of FreeBSD as well -- should be rewritten? Be it C++, F#, or FORTRAN.


----------



## luna (Oct 24, 2010)

It wouldn't be FreeBSD anymore, too much traction for C. OTOH, pushing an embedded language into kernel (Lua[*] or Scheme) has a higher chance of success.

[*] there is a similar project for netbsd called lunatik
http://mail-index.netbsd.org/tech-kern/2010/10/05/msg008900.html


----------



## da1 (Oct 24, 2010)

But then again, remember the USB stack before 8 branch ? It was re-written because pretty much no one was satisfied of how it was working (well, actually, not working).

At a certain point, you realize the whole darn thing might be better off written in another way just because of .... many reasons.

Realistically, how many of you came back to a script you wrote 2y ago and said "Hmm, this script would make more sense if it was written in another way" ?

Of course, if time is an issue, rewriting something is non-sense (if it works good enough) but if time is not an issue, sure ... why not (if it makes sense to do it) ? Times change, scripting/programing languages change, ppl change and if you fall behind you will be (left) behind.


My 2c.


----------



## graudeejs (Oct 24, 2010)

It's one thing to rewire a subsystem of kernel.
It's completely another thing to rewrite kernel.

Also If you think FreeBSD should rewrite kernel, please explain why? Does current kernel doesn't work well?


----------



## darkshadow (Oct 24, 2010)

*mm*

I think freebsd FreeBSD with current kernel work very well I'm not asking about if we need to rewrite it or not, unix kernel developed from long time ago, I just wonder if there are any reason demand freebsd FreeBSD community to rewrite the kernel what language would they use and technology?
(the only language was suitable in the past was c)


----------



## Alt (Oct 24, 2010)

darkshadow said:
			
		

> Will it be rewritten using c++? Or another language?


Actually I don't know what C++ can give to kernel. This is pretty low-level programming, so moving to high level is just another headache.


----------



## Beastie (Oct 24, 2010)

darkshadow said:
			
		

> the only language was suitable in the past was c


And it still is. Its simplicity is fundamental.


----------



## shitson (Oct 26, 2010)

I think the motivation behind the question should be understood - Are you asking what language a modern operating system would be written in?


----------



## darkshadow (Oct 26, 2010)

*thats my point*



> what language a modern operating system would be written in?



Yeah sure, that's my point. Do you have an answer ?


----------



## rden (Oct 26, 2010)

Millions of generations of chickens and eggs can't be wrong:
C is still the best choice for an operating system.

(Hmmm, or is it eggs before chickens?)


----------



## graudeejs (Oct 26, 2010)

rden said:
			
		

> Millions of generations of chickens and eggs cant be wrong:
> C is still the best choice for an operating system.
> 
> (Hmmm, or is it eggs before chickens?)



Recent scientific research proved that chicken was before egg....
Don't ask me how they proved, it's to complex to explain in my native language, not to speak about English


----------



## Crivens (Oct 26, 2010)

rden said:
			
		

> Millions of generations of chickens and eggs cant be wrong:
> C is still the best choice for an operating system.
> 
> (Hmmm, or is it eggs before chickens?)



There is no question what came first, chicken or egg. It was the rooster.
That's what she said 

Apart from that, some good systems have been written in other languages than C, heck there even is a complete system (including compiler, ...) written in some variant of FORTRAN. But for the FreeBSD kernel, C is the best choice. Maybe one day the language will be some subset of C with several things stripped out, then it will no longer be C. Maybe one could call that a rewrite.


----------



## richardpl (Oct 26, 2010)

FreeBSD should be rewritten in assembly to get maximal performance. Both clang and gcc fail to give performance to your code.


----------



## Crivens (Oct 26, 2010)

richardpl said:
			
		

> FreeBSD should be rewritten in assembly to get maximal performance. Both clang and gcc fail to give performance to your code.



Good bait to hook trolls. Congrats!
Your statement is completely correct, and utterly wrong at the same time, if I may be so bold to say so.

But I hope you own, and wear, fireproof underwear? I mean there may be those who do not get the joke


----------



## darkshadow (Oct 26, 2010)

*using assemply*

I think they will take
100 year to develop
100 year to debug 
till  that they arch will change they will repeat the process
I was think about middle level language


----------



## Beastie (Oct 26, 2010)

richardpl said:
			
		

> FreeBSD should be rewritten in assembly to get maximal performance.


Possible, but we would lose portability. And one would need *good* assembly programmers or the result will be as unoptimized and inefficient as code written in the most HLL.


~~~~




			
				darkshadow said:
			
		

> 100 year to debug


Assembly is the easiest to comprehend and most logical language if you understand how an architecture works, so no. I think it would be only slightly slower to debug than C.



			
				darkshadow said:
			
		

> I was think about middle level language


Choose C-- or C + a lot of inline assembly and you have already lost portability which is important for systems like FreeBSD.
C is and will always be the best choice.
Choose anything higher and efficiency starts to decrease. Even the output of C compilers is sometimes horrible. Check it out and see for yourself.


----------



## noz (Oct 27, 2010)

killasmurf86 said:
			
		

> Recent scientific research proved that chicken was before egg....
> Don't ask me how they proved, it's to complex to explain in my native language, not to speak about English



I'll explain.  This is an easy question to answer if you think about evolution.  It's clear that the chicken came first.  Something that wasn't completely a chicken gave birth to a chicken.  What about the egg?  Isn't it a chicken egg?  Well, no, it was a "something that wasn't completely a chicken" egg that had a chicken in it.


As for darkshadow's kernel question, just take a look at this page:
http://en.wikipedia.org/wiki/Comparison_of_open_source_operating_systems

C dominates the list as the kernel programming language.  You want efficiency in the kernel, and there's very few options available if efficiency is your main concern.


----------



## DutchDaemon (Oct 27, 2010)

I think this topic, the chicken, _and_ the egg have run its course


----------



## UNIXgod (Oct 27, 2010)

Historically it was written in assembly. Also C has ties to the system due to the need for a portable assembler. UNIX birthed C to birth UNIX. Almost in the same sense to use enough assembly to create the smallest amount of C possible to build the rest of the language within itself...C.


----------



## rden (Oct 27, 2010)

UNIXgod said:
			
		

> Almost in the same sense to use enough assembly to create the smallest amount of C possible to build the rest of the language within itself...C.



Originally that was true but these days the most common way to produce a compiler is to write the first one in another language (commonly C) and/or on another machine (with a modified output stage for the target machine).  Sure the first few C compilers were written in PDP assembly (PDP-7) but eventually it compiled itself.  (They later even used YACC (written in C) to produce C compiler C source code.)

It's been a long time since a brand new compiler started as assembly.

Also not all languages are eventually used to compile themselves: consider writing a COBOL compiler in COBOL - technically not impossible, but not a idea unless you hate yourself.
(Whats the chances while the younguns are Wiki-ing COBOL some old timer will tell me they did just that).


----------



## captobvious (Nov 13, 2010)

Scheme/LISP as a candidate would be interesting academic project; just a guess, but let's say 1/3 lines of code but 100-200% performance penalty. 

Actually, can anyone name a computer kernel written in Scheme/LISP?


----------



## noz (Nov 13, 2010)

captobvious said:
			
		

> Scheme/LISP as a candidate would be interesting academic project; just a guess, but let's say 1/3 lines of code but 100-200% performance penalty.
> 
> Actually, can anyone name a computer kernel written in Scheme/LISP?



Here's an entire OS written in a pure functional language, as opposed to Scheme and LISP which are mostly functional.

http://programatica.cs.pdx.edu/House/


----------



## captobvious (Nov 15, 2010)

Wow nice link, thanks. I am learning Clojure now, if LISP turns me off I will have to give Haskell a shot.


----------



## ChalkBored (Nov 17, 2010)

captobvious said:
			
		

> Scheme/LISP as a candidate would be interesting academic project; just a guess, but let's say 1/3 lines of code but 100-200% performance penalty.
> 
> Actually, can anyone name a computer kernel written in Scheme/LISP?



Lisp as an academic project leads to crazy things.
like GNU.
http://en.wikipedia.org/wiki/Lisp_machine


----------



## Crivens (Nov 17, 2010)

ChalkBored said:
			
		

> Lisp as an academic project leads to crazy things.
> like GNU.
> http://en.wikipedia.org/wiki/Lisp_machine



Many things, when in academic use, can lead to crazy things. The same goes for industrial use, mind you. When crunching numbers, I would pick Fortran. When crunching rules, that would be prolog. Some things are best done in lisp, some in C/C++. Of course you can shoehorn any program written in a touring complete language into another such language, but the result may not be pretty and might not perform as expected.


----------

