Recommended Posts

48 minutes ago, Mad Rocket Scientist said:

I'm not sure which is best, but I personally learned Python first, from this book: https://www.amazon.com/Hello-World-Computer-Programming-Beginners/dp/1617290920\

Python is nice because it a minimum of fussy syntax to learn. But C is more powerful, more relevant to embedded systems and arduino, and not very much harder to learn.\

Luckily, whatever you choose to learn will also teach you a bunch of stuff that will transfer over to other languages.

Python used to be the best language out there for handling strings, although this likely was sacrificed in favor of unicode during the change from 2.x to 3.x.  C's original method of string handling was not particularly good and lead to completely insecure code and had to be completely depricated.  You might even flee to C++ string handling, but expect that even thinking about touching C++ features have side effects upon side effects to those who never learned the details of C++.

- leaned C++ from library books.
- It took me weeks to find the bug in my just-beyond-trivial routine I needed to use a C++ library in my python
- the library books didn't bother to teach required keywords ("new" was one) that were needed to use programs with subroutines (i.e. any non-toy program, and most toy ones at that).
- won't touch the thing anymore, but might have to check my wrapping again soon.
 

Share this post


Link to post
Share on other sites

I learned C++ in a single semester college CS course required for my physics degree. Learned more from teaching the other students in the class than I did from the prof.

Share this post


Link to post
Share on other sites
13 hours ago, wumpus said:

C's original method of string handling was not particularly good and lead to completely insecure code and had to be completely depricated.

Woah, there. C always had safe methods of handing strings. It just didn't make it hard to write bad code.

// Lazy. Unsafe.
char string[20];
strcpy(string, input); // If input > 20 chars, buffer overflow. Vunerability.
// Correct. Secure.
char string[20];
static const size_t kSize = sizeof(string);
strncpy(string, input, kSize - 1); // Copies at most 19 characters.
string[kSize - 1] = '\0'; // Makes sure copied string is terminated, even if truncated.
13 hours ago, sevenperforce said:

I learned C++ in a single semester college CS course required for my physics degree.

I've been learning C++ for over 20 years. Can't say I've learned it all.

Share this post


Link to post
Share on other sites

Only remains to say that since C11 strncpy_s offers a more intuitive safe copy method :-)

------------------

I wonder whether @Cheif Operations Director has started and already had his first feeling of achievement or frustration ?

Share this post


Link to post
Share on other sites
7 minutes ago, Green Baron said:

Only remains to say that since C11 strncpy_s offers a more intuitive safe copy method :-)

------------------

I wonder whether @Cheif Operations Director has started and already had his first feeling of achievement or frustration ?

I have not started learning a code yet

I've been busy

Share this post


Link to post
Share on other sites
2 hours ago, K^2 said:

I've been learning C++ for over 20 years. Can't say I've learned it all.

Oh, I certainly wasn't saying I've learned it all, either. I meant that the one-semester class is what I needed to get my feet wet.

Share this post


Link to post
Share on other sites

A semester is long enough to learn C++ good enough to solve almost any problem, even more under instruction and when you've done another language before.

Practice is needed, and there is always more than one solution to a problem.

 

And C is much easier than C++, imo. Only one must start somewhere.

Demystifying things ;-)

Share this post


Link to post
Share on other sites
On 8/10/2018 at 5:15 PM, Cheif Operations Director said:

How to I write an interpreter for my own codE

I know this is being regurgitated over and over, but writing your own interpreter because you cannot stand learning a language seems exceptionally paradoxical to me.

By the time you have written your interpreter and make it interface with your hardware you know enough about coding to write your scripts into the language of your choice.

A couple of people seem really hellbent on pushing you towards C. I think there are better choices but I don’t feel like engaging in a shouting contest, so C it is. Do consider pure assembler. It’s a lot more direct in interfacing with the hardware, and it’s much less like a computer language than most others. It’s hardware specific of course, but you’ll get performance and you don’t need to learn C or another high level language to write your own interpreter.

Share this post


Link to post
Share on other sites
4 hours ago, Green Baron said:

A semester is long enough to learn C++ good enough to solve almost any problem, even more under instruction and when you've done another language before.

Problems you can solve after learning semester of C++ don't need C++ to be solved. You need C++ on complex projects with many moving parts and strict performance requirements. If you don't have one of these, no need to bother with C++; just throw some Java Script at it.

Of course, there's nothing wrong with using C++ for simple problems. If that's all you know because you just started, you want more practice, or even just for fun, C++ will do. But if you're only planning to learn a language for semester, I wouldn't recommend C++. Python or Java Script are going to be better options for that. If you think you might be interested in taking it further and go into a life of crime software engineering, then that is a good reason to start learning C++.

