OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Mar 03, 2021 10:03 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 54 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Real alternatives of C
PostPosted: Sun Nov 15, 2020 2:28 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
Hello Everyone. With the help of you guys and stackoverflow, I'm making progress in my hobby OS I started in the holiday time as universities closed due to corona. I used assembly(nasm) to write bootloader, Interrupt handling stuff, drivers(except display) and some other low level stuff that make my basis for my kernel, which is just a program that is a CLI, text editor and a half working interpreter.

I used C for writing the kernel, and used linker to link the assembly to make the binary. Although I've learned a lot about x86 and PC hardware, my initial goal is to push my C skills to the limit and beyond and also gain a foothold in asm(Hence my OS has an interpreter but not even have GUI or multithreading and other complex stuff. I don't even uses interrupt except for keyboard, and maybe PIC in future).

This got me wondered about other systems programming languages. I have college experiences for C++, but I can't exactly figure out how those OOP concepts of C++ map to assembly. C was a lot easier to figure out what was happening in my PC without having to look through compiler asm. Also, I find C++ very hard.

Now, Java and python aren't exactly systems programming language, as they run on VM. Python is easier than C to master, as it puts a layer of abstraction without complicating things. But that limits the ability of these to communicate to hardware. But I don't understand why they needed to isolate the program from the system. The only thing I could think of is security.

I don't think there is too many jobs for C programmers out there. So I want to expand my knowledge to others. But I like systems programming, or games and applications. What do you guys think about other alternatives as C? Is OOP concepts good to practice? Or I have to go the same route as all others with some variant of JS and python, or do the impossible and master C++?

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 3:09 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4109
Location: Chichester, UK
Rust.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 3:54 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
iansjack wrote:
Rust.


Heard about it, but not enough. Is it a true alternative to C, such that it can replace it? Can you tell me it's advantages and disadvantages?

Also what about the job market? If I learn rust, is it easy enough to get to a job?

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 3:56 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 22, 2019 5:46 am
Posts: 576
The language must be able to produce standalone "programs" (kernels) = without runtime library.

I asked similar here:
viewtopic.php?f=13&t=37326

I also would name Pascal and ObjectPascal and perhaps Go.

There is a page about programming languages for use with OS development:
https://wiki.osdev.org/Languages

Greetings
Peter

_________________
The "fanboy"
https://wiki.osdev.org/User:PeterX


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 3:58 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 1072
go is another alternative to C, though it uses garbage collection unlike rust.

I wouldn't worry too much about OOP.
First, it's not obligatory unless you really need to use some existing OOP stuff in e.g. a library, outside of which you may avoid OOP mostly or completely.
Second, the very basic encapsulation and inheritance are easy and shouldn't be hard to learn.
Third, complex OOP stuff, all those "design patterns" built with OOP, is likely going to be a waste of time for you in the foreseeable future (it may be interesting to read about, but unless you have a need to build quality APIs for others to use and unless you already have experience building complex stuff, it's likely going be an unnecessary distraction and complication and there will be bugs in both the design and implementation).
Also, I don't think C++'s OOP part is special. I think C++'s OOP facilities are rather basic and common, that is, commonly available in other languages.

Modern C++ is big (many different concepts, many details and quirks) and that's what makes it complex (all little and not so little things do add up). C is compact (in terms of concepts and overall) and much simpler (though, you may need to invent half of the world before you can program in C comfortably because the language and its standard library are quite minimalistic).


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 4:35 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 824
C and C++ have much more jobs than Rust. (But Rust is still a decent replacement for C.)

Why do you have the impression that there are no C jobs? Pretty much all embedded dev is done in C. (I guess this depends a bit on where you live etc.)

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 7:07 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
PeterX wrote:
The language must be able to produce standalone "programs" (kernels) = without runtime library.

That is needed only for embedded systems and OS, right? I think of more of a general case, like uses of C++. You can use it with Win32 API to make Windows Apps, use it inside game engines to make games, etc. I've actually played with Win32 in C( not much). I would say it is definitely a use case for C.

I mean I can use C style C++ and be a C++ programmer, but I would like to know some modern alternatives to C. Also I would like to know your take on other languages like python.
alexfru wrote:
go is another alternative to C, though it uses garbage collection unlike rust.

I don't know about Go, but I've heard it is more of a language for server stuff. Does it output executable binary? I've also heard Go has easy syntax, might check it later.
Korona wrote:
Why do you have the impression that there are no C jobs? Pretty much all embedded dev is done in C. (I guess this depends a bit on where you live etc.)

Yes, there is not that much embedded jobs in here, as there is not much hardware companies. I'm more inclined to get a job in application programming like Win32 or something until I find some jobs in low level stuff where I can use C, as I like C. But Win32 is complex and hard. That's why I wanted to know alternatives.

Also I want to ask now, should I try to get a job in embedded? I think I'm not that much of a skilled programmer. That's why I want to find some modern(easier) stuff than C, so that I can use it for job and keep C in my hobby stuff.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 7:08 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
Korona wrote:
C and C++ have much more jobs than Rust. (But Rust is still a decent replacement for C.)

Will that be the case in future, tho? I heard the rust compiler is smart and can detect a lot of logic errors and stuff.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 7:30 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 22, 2019 5:46 am
Posts: 576
So you are not bound to OS dev.
I think: Regarding jobs you can go the mainstream road, Java, C++, Python.
And like in other job areas, there is specialization. Some people produce business applications. Others games, or web development. Or many other specializations...
You should probably do both of the following:
a) choose your specialization and learn the languages which are important for that.
b) learn many, many different programming languages to be able to adapt to ANY language that your future boss wants you to know.
Your "programming horizon" can be widened by learning the following languages:
- Prolog: Logical programming
- make: Constraint based programming
- Scheme: Functional programming in Lisp syntax
- Forth: Stack based programming in Forth syntax
- Javascript, PHP, CSS: Web programming
- Cobol, Excel: Business
- C++: For jobs in the game industry
- Lua: For games and configuration
- some mathematical language, like Haskell or ML or so
- Assembler: For getting a deep understanding of hardware
I probably missed some useful languages, but I think you get the idea: Broaden your skills.

