Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
Cipherd ( cipherd@lemmy.ml )  to Programmer Humor@programming.dev · 10 months ago

functions

lemmy.ml

message-square
21
link
fedilink
  • cross-posted to:
  • programmerhumor@lemmy.ml
386

functions

lemmy.ml

Cipherd ( cipherd@lemmy.ml )  to Programmer Humor@programming.dev · 10 months ago
message-square
21
link
fedilink
  • cross-posted to:
  • programmerhumor@lemmy.ml

cross-posted from: https://lemmy.ml/post/39334581

alert-triangle
You must log in or # to comment.
  • littleomid ( littleomid@feddit.org ) 
    link
    fedilink
    English
    arrow-up
    39
    ·
    10 months ago

    Meanwhile Haskell:

    =

    • andrybak ( andrybak@startrek.website ) 
      link
      fedilink
      arrow-up
      3
      ·
      10 months ago

      too bad they chose :: for type declaration instead of :

  • Riskable ( riskable@programming.dev ) 
    link
    fedilink
    English
    arrow-up
    36
    ·
    10 months ago

    Related: Every Fn key on a keyboard is a missed opportunity! That’s not fun at all!

    Riskeyboard 70 analog hall effect keyboard left side showing the Fun key

  • NotSteve_ ( NotSteve_@piefed.ca ) 
    link
    fedilink
    English
    arrow-up
    29
    ·
    edit-2
    10 months ago

    def (): is pretty nice

    Edit: also as someone doing a bunch of CI work right now, Bash can GTFO (unless the alternative is whatever Windows is doing)

    • flying_sheep ( flying_sheep@lemmy.ml ) 
      link
      fedilink
      arrow-up
      11
      ·
      10 months ago

      Nushell is pretty nice. It’s the good parts of “what Microsoft is doing”, i.e. real structured data in a shell-like language and real error handling.

  • Laser ( Laser@feddit.org ) 
    link
    fedilink
    arrow-up
    15
    ·
    10 months ago

    Not sure I’d call what bash has functions. They’re closer to subroutines in Basic than functions in other languages, as in you can’t return a value from them (they can only return their exit code, and you can capture their stdout and stderr). But even then, they are full subshells. It’s one of the reasons I don’t really like Bash, you’re forced into globally or at least broadly-scoped variables. Oh, and I have no clue right now how to find where in your pipe you got a non-null exit code.

    It’s not a big problem for simple scripting, but it makes things cumbersome once you try to do more.

    • yetAnotherUser ( yetAnotherUser@discuss.tchncs.de ) 
      link
      fedilink
      arrow-up
      5
      ·
      10 months ago

      I really like bash when dealing with even somewhat advanced scripting. Like the 300 LOC scraper I have written over the past two days which horribly parses HTML files using grep | sed.

      It’s genuinely so much more fun to do this with Bash than, say, Python. I have once written a scraper using Beautifulsoup and I have no desire to do so ever again.

      Honestly, only Haskell manages to beat Bash in how satisfying it feels when you manage to get something working well.

      • Laser ( Laser@feddit.org ) 
        link
        fedilink
        arrow-up
        2
        ·
        10 months ago

        Bash has its upsides too, like the fact that it has arrays / lists and dictionaries / hashmaps. In my opinion, it gets iffy though when you need to do stuff with IFS; at that point one might be better off just using specialized tools.

        Not saying working bash isn’t good enough, but it can break in very surprising ways is my experience.

  • unalivejoy ( joyjoy@lemmy.zip ) 
    link
    fedilink
    arrow-up
    12
    ·
    10 months ago

    Kotlin also lets you do fun x() = y()

  • staircase ( staircase@programming.dev ) 
    link
    fedilink
    arrow-up
    11
    ·
    10 months ago

    In the language Gulf of Mexico,

    you can use any letters from the word “function” (as long as they’re in order)

    union foo () => ()
    
    • luciferofastora ( luciferofastora@feddit.org ) 
      link
      fedilink
      arrow-up
      8
      ·
      edit-2
      10 months ago

      Naming

      Both variables and constants can be named with any Unicode character or string.

      const const letter = 'A'!
      var const 👍 = True!
      var var 1️⃣ = 1!
      

      This includes numbers, and other language constructs.

      const const 5 = 4!
      print(2 + 2 === 5)! //true
      

      This is a recipe for disaster I kinda wanna try

    • MonkeMischief ( MonkeMischief@lemmy.today ) 
      link
      fedilink
      arrow-up
      3
      ·
      10 months ago

      Just looking through this as a fledgling barely-coder…

      …It inspires fear. Terror, even. LMAO

    • Revan343 ( Revan343@lemmy.ca ) 
      link
      fedilink
      arrow-up
      3
      ·
      10 months ago

      If you’re unsure, that’s ok. You can put a question mark at the end of a line instead. It prints debug info about that line to the console for you.

      print("Hello world")?

      Fucking sold, I was gonna learn rust but you’ve changed my mind

  • Speiser0 ( Speiser0@feddit.org ) 
    link
    fedilink
    arrow-up
    10
    ·
    10 months ago

    C++ has []{}.

    (You can also add more brackets if you wish to do nothing longer: []<>[[]]()[[]]{}())

    • anton ( anton@lemmy.blahaj.zone ) 
      link
      fedilink
      arrow-up
      4
      ·
      10 months ago

      Then rust has ||{}

      Sadly we can’t add more complexity without adding an argument: |_:&'_[()]|{}

  • save_the_humans ( save_the_humans@leminal.space ) 
    link
    fedilink
    English
    arrow-up
    9
    ·
    10 months ago

    Anyone tried lisp? Looks something like this. ((()))()())))

  • krooklochurm ( krooklochurm@lemmy.ca ) 
    link
    fedilink
    arrow-up
    8
    ·
    10 months ago

    Bash was derived by a team of criminally insane programmers in the bowels of a South American asylum so deep in the jungle no country can rightfully claim it as its own. It is the product of the demented keystrokes of the damned, possessing a singular logic so alien that its developers can hardly be said to be human at all.

    And I wouldn’t have it any other way.

  • Chaser ( Chaser@lemmy.zip ) 
    link
    fedilink
    arrow-up
    4
    ·
    10 months ago

    JS:

    () => {}
    
  • solrize ( solrize@lemmy.ml ) 
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    10 months ago

    C++ [](){} looks nice.

  • katy ✨ ( cupcakezealot@piefed.blahaj.zone ) 
    link
    fedilink
    English
    arrow-up
    2
    ·
    10 months ago

    basic: def fn

  • ulterno ( ulterno@programming.dev ) 
    link
    fedilink
    English
    arrow-up
    1
    ·
    10 months ago

    While C feels fine without having a keyword for function, I feel like bash would have benefitted from it.

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
    • If the mod doesn’t find it funny, you’re banned. Ha-ha!.. For real: do not use the community for “statements”. There are other places for such content. Keep it chill and funny.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 411 users / day
  • 1.38K users / week
  • 3.2K users / month
  • 7.37K users / 6 months
  • 463 local subscribers
  • 33.4K subscribers
  • 1.52K Posts
  • 25K Comments
  • Modlog
  • mods:
  • Feyter ( Feyter@programming.dev ) 
  • adr1an ( anzo@programming.dev ) 
  • BurningTurtle ( BurningTurtle@programming.dev ) 
  • Pierre-Yves Lapersonne ( pylapp@programming.dev ) 
  • BE: 0.19.15
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code