That said, I completely support C++ as requirement for Physics majors. It's nowhere near enough for most things practical (read, things you can't do in Matlab/Mathematica on your laptop), but it's good exposure, and modern theoretical physics is 50% CS. One should know what one is signing up for.

Share this post


Link to post
Share on other sites
40 minutes ago, Kerbart said:

 Do consider pure assembler.

"Viel Feind, viel Ehr !" German saying of one of the generals from early modern times when defending his fiefdom. Meaning "The more enemies, the more honor !". On second thought, sounds Klingon as well ... :-)

But i am interested, just because hobby. Could you recommend a good book to learn modern 64bit assembler, from ground on ? I mean, not something from a past millennium ? Gnu if possible ?

Share this post


Link to post
Share on other sites
2 minutes ago, Green Baron said:

But i am interested, just because hobby. Could you recommend a good book to learn modern 64bit assembler, from ground on ? I mean, not something from a past millennium ? Gnu if possible ?

I don't think this is a thing that's even done anymore. People write assembly inserts. Especially if you're a driver dev. And people need x64 assembly for debugging and otherwise messing with compiled code. But I'm not sure you'll find modern books on straight up programming in x64. If somebody wants to prove me wrong, I'd be curious.

I would take a more practical approach. If you are more interested in actually writing entire code in assembly, this is still something that's done for MCUs some times. I'd pick up something on, perhaps, PIC MCU, and either an actual chip with a USB dev board or an emulator, and just play with it.

Alternatively, there is a lot of good material on disassembly and debugging, which involves learning a lot of modern assembly. This is in case you are specifically interested in x64 and what compiled code looks like after optimizer had a go at it. For this, you'll want ability to compile your own code from C/C++ and be able to use debugger. gcc/g++ and gdb will do. Though, personally, I prefer the clang/clang++ and lldb combination for this. Unfortunately, all of the books I have on the subject are hopelessly outdated. So I can't recommend anything specific. But if you search for something on security and disassembly, you'll probably find something.

Share this post


Link to post
Share on other sites
22 minutes ago, K^2 said:

I don't think this is a thing that's even done anymore.

Yea, i had the same impression.

I once upen a time did a little 6502 assembly. Problem is, nowadays the tutorials all stop when it gets interesting, then there is a gap, and the next thing are the ly-long specifications from Intel or AMD that are as interesting as the Beijing telephone book if you don't know what to look for. Most if not all online books are 32bit and too close to masm or nasm, books on amazon have doubtful reviews and with packt books one can be lucky, but that is not always gueranteed.

Share this post


Link to post
Share on other sites

Yeah, that gap takes an effort to close, but basically everyone who works with assembly professionally ends up using instruction references, so that's the only material available.

It gets worse if you have to write machine code by hand, because documentation on which bits mean what within the instruction are extremely cryptic, and basically follow some sort of an Intel shorthand from decades and decades ago that I have to track down explanations for every time.

Why can't everything be like MIPS? (Don't answer that, I know why, just complaining out loud.)

Share this post


Link to post
Share on other sites

Honestly, I've never heard about it, but I can tell you the way I learned (what little I know).

I started with Logo and BASIC when I was 13 or 14, as part of optional Computer Science classes in my elementary school. We also had a Robotics class I (naturally) enrolled in. Unfortunately, the guidance was very poor so for those four years I didn't progress much. By that I mean, no one really explained the for loop, so I lived in this little world where I thought that was some complicated witchcraft and I avoided it. Arrays, what are those? The mechanical and electronics part of robotics held my interest more than programming so my skills developed in that direction and software stuff stagnated.

After elementary school, I made a serious life mistake of going to a wrong high school, something still I regret. While we had Computer Sciences there, it was all about Excel and PowerPoint, basically waste of time. My breakthrough came in college where I finally got someone to explain the basics and my eyes opened. We were learning C#, which came in handy rather soon. At work we had a continuous problem which required a lot of trial and error (something similar to the Knapsack problem). After a while I got bored of doing the trial and error thing and decided it was time to use my newly acquired programming superpower to solve the problem. The result was a tiny little windows form that would brute force the solution and spit it out in seconds. That was my first piece of code that actually had a purpose, and the feeling of solving a real problem is much better than just completing a tutorial. After that I switched to Arduino and did countless little projects for that same workplace where I still work. The switch to Arduino also came as a requirement, because most of the projects I do require interfacing with real world hardware (lights, motors etc.). 

So, back to your question, I have no idea if sololearn is any good, but I can tell you that finding a small problem in your life and solving it will be a much better experience and give you a feeling of instant reward. That problem can be anything - automated plant watering system, pretty flashing lights under your bed to ward off the monsters, whatever.

Edited by Shpaget

Share this post


Link to post
Share on other sites
2 hours ago, Shpaget said:

I started with [...] and BASIC

