I am total new to programming

Hey everyone: I am totaly new to programming.
What is the Best language to learn before starting with rust?
Thx!
limak

Hello,

People who start with high-level languages such as Python or JS often have difficulties to learn lower-level languages and to understand how the computer (hence their programs) work.

With Rust you are guided by the compiler, so unlike with C you won't spend hours on debugging segfaults, and you understand what you can or can't do with pointers and stuff. Do definitely I think Rust is the best low-level language to begin.

Beginning programming with Rust is harder than with Python, but I think it will be easier to learn any new language after. But the absolutely "best language to begin with" is relative to what you want to learn/do.

4 Likes

I think you are right in wanting to learn another language before Rust, as it may be a bit hard as a first programming language :sweat_smile:

In my opinion python is probably the best language to learn as a beginner, as it allows you to focus on algorithms rather than the specific implementations of what you want to do. There is an official tutorial, and a ton of resources online to help you learn.

If you want to get closer to what Rust does though, I would actually recommend C, as it serve as a good and (kinda) simple entry into low-level programming concepts: what is memory, how are things actually encoded... I don't think there are official learning resources for this one, but again, C is an incredibly popular language, so the internet should be flooded with tutorials.

And well, Rust itself might be an option: the book is pretty incredible !

If you know absolutely nothing about programming, I would actually recommend you also find someone that might help and teach you: for example if you have access to some beginner programming course in a university, or even just a friend that might direct you to useful programming tools.

1 Like

The question of whether Rust is a suitable first language for someone who has never programmed before is a recurring topic around here. Some say yes, some say no, I'm not aware of any consensus on this.

As such what we need to do is try it. Find total beginners to programming, start them of with Rust and see how it goes. Perhaps you would like to be the first quinea pig in this experiment?

By way of encouragement my first introduction to programming was by doing very simple things in BASIC. Like printing a greeting message, which in Rust looks like this:

println!("Hello, world!");

