News for hackers. Stuff that matters.
Re:Building an Operating System for the Raspberry Pi by AndyKelley on Thursday January 18, 2018 @06:06PM (#16182458)
If you're starting a new operating system project, you might consider using Zig[1] instead of C.

It does all the low level stuff that C does but it has some safety features as well as generics.

The standard library is usable in freestanding mode, even the data structures that allocate memory, because everything takes an allocator as a parameter.

Here are some examples:

* i386 OS: https://github.com/AndreaOrru/zen

* ARM (raspberry pi) OS: https://github.com/andrewrk/clashos

[1]: http://ziglang.org/

Re:Building an Operating System for the Raspberry Pi by jsandler18 on Friday January 19, 2018 @01:06AM (#16184446)
When I started this, I considered writing it I rust. However, I really wanted this to be the tutorial I would have wanted to read several years ago when I first developed an interest in OS, and a "modern" system language like zig or rust would have hurt that goal.
Re:Building an Operating System for the Raspberry Pi by mkesper on Friday January 19, 2018 @09:31AM (#16186421)
Because real programmers don't use such tools?
Re:Building an Operating System for the Raspberry Pi by jsandler18 on Friday January 19, 2018 @10:39AM (#16186993)
What? No. Because way more people know C than rust. I wanted to be able to reach a wider audience. I know I would have looked elsewhere if I saw found this but I didn't know the language.
Re:Building an Operating System for the Raspberry Pi by snaky on Thursday January 18, 2018 @07:15PM (#16182904)
There is ATS for the task, with all the C features plus proofs, quantified constraints, dependent types, linear types, interface for pluggable SAT solvers and so much more.

https://bluishcoder.co.nz/tags/ats/index.html

Re:Building an Operating System for the Raspberry Pi by earenndil on Thursday January 18, 2018 @10:37PM (#16183953)
Apparently this is the shill-c-alternatives thread. Here's a short list:

* Rust

* D

* Zig

* C2

* Nim

* LISP

* Ante

* Clay

Please note: I think all of the above languages (with the exception of C2) are awesome and should be looked at.

Re:Building an Operating System for the Raspberry Pi by cbHXBY1D on Thursday January 18, 2018 @11:23PM (#16184137)
* Myrddin

* Terra

Re:Building an Operating System for the Raspberry Pi by rhaps0dy on Friday January 19, 2018 @04:23AM (#16185032)
LISP Is Systems Programming

or, if you want,

LISP: Loses In Systems Programming

Re:Building an Operating System for the Raspberry Pi by earenndil on Friday January 19, 2018 @11:29AM (#16187447)
LISP machines?
Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @01:49AM (#16184564)
You forgot

- Ada

- SPARK

- Modula-2

- Modula-2+

- Modula-3

- Oberon

- Oberon-2

- Oberon-07

- Component Pascal

- Active Oberon

- Dylan

- Object Pascal

- Sing#

- System C#

- Swift

- C++ (assuming C++17)

Then the older than C, or about the same age.

- ESPOL

- NEWP

- PL/I

- PL/M

- PL/S

- PL/8

- Mesa

- Mesa/Cedar

- Algol68-W

These are the most well known ones.

Plenty of material to learn for anyone that anyone with interest in systems programming and how it evolved since 1960.

Re:Building an Operating System for the Raspberry Pi by earenndil on Friday January 19, 2018 @02:39AM (#16184717)
I'm talking about legit languages people are proposing to replace C with that are actually any good (except C2, it was an afterthought and I regret it because it was out of place and unlike the other languages there purposeless). Ada and perhaps C++17 is the only language people are actually recommending to replace C.
Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @03:36AM (#16184883)
Yeah, given the current market situation, you are right.

However, there are quite a few lessons on the manuals, papers and sample code from those languages, to learn about other approaches of doing systems programing.

Lessons that one can bring back to life.

For example, are you aware that ESPOL, the systems programming language for the Burroughs B5500 in 1961, about 10 years before C was created, already had the concept of UNSAFE code blocks?

Burroughs B5500 is still sold nowadays as Unisys ClearPath mainframe.

Or that IBM implemented their research OS and compiler toolchain for their very first RISC processor in PL/8, a safe systems programming language, using a compiler architecture similar to how LLVM looks like?

IBM mainframes still use PL/I variants, although new systems code is a mix of C and C++.

So plenty of ideas there to learn, even if no one is going to start writing new code in those languages.

> Ada and perhaps C++17 is the only language people are actually recommending to replace C.

I would still add Swift to that list, even if that turns out to be just like Objective-C, mainly specific to Apple platforms. Given Apple's roadmap for it.

Re:Building an Operating System for the Raspberry Pi by earenndil on Friday January 19, 2018 @11:10AM (#16187251)
Swift is more applications programming than OS or systems. It does have those capabilities, but no one is using it for that and it's not really the intent.

However, to the extent that swift (and obj-c!) are used for systems programming, those programs are useable outside of apple platforms.

Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @12:53PM (#16188184)
It is definitely the intent of Apple, explicitly mentioned on their developer documentation as C and Objective-C replacement.

"Swift is a successor to both the C and Objective-C languages."

https://developer.apple.com/swift/

As mentioned in another comment, most of the time the issue is political, not technical.

Re:Building an Operating System for the Raspberry Pi by Someone on Friday January 19, 2018 @03:57AM (#16184952)
Swift? I know Apple says they intend it to be usable for OS development, but I would want to see some real OS work (either from them or from others) before being convinced it is a real contender (or is there, and did I miss it?)
Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @04:29AM (#16185051)
Officially launchd and the Dock are now written in Swift (disclosed at WWDC 2017), so even though they aren't drivers or something, they are already a bit lower level than just apps.

Swift 4.0 got all the Unsafe* APIs stabilized, maybe they would be using it a bit more.

In any case, Apple also suffers an Objective-C vs Swift, just like Microsoft used to have C# (Longhorn, Singularity, Midori) vs C++.

Which means, even if it possible to use a certain language from technology point of view, many political wars have to be won as well.

Re:Building an Operating System for the Raspberry Pi by mveety on Thursday January 18, 2018 @07:14PM (#16182900)
I don't know if this is my conservatism speaking or not, but one problem I see with this approach is that you wouldn't learn as much because more batteries are included. Having to implement more than just a kernel (like the standard library and userland) gives you more of a chance to learn intangibles like what is or isn't appropriate to include in an API or what programs will actually be useful given your overall design. Also, there could be the problem of not having as many resources available in the language you're writing your OS in. That's a huge deal for a less experienced programmer.

That all being said, Zig looks pretty okay. It would be a good candidate to write an OS if you had to because the standard library looks trivially portable so you could test the userland on a known working kernel before getting it working on your new kernel.

Re:Building an Operating System for the Raspberry Pi by dom96 on Thursday January 18, 2018 @08:34PM (#16183369)
As an alternative to this you could use Nim[1] which compiles to C. If you, like myself, dislike C, Nim can be used as a "better C" (you can disable the Nim GC and forget about its standard library, then use Nim as a thin layer over C with modules, generics and other nice goodies)

1 - https://nim-lang.org/

Re:Building an Operating System for the Raspberry Pi by NetOpWibby on Saturday January 20, 2018 @08:12PM (#16196355)
I’ve been wanting to learn how to use a real programming language (I’m strictly front-end languages) and Nim looks great at first glance.
Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @04:04AM (#16184972)
Other point of view, would be to consider that the language runtime is the OS being implemented.
Re:Building an Operating System for the Raspberry Pi by derefr on Thursday January 18, 2018 @06:36PM (#16182659)
Why not Rust? Or, say, Ada?
Re:Building an Operating System for the Raspberry Pi by panic on Thursday January 18, 2018 @06:39PM (#16182683)
Or go all the way and design a new language too!
Re:Building an Operating System for the Raspberry Pi by qznc on Friday January 19, 2018 @04:38AM (#16185090)
Ah, the Knuthian approach. Why not go more than all the way and design an architecture too?
Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @06:44AM (#16185509)
That would be to just use Assembly, given Mix.
Re:Building an Operating System for the Raspberry Pi by snaky on Friday January 19, 2018 @07:19AM (#16185646)
Assembler is too high level these days. This would be translator from higher languages to hardware.

http://conal.net/papers/compiling-to-categories/

https://icfp17.sigplan.org/event/icfp-2017-papers-kami-a-pla...

Re:Building an Operating System for the Raspberry Pi by pjmlp on Friday January 19, 2018 @07:23AM (#16185673)
Thanks for the reading material, quite interesting.

I think you are right, recently I saw an Arduino-like projects book, but using VHDL instead, which somehow pointed into this direction.