Greetings
Peter

_________________
The "fanboy"
https://wiki.osdev.org/User:PeterX


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 7:57 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
PeterX wrote:
So you are not bound to OS dev.

OS development is fun and interesting, but as you can imagine, there are not that many jobs developing kernel components in my area(unfortunately).

Also, even though I understand your advice of broaden your skill, I don't think I am going to master EVERY programming language on this planet. That is why I need help. I don't want to go too far from OSdev and C programming, and end up as a Web developer or something. As I told, I would have gone Win32 if it was not so complex. From your replies, I understand rust and Go are good alternatives that I want to check out. I hope you guys understand what I mean.

My end goal is OS dev, but that's a bit too far fetched for me right now, as a beginner programmer. That is why I want to get some experience in user space app programming.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 7:59 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 639
I know a lot of different languages. I dislike them all except Java and C# are all right. The web stack I can get a long with. The only languages I love are C and ASM. Everything else adds uneeded complexity. C gives you the most power. Now that I have made my case for C :) , the only alternatives to C IMO are Rust and Go. I don't know either language, but they seem to be good alternatives to C.

_________________
Currently working on the Nexware project, an attempt to make a less bloated version of GNU. All repos for it can be found at https://github.com/Nexware-Project.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 8:01 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
PeterX wrote:
I think: Regarding jobs you can go the mainstream road, Java, C++, Python.
And like in other job areas, there is specialization. Some people produce business applications. Others games, or web development. Or many other specializations...


As I mentioned in previous post, I don't like Website building stuff. I can go desktop application like business apps or games. Probably android, but mostly Windows or linux. I haven't tried linux APIs. Windows legacy API WIn32 is hard, as I understand(correct me).

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 8:07 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
nexos wrote:
I know a lot of different languages. I dislike them all except Java and C# are all right. The web stack I can get a long with. The only languages I love are C and ASM. Everything else adds uneeded complexity. C gives you the most power. Now that I have made my case for C :) , the only alternatives to C IMO are Rust and Go. I don't know either language, but they seem to be good alternatives to C.


Yes, that's the problem with me. I love the flexibility and simplicity of C. I don't want to leave C, but holding to C locks me in embedded and OS departments only. Even Desktop programmers requirement is C++ when actual Win32 also supports C. That is why I want a language like C for more general case, so that I can somewhat like and therefore like that I do when I get a job.

Can Go and rust be replace C++ in application programming? That would be awesome, especially, Go seems to be simple as C is.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 8:07 am 
Offline
Member
Member
User avatar

Joined: Fri Nov 22, 2019 5:46 am
Posts: 576
pranavappu007 wrote:
... I don't think I am going to master EVERY programming language on this planet. That is why I need help. I don't want to go too far from OSdev and C programming, and end up as a Web developer or something. As I told, I would have gone Win32 if it was not so complex. From your replies, I understand rust and Go are good alternatives that I want to check out. I hope you guys understand what I mean.

My end goal is OS dev, but that's a bit too far fetched for me right now, as a beginner programmer. That is why I want to get some experience in user space app programming.

I gave the wrong impression you would have to master them all at once. But over your career it would be good to learn (step by step) the different approaches to programming, like functional, OOP, relational database, markup, logical, reverse polish (Forth).
A key language is definitely Assembler.
The bad news is, you probably HAVE to learn complex stuff to be a pro. Like C++ and Win32 API. You probably should try to learn them. And good news are: You don't have to "master" these topics totally, it is enough to learn a bit of them.
I still think you should choose a specialization. Maybe it is system programming on a userland level instead of kernel development. And it is true that that doesn't give you the best job opportunities.

_________________
The "fanboy"
https://wiki.osdev.org/User:PeterX


Top
 Profile  
 
 Post subject: Re: Real alternatives of C
PostPosted: Sun Nov 15, 2020 9:57 am 
Offline
Member
Member

Joined: Mon Apr 20, 2020 11:02 am
Posts: 88
PeterX wrote:
[Maybe it is system programming on a userland level instead of kernel development. And it is true that that doesn't give you the best job opportunities.

Yes, I have to learn complex stuff to be a pro. But you can't learn till you get professional skills and then get a job. Work experience is a part of becoming pro.

My question was simple. Now, I have intermediate skills at C and beginner skills at Assembly. But, I don't think sticking to C will get me a job right away, as I don't think embedded programming jobs will be given to beginner level programmers, and also kernel level stuff. So until I get a job and become a pro, my C probably won't be helpful.

I need a language that can get me a job quickly, and the experience will be helpful for my C skill, so that I can become a pro and get inside low level programming community and back to C finally.

_________________
A beginner developer/student. Likes to know stuff. Don't have an OS to put here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 54 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot] and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group