this post was submitted on 04 Jan 2025
29 points (73.8% liked)

Programming

17752 readers
1027 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

I have some background in Python and Bash (this is entirely self-taught and i think the easiest language from all). I know that C# is much different, propably this is why it is hard. I've been learning it for more than 4 months now, and the most impressive thing i can do with some luck is to write a console application that reads 2 values from the terminal, adds them together and prints out the result. Yes, seriously. The main problem is that there are not much usable resources to learn C#. For bash, there is Linux, a shit ton of distros, even BSD, MacOS and Solaris uses it. For python, there are games and qtile window manager. For C, there is dwm. I don't know anything like these for C#, except Codingame, but that just goes straight to the deep waters and i have no idea what to do. Is my whole approach wrong? How am i supposed to learn C#? I'm seriously not the sharpest tool in the shed, but i have a pretty good understanding of hardware, networking, security, privacy. Programming is beyond me however, except for small basic scripts

you are viewing a single comment's thread
view the rest of the comments
[–] DrDeadCrash 8 points 3 days ago (1 children)

Check out this reference (not mine): https://gist.github.com/DanielKoehler/606b022ec522a67a0cf3

The first difference that I would point out is c# use of static typing, where python is dynamic. This author is using the var keyword to avoid specifying a type for variables. The type is, instead infered by the code that follows the equals sign.

The next main difference is the use of whitespace. Python is very whitespace aware, it uses indentation and line breaks to organize code. C# is whitespace agnostic in most cases and separates blocks of code using curly braces {...}, statements must end with a semicolon;

In C# collections are organized by how the data is accessed and whether elements can be added or removed. Arrays are initialized with a set of items and can't be made longer, a List can be added to and can be removed. The key point is that all items in a collection are of the same type.

Complex objects (that have properties and methods) can be structs, classes, or records but they all basically do the same thing and interact in the samish way. You have to use the new keyword to make a new instance.

Classes and records can inherit from another where as structs cannot. Properties must have a type, methods must return a type or void. Method parameters must be typed, when calling a method the provided parameters must be of the proper type.

An interface describes requirements an implementing class, record or stuct must meet (i.e. properties and methods). You can't make a new interface, it's more of a qualification.

I hope this helps some

[–] [email protected] 3 points 3 days ago* (last edited 3 days ago) (3 children)

Is it bad if i barely understand anything in this comment?

[–] [email protected] 5 points 2 days ago* (last edited 2 days ago)

Quite bad actually, since most of this stuff is not specific to c#, and are just basic programming concepts. This leads me to believe that your python experience is "coby and paste stuff in until it looks like it works", and you never took the time to understand what the code does.

[–] DaleGribble88 8 points 3 days ago (1 children)

Most probably, yes. A lot of these are fundamental concepts of most modern object-oriented languages that I am familiar with. It may be worth refreshing your basic programming skills/concepts with a book you like. There are plenty available online for free in C#, Java, C++, Go, etc.

[–] [email protected] 1 points 3 days ago (2 children)

Refreshing what? I don't have anything to refresh here. I only have experience with scripting languages, which are not object oriented at all

[–] [email protected] 16 points 3 days ago

Python is an object oriented language.

[–] [email protected] 7 points 2 days ago (1 children)

This is going to sound harsh but... You need to take an intro to programming course.

I didn't know what your doing in Python, but you've not learned to program in Python. Maybe just copy pasting or making small changes to existing stuff? Working in a specific framework? Are you writing code from scratch?

You need to understand datatypes (a concept Python tries to hide from you and imo does a disservice to novices), structures, conditional is, loops, etc. These concepts aren't language specific.

[–] [email protected] 2 points 2 days ago* (last edited 2 days ago)

Yes, i write from scratch in python, but only basic things. The most advanced are reading from a file and defining an own function. I'm in a programming course already

[–] [email protected] 4 points 2 days ago

I wouldn't say it's that bad, it probably means you lack vocabulary rather than anything else.