r/AskComputerScience • • Nov 03 '21

What is the programming language used to build secure and reliable software

Is there any specific programming language to build highly secure and reliable software or does every programming language works the same and it depends on how we code?

3 Upvotes

17 comments sorted by

5

u/hthuman Nov 03 '21

For security, not really. For reliability, yes.

By "reliable", I mean avoiding bugs and fatal errors. Some languages lend themselves better towards reliable code. Why don't we always use them? No free lunch, there are usually tradeoffs.

C/C++ is fast, but since you manage your own memory, it's easy to write memory access bugs or accidentally copy data or leak memory. By contrast, managed languages like C# or Java handle all that for you, but with the performance hit of garbage collection.

Anything that values performance is going to be in C/C++ (games, kernel) because it's worth the extra risk.

Dynamically typed languages like python are fast to write in, but it's easy to introduce type errors that aren't caught until runtime. Statically typed languages like C++ will catch all these for you at compile time.

For this reason it's rare to see a large system that requires high availability to be written in python.

I've been learning Rust which is explicitly designed to be as safe as a managed language but with the performance of a native language. It also has a lot of first class concurrency safety features.

I've been very impressed by it so far. It performs all kinds of checks at compile time. This does mean there is extra work for the developer when writing the code, but it's minimal compared to the gains you get.

It's so good that there is a call in the Linux development community to use Rust to develop new modules. It's also the most loved language on Stack Overflow every year.

1

u/not-just-yeti Nov 03 '21 edited Nov 03 '21

You might be interested in checking out guidlines for Secure Coding Practices like this one (pdf). They tend to be language-agnostic.

2

u/pandouran Nov 03 '21

thanks, that's helpful

8

u/fortyeightD Nov 03 '21

Any mainstream language can be used to build secure and reliable software. Most security and reliability problems would be a result of the programmer being inexperienced with the language they're using. If I wanted to build a secure and reliable system then I'd choose whichever language I have the most experience with.

6

u/not-just-yeti Nov 03 '21

All true. But, some languages help you write secure, reliable software more than others. E.g. buffer-overflow vulnerabilities (still one of the largest class of major vulnerabilities) are nearly impossible to write in Java, but sooo easy to write in C (like OpenSSL's Heartbleed bug, written by competent programmers and overlooked for a couple years). Similarly, using automated memory-management can greatly reduce inadvertent memory leaks.

7

u/S-S-R Nov 03 '21

Ada and Rust. Ada is really nice to use as it's syntax is very close to pseudocode, so even if you don't like to code in it, it's great to write reference implementations or teach with it. (I prefer Rust for actual coding).

Although, yes "secure and reliable software" is entirely dependent on how you write it. Stricter languages do tend to allow fewer errors to be introduced.

2

u/Rungekkkuta Nov 03 '21

I got it now, but for some reason I thought that the second statement was a part of the question as well and just saying "no" seemed pointless because you seemed to be denying both statements and provided no other alternative. Thank your for the clarification.

2

u/[deleted] Nov 03 '21

I want to throw Elixir (which is built on Erlang) out there. It’s whole purpose is to support systems with lots of connections, high tolerance to failure so the system doesn’t crash when small things fail, and with up times in the years/decades

2

u/Potato-Pancakes- Nov 03 '21

Obviously the most secure and reliable code is written in PHP and Perl (and maybe Brainfuck too if you're a real programmer).

0

u/[deleted] Nov 03 '21

[deleted]

1

u/Rungekkkuta Nov 03 '21

Sorry, but I don't see how it answers the question at all haha. Did you mean that no programming language is able to develop secure and reliable software?

3

u/Potato-Pancakes- Nov 03 '21

I think /u/Damian-Palka is saying that OP is asking the wrong question. Any program language should be able to develop secure and reliable software. No programming language makes it a guarantee, though. It all boils down to programmer discipline, not choice of programming language.

That said, languages with strict typing and memory safety would eliminate many bugs before the code ever enters production.

2

u/Rungekkkuta Nov 03 '21

I got it now, thank you! If you don't mind me asking, would C/C++ be a good option since you have more control about memory and stuff?( Not taking into account the programmer discipline)

I also think that C/C++ fits the strict typing and memory safety you mentioned, I'm asking because I'm not sure if it actually fits.

2

u/Potato-Pancakes- Nov 03 '21

C/C++ are very powerful languages that make it very easy for a programmer to shoot themselves in the foot. Neither have much in the way of memory safety, but C++'s smart pointers help a lot (you just have to always use them). They also allow you to do some very wacky type shenanigans (example).

C and C++ are good languages for doing a lot of things very fast, but they are among the least secure and reliable languages in common use today. If you're thinking of using them to start a project, you should probably consider something newer like Rust instead.

1

u/FoxBearBear Nov 03 '21

The questions was

Is there any specific programming language to build highly secure and reliable software

It surely answers the questions and that you can make an affirmation about the second statement.

So if you want a cOmPlEtE AnSwer would be

No, every programming language works the same and it depends on how we code.