Real alternatives of C

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Real alternatives of C

Post by pranavappu007 »

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.
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Real alternatives of C

Post by iansjack »

Rust.
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Real alternatives of C

Post by PeterX »

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
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Real alternatives of C

Post by alexfru »

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).
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Real alternatives of C

Post by Korona »

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].
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Real alternatives of C

Post by PeterX »

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
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
nexos
Member
Member
Posts: 1078
Joined: Tue Feb 18, 2020 3:29 pm
Libera.chat IRC: nexos

Re: Real alternatives of C

Post by nexos »

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.
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Real alternatives of C

Post by PeterX »

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.
pranavappu007
Member
Member
Posts: 91
Joined: Mon Apr 20, 2020 11:02 am

Re: Real alternatives of C

Post by pranavappu007 »

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.
Post Reply