1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Trying to Switch from C# to Python - Having Issues

Discussion in 'C, C++, C#' started by Cnotey, Oct 24, 2015.

  1. Cnotey

    Cnotey Power Member

    Joined:
    Jun 25, 2010
    Messages:
    713
    Likes Received:
    915
    Location:
    Seattle
    Home Page:
    Hey there,

    Haven't posted in a while but I need some advice from my fellow bot programmers.

    I've been writing in C# for a while for my scraping utilities. I am looking at switching to Python so I can take advantage of the Django and Scrapy framework, as I am not really that impressed with the HTMLagilitypack for C#.

    Is the productivity all that much better in Python? I've always read that C# is a much harder language than Python, but for some reason I am having a lot of trouble with the concept of dynamic typing.

    Anyone have any good resources specifically to help a C# guy like me understand how to switch to Python?

    Thanks in advance!

    Cnotey
     
  2. ItsBlinkHere

    ItsBlinkHere Regular Member

    Joined:
    Apr 27, 2014
    Messages:
    409
    Likes Received:
    150
    Location:
    At Large
    Well, when I started writing python, someone told me to code like I was talking. That's the cool thing about python, its written so it can be read and understood properly later. Forget about those lousy semicolons and just hit return at the end of a line of code. As for training... I don't know of to much, ask I know is that it's much easier then C#
     
  3. mantic0re

    mantic0re Junior Member

    Joined:
    May 29, 2015
    Messages:
    118
    Likes Received:
    9
    The question is rather, what does python(and these frameworks) offer over anything that c# has?
     
  4. Cnotey

    Cnotey Power Member

    Joined:
    Jun 25, 2010
    Messages:
    713
    Likes Received:
    915
    Location:
    Seattle
    Home Page:
    Being open source, Python tends to have better curated libraries that help out quite a bit with development time. In addition the line to line code comparison is about 5:1 in Python's favor. These two factors lead and about 250k other people to believe that Python is a more productive environment than C#.
     
  5. mantic0re

    mantic0re Junior Member

    Joined:
    May 29, 2015
    Messages:
    118
    Likes Received:
    9
    Hi, it really depends on what you are trying to accomplish. There are many things python can't do that c# can. That does not apply the other way around though. c# can do anything python can and it's libraries are very extensive.

    Additionally, if your focus are command line script(on linux?) then you could also definitely accomplish all that with PHP as well.
     
  6. fidodido

    fidodido Junior Member

    Joined:
    Aug 12, 2015
    Messages:
    113
    Likes Received:
    27
    What is that you are finding difficult in c# writing screen scrapers ?
     
  7. Intruder

    Intruder Regular Member

    Joined:
    Jun 3, 2012
    Messages:
    340
    Likes Received:
    206
  8. rootjazz

    rootjazz Jr. VIP Jr. VIP

    Joined:
    Dec 21, 2012
    Messages:
    684
    Likes Received:
    326
    Occupation:
    Developer
    Location:
    UK
    Home Page:

    Isn't that python2?

    Should really learn python3 IMO


    But as stated, anything you can do in python you can do in c# and anything you can do in c# you can do in python.

    Python does have extensive projects you can use, which c# doesn't have. But for botting, they are not really needed in my opinion. But learning a new language is always a good thing.



    To whoever said python is so readable I disagree, a semi colon doesn't effect things at all.


    Which is more readable here

    Code:
    //c#
    var csv = listAccountIds.Split(',');
    
    
    #python
    csv = ",".join([str(acc_id) for acc_id in list_account_ids ])
    

    It is more a case of the programmer writing readble code, than a languae in my opinion




    Moving to a dynamic language, the thing you will probably miss most is the compiler catching all those stupid typo bugs, or refactors you make, forgetting to change all function calls if you change the parameters. Really it is a case of changing your workflow, to be more careful, writing more tests that replace the compiler that you would need to write in a compiled language as the compiler is there for you

    The way code is written is also different, less patterns , oo strict structure in python

    At the end of the day, you just need to keep at it, complete more projects in python, you will soon figure out what you could have done better, read through some src of the projects you are utilizing to understand best practises etc. The more you do the better you get
     
  9. kahuna74

    kahuna74 Regular Member

    Joined:
    Aug 19, 2014
    Messages:
    270
    Likes Received:
    102
    Gender:
    Male
    Occupation:
    Software Developer
    Location:
    Grand Rapids, MI
    What's difficult about dynamic typing? The lack of compile time type checks? Write unit tests if that's what you're worried about. Otherwise, can you give some specifics?
     
  10. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,073
    Likes Received:
    10,841
    Occupation:
    WHEREZ MA
    Location:
    BITCOINS AT?
    Home Page:
    If you're planning on selling your bots you should stick with C++ or some other compiled language. Even C# can be easily decompiled.
     
  11. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    971
    Likes Received:
    680
    Occupation:
    Web/Bot Developer
  12. selfself

    selfself Newbie

    Joined:
    Apr 3, 2016
    Messages:
    1
    Likes Received:
    0
    Practice is the best. You'll be glad you did just for Scrapy once you'll write efficient spiders in less then 100-200 lines of code.
     
  13. FJX

    FJX Regular Member

    Joined:
    Oct 13, 2011
    Messages:
    358
    Likes Received:
    188
    Location:
    0x90
    lol. I want what you are smoking bro.

    And C++ can't be modified or reverse-engineered? .NET just made it easier but it's still the same for other languages. It can still be analyzed and then patched according to the cracker's needs - even if you virtualize everything with lots of time in hand it's still inevitable for your software to be cracked. In the end, everything comes to machine language.
     
  14. Dev Warrior

    Dev Warrior Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 13, 2015
    Messages:
    253
    Likes Received:
    30
    Home Page:
    Nice book.. Thanks..

    Any application can be decompiled!

    If you still want to try C# before you move your code to python, try using AngleSharp or CSQuery in your existing C# code.

    nuget.org/packages/AngleSharp/
     
  15. ToxicBlack

    ToxicBlack Regular Member

    Joined:
    Mar 25, 2016
    Messages:
    223
    Likes Received:
    57
    Occupation:
    Programming custom bots and tools.
    Location:
    botland
    Well depends what you are going to code. If you want to distribude your programs best is C++.

    But to not being offtopic, python is as powerfull as C# and both are pretty fast to learn. Scrapy is using very good libs and it fast anyway, even you can deploy your code to their Cloud for free.

    Btw best HTML parsing library is Beautifulsoup if you decide to go your own way as I did. It was for me simpler to create my own crawler implementation rather than using scrapy...