5
sariel
3y

As a Ruby dev I know I've been spoiled. It's so fucking easy to natively manipulate data in a Ruby app.

But seriously...come the fuck on Python...

You mean to tell me that I have to script out the entire logic to dedup an array?! Something that's an inherent part of EVERY project?

Sorry for the rant, but I just cannot fathom why ANYONE would use Python to write a full application. It's great at scripting, but a shit-stain-to-maintain for true app development.

I want to drop-kick the asshole who decided to write this fucker of an app in Python.

Also, fuck Python for taking ~20 years to add a fucking switch statement.

Comments
  • 0
    What's your stack?
  • 2
    1. Use a Set.
    2. A switch is just an if else behind the scenes. the elif actually makes more sense.
  • 0
    @jasongodev the part I'm working on is building a configurator class that reads in from a flat file.

    The file is managed by people and needs to have unique values attributed to it.

    Packages include pyyaml, pymysql, and some propriety packages that were built in-house.

    I got handed this project a month ago and was told to implement for production.

    It was barely a POC, and all the higher ups expect it to be done by August. No time to spike a new story and find a better solution.

    I would have probably written something in c just because it could have ran directly on the database then.

    Without giving too much detail away, think of this app as an overly ambitious ETL script.
  • 2
    @magicMirror Not really...

    A switch case is far more readable, especially for multiple sets of options.
  • 0
    @magicMirror although I agree from a technical side, from a standards and maintenance perspective it's bollocks.

    Every mainstream language has a switch function.

    I would also argue that a switch can be improved upon that wouldn't require an elseif.
  • 0
    @IntrusionCM Yes And No. elif blocks allow more then one condition, while switchs are limited (in most langs).
    @sariel You can also use a key/function map. But that is not an improvment - it is less efficient, and makes the code flow less readable.
  • 0
    Dictionaries, besides having ability to store function capable objects allow also setting default value like any switch has.
  • 0
    huh. they added arrays!
    in 3.9.6 version.
    https://docs.python.org/3/library/...

    from array import array
    arr = array('l', [1, 2, 3, 4, 5])
    for item in arr:
    ---print(item)
  • 1
    Well, actually they just added the switch in python 3.10... which happened just yesterday.

    ```
    def f(x):
    --match x:
    ----case 'a':
    ------return 1
    ----case 'b':
    ------return 2
    ```

    interesting about them
    https://docs.python.org/3.10/...
    they support even more complex matching patterns
    an array of conditions, or even predicate could be used.
  • 0
    @molaram some doofus decided they could only create the proof using python.

    Now I'm expected to carry on with that bullshit.

    This thing didn't even have tests in place before I got my hands on it.

    It took them over a month to come up with the concept and it resulted in about 20 different scripts that scatter any logic to the stratosphere.

    In the amount of time it took to get here, I could have written the thing in native c as a plugin in the database.
  • 0
    @darkwind even the example code is difficult to share in other places because of that whitespace rule. We have to resort to dashes or other characters just to say it's indented
  • 0
    @jasongodev that is the problem of current messager in lacking support for proper indentation.

    A lot of languages require showing it at least for a better readability.

    A lot of messanging platforms support code blocks.
    (Discord, Telegram)
    ```
    # your code
    ```
    With sometimes even colorizations of the code.

    Tbh, it is weird for dev rant missing it. Isn't it a messenger for devs... why it is missing this important syntax then.
  • 0
    Tbh, I will surely have the opposite problem.

    The python spoiled me with things, which I will not be able to find in other languages, or with things that are super easy in python, but I am sure it would not be that easy in other languages.

    Python is awesome for fast development and results with great readability.

    It has abilities that allow easily writing code with a minimum of ripple effects.

    Code testability, documentation ... everything is easy to reach in python.

    That people write bad code in python just shows their bad code skills. It is not a problem in language. It just shows it has a low entrance to start using it. Proper advanced usage just requires more effort to learn it.
  • 0
    @darkwind

    Because devrant doesn't want you to share code.

    Do you want it to be another SO?
  • 1
    I have a preference towards Ruby as well, so you are most definitely not alone on this.

    Honestly, I blame academia and how easy it is to develop for Python in all major operating systems and/or having it already inside most Linux environments when that won't necessarily be the case for Ruby. "Just install it and run idle!" and boom, we have the same case of newbie developers doing horrible things in PHP, but now with (subjective) nicer syntax in Python.

    Personally, Ruby all the way, forever and always.
  • 1
    @magicMirror just came here to say "use a set."

    Thanks for reading my mind.
  • 1
    @Wisecrack Great minds....
  • 1
    @magicMirror ..can read the thoughts of lesser minds apparently.
  • 1
    @Wisecrack from the future!
Add Comment