Question:
Going from C# to C,C++,Perl, Python and Shell?
Lol Funny
2013-07-17 12:02:10 UTC
Hi there,

I'm a college student and have to learn these programming languages in order to pass a course I have coming up. I'm already fairly competent in c# but I have no idea about these languages. I'm currently learning more about them as I search the net and therefore becoming increasingly fearful of the difficulty compared to c#

Could someone please give me some advice on the transition from C# to these other languages?

Is it possible to be competent or at least be able to code well in these languages after a month?

Any help will be greatly appreciated, thank you!
Three answers:
Just Jess
2013-07-17 18:44:22 UTC
C# and C++ are supersets of C. So that's the one I would start with.



The easiest way to get started is by making some classes. A class in a c-based language is really something called a "struct" with some magic to make it work in an object oriented fashion. In order to learn how to make classes in C, you are going to need to learn just these concepts:



* structs

* the . and -> operators, and how they relate to structs

* typedefs

* pointers (VERY important)

* function pointers

* "malloc" and "free" (which you already know as Marshal.AllocHGlobal and Marshal.FreeHGlobal)

* how to properly use headers and forward declarations, to separate your public interface from your code

* preprocessor directives, especially #include, #ifdef, #define, and #endif

* preprocessor macros

* how the "static" and "extern" keyword works with functions, and the similarities and differences between "static" in C and "private" in C#



Once you understand all that, a class is just a struct with a pointer reference to itself passed in as the first argument to any method. In other words,



self->do_something(self, arg1, arg2)



And once you understand that conceptually, then Perl and Python will be very easy to learn for you - because they do the exact same thing! In fact, there are ways to access the "self" member directly in both those languages. Perl especially will be easier for you, since you can program in whatever style you are used to. Python's flexibility and being very loosely typed is very addictive and easy.



And once you learn Python, you will like C++ a lot less because it is really really strict. Learning C++ might be easier once you've learned Java. The key difference between C++ and other programming languages is "templates". You do understand already how to use namespaces. But once you know these java concepts:



* Generics

* Interfaces, and how to use them to work around single inheritance



then you will know how to do things the "hard" way, and you'll be able to appreciate and use multiple inheritance in C++, and templates in C++. Everything else will be concepts you already know. Practice using C++ heap management commands like "new" and learn their limitations. Also practice mixing in C code, because many times you will want to be able to use C libraries.



Finally, the bash shell, is pretty simple. You need to know:



* strings and variables, and how to use $var and ${var} and some ${var} constructs. A quick example,



x=file.jpg

y=${x%.jpg}.png

echo $y

# output is file.png



* the test command, and how to use [ ] tests



Otherwise you really need to learn just as many unix tools as you can. At a bare minimum,

* a terminal editor

* sed and awk

* cat, more, less, head, tail, and paste

* ps and kill

* echo, wc, and the |, &, >, <, and << operators

* the backtick operator, `, the command let, and the $(()) operator

* cd, pwd, rm, touch, cp, and dd (careful with that one)



Bash has some loop constructs that work the way loops do in other languages. In order to do a for loop, you need to know how to use the seq command.



One last thing, in C#, when you do a switch/case statement, you can't "flow through", so you might not be familiar with that concept. I would look it up, it is very useful. You can use dictionaries in python like switch/case statements, there are tutorials online that will help you.



Good luck to you :)
Michael
2013-07-18 05:12:59 UTC
I don't know shell but I would go from low level to high so C > C++ > Perl > Python
anonymous
2013-07-18 05:03:24 UTC
you know C# so you can learn any other languages within short time. I'd like to suggest you to learn C# professionally then learn ASP.Net or other C# related development.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...