I've hit the same rock on my path. I've heard CS professors say, "It's alright if you've never programmed before. It's much worse if you know BASIC." Picked up some bad programming habits that it took me years to get rid of.

Share this post


Link to post
Share on other sites
15 hours ago, Green Baron said:

"Viel Feind, viel Ehr !" German saying of one of the generals from early modern times when defending his fiefdom. Meaning "The more enemies, the more honor !". On second thought, sounds Klingon as well ... :-)

But i am interested, just because hobby. Could you recommend a good book to learn modern 64bit assembler, from ground on ? I mean, not something from a past millennium ? Gnu if possible ?

Google “assembler programming on the arduino,” I think that’s an interesting machine to learn assembler on. I am serious for the OP though.  Learning ASM is very mechanical, and you’re more operating a machine than writing real code, so that might be workable.

Maybe not as a means to write an interpreter but at least to control the rocket. Although the moment you need math beyond basic arithmetic might also be the moment to decide that learning C is not such a bad idea after all.

Share this post


Link to post
Share on other sites
5 hours ago, K^2 said:

I've hit the same rock on my path. I've heard CS professors say, "It's alright if you've never programmed before. It's much worse if you know BASIC." Picked up some bad programming habits that it took me years to get rid of.

Don't agree, yes you learn some bad habits but you also learn how to write software. 
Now to be completely confused write an web application with vb.net backend and java-script frontend. 

Share this post


Link to post
Share on other sites
15 hours ago, magnemoe said:

vb.net backend

No thank you. But JS front and back is completely fine, so long as you use modern frameworks and keep in mind limitations of JS backend.

14 hours ago, kerbiloid said:

Since Visual Basic appears, this phrase is obsolete.

I'd even say QBasic. But I was learning to code on MSX BASIC. I didn't know how to use loops and subroutines until I switched to C. Fortunately, that happened very early.

Share this post


Link to post
Share on other sites

QBasic (as earlier QuickBasic) allowed both ways, and both were being used. Numbered lines even more often, like in other then basics.

VisualBasic was dictating more proper style, with If/End If and so on, and was being used in much more complex projects.

Edited by kerbiloid

Share this post


Link to post
Share on other sites
On 8/14/2018 at 2:17 AM, Shpaget said:

My breakthrough came in college where I finally got someone to explain the basics and my eyes opened. We were learning C#, which came in handy rather soon. At work we had a continuous problem which required a lot of trial and error (something similar to the Knapsack problem). After a while I got bored of doing the trial and error thing and decided it was time to use my newly acquired programming superpower to solve the problem. The result was a tiny little windows form that would brute force the solution and spit it out in seconds. That was my first piece of code that actually had a purpose, and the feeling of solving a real problem is much better than just completing a tutorial.

Working for a small law firm part-time after my first semester of CS. Criminal case. I had a PDF data dump (like, 200 pages) of the client's cellphone records. Converted to .txt and wrote a simple executable to sanitize, strip out the times and cellphone tower coordinates, and construct a map of where he had been and when, proving that he lied to us and the police about where he was. Convinced him to take the plea deal. If I hadn't, then we would have gotten hit by the same thing during trial and it would have gone very, very badly.

Not that the guy was a decent human being, mind you. But it saved us the trouble of preparing for a trial that we would have lost.

Share this post


Link to post
Share on other sites
On 8/13/2018 at 8:39 AM, Kerbart said:

I know this is being regurgitated over and over, but writing your own interpreter because you cannot stand learning a language seems exceptionally paradoxical to me.

By the time you have written your interpreter and make it interface with your hardware you know enough about coding to write your scripts into the language of your choice.

A couple of people seem really hellbent on pushing you towards C. I think there are better choices but I don’t feel like engaging in a shouting contest, so C it is. Do consider pure assembler. It’s a lot more direct in interfacing with the hardware, and it’s much less like a computer language than most others. It’s hardware specific of course, but you’ll get performance and you don’t need to learn C or another high level language to write your own interpreter.

c does teach some good fundamentals, so i think everyone should at least play around with it before moving on to something else. it was my first language though ive never really used it seriously (i actually prefer c++). c and asm are something you should learn if you want to go into embedded programming or if you want to write device drivers. its certainly a good idea if you want to write a fast bytecode interpreter (lua for example is written in ansi c). 

Share this post


Link to post
Share on other sites
1 hour ago, Nuke said:

its certainly a good idea if you want to write a fast bytecode interpreter (lua for example is written in ansi c). 

This is a somewhat dated view. Compilers got a lot better, and standard enforces some good rules that lead to better optimization now. There isn't a reason to chose C over C++ for performance anymore. Of course, you have to know how to write in C++ without relying on standard libraries if you're going to writer drivers or OS code, and when writing for performance, know which standard library calls do expensive error checking.

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.