Which I think you might find quite obvious. Especially when you read in the book that println prints a line of text. The ! means it's a macro, but you don't need to know anything about that at this stage. The the ( and ) remark whatever you want `println' to print. And the stuff in double quotes is the text you want printed.

Then back in those BASIC days we moved on to simple arithmetic calculations, which in Rust look like this:

    let a = 2.0;
    let b = 3.0;
    let result = a + b;

If you have done any math in school the meaning of the above should be pretty clear.

Next we might have moved on to programs that make decisions. Which in Rust would like this:

    if result > limit {
        println!("Too big");
    } else {
        println!("Just fine");
    }

This looks a bit strange perhaps, with those { and }. But they are just brackets around lists of instructions to do. The rest should be pretty easy to work out. if and else from normal English use and a mathematical condition with >.

Next we might have moved on to repeating instructions many times. Loops that is. Which in Rust look like this:

    while result < limit {
        println!("Increasing result...");
        result = result + 1.0;
    }

It might be clear that while is used as in English. As in "while it's too cold warm it up". Followed by a list of instructions to do.

What do you reckon? Understandable or gibberish for you?

Of course I'm skipping over some details of getting those things running in Rust here. But I will claim no matter what language you start with there will be a bunch of mysterious details you need to absorb to get anything working, even if it's not necessary to understand them all from the get go.

And yes, Rust has a lot more features than that. That does not mean that a rank beginner has to worry about them.

In support of my claim I will point out that millions of non-programmers in recent years have gotten a start by programming the Arduino micro-controllers using C++. Now C++ is a "Rust like" language, though massively more baroque and complex, but the Arduino guys have done a good job of providing teaching materials and libraries that make it really easy to use, even for those that have never seen a program before.

Having had to learn C as a third language, after BASIC, Assembler and ALGOL all those years ago I would strongly suggest you don't start with C. Yes C is a simpler language but it's a lot harder to use correctly, and when you make simple mistakes you can spend a lot of time in frustration trying to figure out what has gone wrong. In fact having used ALGOL I could hardly believe anyone could take C seriously for actual work.

By contrast the Rust compiler issues very friendly and helpful error messages when you make a mistake. Importantly it won't blindly let you run code that it knows is incorrect and leave you to figure it out. Languages like Javascript and Python also suffer from that bad behaviour.

So, are you up for the challenge, start with Rust? If you get lost or stuck you can always ask here. Plenty of folks to lend a hand. Such a conversation might give someone insight on how to write a "Programming for beginners, in Rust" book.

2 Likes

Pretty understandable. Thx a lot..

Excellent. Sounds like we have a volunteer.

Some my ask what it is you have in mind to use your up and coming programming skills for. Pointing out that if you want to make complex user interactions or funky data presentations in the web browser then Javascript is the language to start with. Or if you want to do data analysis and such Python is the choice. And so on.

Worst of all, if you want to get a job learn language X because skills in X are in big demand. Franky I think if ones motivation to learn programming is only getting a job one is approaching it all wrong.

Personally I don't think it matters what language one starts with. If one knows nothing of programming the job in hand is to learn what a program is and the basic elements of programming that are pretty much common to all languages. Once you know what variables, statements, conditionals, loops, functions, objects, methods, etc are you are in a good position to dive into any other language. Most programmers know many more than one language anyway.

1 Like

I agree, this is the most important place to start. If you just "want to program" the process is likely to be extremely frustrating. Instead, identify what you would like to do, or to be able to do. Once you've done that, you can get advice as to how you might best get started.

Probably C or C++ because it's easy to go wrong in those languages ..... You'll learn to look for errors in them.

Later Rust cus it teaches you everything you failed to understand in C/C++ step by step

Ah but I was claiming exactly the opposite.

If you have no idea about programming or even what a program is or anything about what programs can do then I feel it's a bit premature to be thinking of what you might like to be doing with any programs you create.

That was the situation I was in back in the day. I was driven to select a computer science course in technical school simply out of a fascination with the the notion of computer and the vague notion that one could calculate with it. Mind you, that was at a time when most people had never seen a computer, except in SciFi movies perhaps.

I think of it in the same way we learn arithmetic early in school. They don't start out by trying to explain where learning maths might lead they just try and get us bootstrapped with some basics and hopefully inspire curiosity to take it further.

If one already is capable of understanding that perhaps learning Javascript is the way to start if one wants to make web pages jump then one is already a few steps more advanced than I'm talking about.

Anyway, the essence is programming. What is an algorithm. How does one get a computer to run an algorithm. The actual programming language is only a detail. Although it helps if a language for beginners is as free of "clutter" as possible and drop dead easy to get running. Which I believe Rust is. At least for those first steps.

My goodness what? That sounds like suggesting teaching skydiving to beginners without a parachute. Getting beginners to use dangerous machines without safety guards or interlocks. Motorcycling without helmets.... After they have recovered from enough bad accidents they will get the hang of it, right?

In that respect I would go further and suggest that those new to computers and programming should be introduced to it with assembler. Which, unlike C and C++ has the great advantage of demonstrating what is actually going on at the bottom of our software world. We learned assembler as young teenagers, I loved it.

Teaching programming has to start with imparting the basic notions algorithms. Of values, variables, operations, statements, sequence, selection, iteration. It would be better if nothing much got in the way of that. Like the weird syntax of C and the many interesting ways one's simple mistakes can make it fail silently in hard to discover ways.

These considerations are what BASIC was invented back in the day.

More philosophically, and perhaps controversially, I'm going to suggest that it is about time we started to raise a new generation of programmers that find the wobbly, unreliable, error prone mess of C, C++ and others, unacceptable. Rather than perpetuate the attitude that it's all perfectly normal as has been going on for decades since notions of correctness and pride in ones creations were dismissed with the downfall of ALGOL and later Ada.

1 Like

In video game form, Human Resource Machine is a pretty good introduction to these topics.

1 Like

Or, if that’s too easy and happy and colorful for you, try TIS-100 instead! :grin: …… :sweat_smile:
(another link)

There’s also Shenzhen I/O from the same creators which is slightly newer and somewhat more colorful and a bit less hard.

Edit: By the way I wanted to second the fact that Human Resource Machine is a very nice game.

1 Like

imo you should be spoon-fed of all your errors only when you're capable of figuring it out without much help in the first place.
look at the bright side, we'll learn to ask fellow programmers for help, or look for your specific answer on the vast internet easily.

And also C/C++ is not that weird too, keeping in mind that most of the embedded programming is written in these 2 languages, and algorithms and other concepts can be implemented in them too as effectively as any other language or even better

And learning motorcycling without a helmet isn't a bad idea if you survive without any bruises and the experience makes you wear a helmet every time for the rest of your life.

C/C++ are old and error-prone languages? Yes, but that doesn't mean they're straight-up terrible.
There are jobs seeking C/C++ developers even today. Learning it as a first programming language may not be a great experience, but better than learning Python, Javascript like high-level language.
It's easier to learn Python after C/C++/Rust than vice versa

I stand by my suggestion of C/C++ before Rust (If new to the programming world and is a must to learn a language before Rust) as Rust is always seen as a (several)step up from C/C++.

1 Like

The only reason I see for learning anything else before Rust is that other programming languages might come with more beginner learning material online. Or maybe I am not aware of good beginner learning resources for Rust but they exist? Who knows…

My opinion: Don’t learn C++ before Rust. C++ is a complicated beast, you’ll come across a plethora of features, especially around “object-oriented” programming, that you will never need for programming Rust. Other (more reasonable) languages such as C or Python might have the advantage of being “easier” or “simpler” (but ultimately simplicitly of a language is quite hard to measure).

I personally feel like lots of people that suggest learning C or C++ before Rust only do so because that’s the path that they took themselves. I could talk about my own path which includes learning a decent amount of C and even C++, and a lot of Haskell before learning Rust. It also includes a whole undergraduate degrees in computer science and an (ongoing) graduate degree, which comes – among other things – with a lot of Java. I could tell you that the language that helped me best in understanding Rust, particularly the harder parts, was probably Haskell.

I like Haskell a lot, I could tell you to learn it before Rust, because I feel like it helped me a lot with learning Rust and because I like the language and think that it’s worth learning on its own. But I do also feel like I understand that this point of view is just as subjective as other people suggesting C++ to be learned before Rust.

Here’s the thing: If your motivation to learn programming is connected to an interest to learn something about the programming language Rust, then stick with that motivation and start with Rust. If it doesn’t work out too well, stay open to trying other things first, especially for the most fundamental things the choice of language probably doesn’t matter all that much. I didn’t learn programming online myself but instead by interaction with other people (teachers, classmates) that could already program during middle / high school time, so I can’t tell you about any online resources do learn programming by yourself, but I guess the most relevant part is to find some path to get started, or some learning material you want to follow, or a goal you want to achieve, or even a programming-themed computer game that sounds intriguing to you (see previous posts); whatever works for you. Learning programming – just like learning anything else – isn’t actually hard, it just takes some time and the right motivation, then you’ll probably get there no matter what you do.

5 Likes

Thx a lot!

I will counter that by claiming that it would be far less wasteful of human life time and all round more efficient if endless generations of new programmers didn't have to trip over the same unnecessary booby traps, over and over add infinitum.

Judging by my efforts to help newbie programmers on the Raspberry Pi forums over half a decade now I think it would be great to remove all those unnecessary diversions. Free their mental effort for actually developing more working code rather than having to scratch ones head for hours and waste peoples time on the net asking how to fix trivialities.

From my end of the telescope, which is rooted in 1975, C and C++ are really weird. Having been previously programming in BASIC and ALGOL where a simple mistake was not going to randomly crash ones program leaving no hint as to why, or crash the whole operating system for that matter.

In 1980 when I had to do some work in C I was dismayed how sloppy it was. I was soon beaten into shape and convinced it was "normal" and "necessary" and it's all my fault if programs my fail. Which lead to a long career programming in C and C++. All the while being afraid to voice my opinions about their robustness for fear of being written off as a terrible programmer and an idiot. Until Rust arrived and showed it need not be so,

That is a shocking statement. For reasons I hope are obvious.

Correct. I love C. Despite my comments above. Because it is a minimalist, small, simple language. Because it is about the least possible high level language, after leaving assembler, that allows for portable code. Because even I could probably create a C compiler in a reasonable time, even if that was not producer of efficient, optimised code. I don't see my totally abandoning C any time soon.

C++ on the other hand is actually terrible. It is massively complex. Nobody understands how it all works. It has accreted ever higher level language features using a baroque syntax as it has to always be backwards compatible with C. Mean while it has never addressed all the issues it drags along from its foundations in C.

True enough. No matter, we are talking about getting a raw beginner into programming, not getting some supposed job in the future.

I'm not so sure. I think Javascript under node.js or even in the browser would be an excellent first language. Like BASIC was back in the day. Only Javascript is a very sophisticated and interesting language.

Is it?

Admittedly Rust is a huge step up from C in high level language conveniences, robustness and ease of use. Ideal for those starting out in programming.

2 Likes

It depends on what you want to get done. It's always a matter of choosing the best tool for the job.

In general, very rarely you'll be writing everything from scratch and you'll typically reuse existing libraries. Some languages have good libraries in some areas but not so good ones in other areas.

You can start with Rust, it has very helpful error messages and I think learning basics will be fun and predictable -- but if you want to write e.g. a mobile phone app, Rust might not be the best choice at the moment and you might be better off with e.g. Kotlin. Or for web apps perhaps TypeScript.

Personally, I have two recommendations:

  • learn a language by working on a project that you want to use
  • use a statically typed language like the ones mentioned above (or Rust). Using types is a great way of letting the compiler check that the values that you're passing around are the ones you're expecting. This is a great way of using the computer to find potentially frustrating problems, it saves time and effort and lets you focus on bits that are fun.

I think the above answers are all pretty great! In general, I don't think it really matters which language you start with - they are all * roughly * similar (once you understand what a loop is, you can do it in pretty much every language... just need to familiarize yourself with the different syntax) but as previously mentioned, each also is targeted at different uses (like data science vs embedded processors vs web user interfaces vs ... etc) and have varying levels of complexity to accomplish those goals.

I think if you are a complete beginner, either take a course (EDX CS50 from Harvard is an incredible course for your first intro to computer science and it's free) or choose a language that has "A+ first class" documentation online (so when you get stuck... which you will a lot... it's easy to find the answer)! Since you posted the question in the Rust forum, it's got great docs and you could start there! Or Python/C/Go/Java/Javascript/etc/etc are also equally well documented with big communities online for support. Hope that helps!

1 Like

A friend of mine recently took their first programming course, and it happened to be in C++. One of their first assignments was something like: "Read in a line from the user, and print out a case-insensitive character count for all English letters." They had a near-solution which produced incorrect counts, and they asked me for help; they suspected some flaw in their logic.

Before even reading the code, I threw it in a playground-esque website to try it out, and I saw the same behaviour. Then I compiled it on my own box and ran it locally, and still saw the same behaviour... followed by a smashed stack error from a check that gcc had kindly inserted.

Ultimately, they had two errors: They were reading input into a 0-length array, and they weren't checking their bounds when incrementing counts (e.g. when a user input a non-letter). With a default compiling arrangement, there were no compile-time warnings or errors. Additionally, the only run-time error was gcc's smashed stack detection. (The playground I chose had no run-time errors.)

That experience convinced me that Rust would be a better beginning language for a complete beginner than C++.

3 Likes

*caugh* functional programming *caugh*
(you can’t really do “ordinary loops” in e.g. Haskell :wink:; they use recursion instead)

2 Likes