5
AleCx04
3y

During my readings of Nim I found a technique known as stropping.

This gives devs the ability to use keywords as identifiers.

Example:

var `var` = "fucking why?"
echo(`var`)

Can anyone tell me WHY would someone subject themselves to such confusion notion? Mind you Nim has large features for macro programming and the creation of dsls, i have not gotten far enough to assess this, but what other use could you highly knowledgeable lads and lasses think of?

Comments
  • 2
    Don't know Nim.

    But some people love variables of variables... Maybe even further nested.

    It's when stuff like stropping and/or escaping becomes important.

    Whenever I see people utilizing stuff like that, PTSD kicks in and I prepare myself for a painful event.

    Variables of variables with object's / lists / .... as an example
  • 5
    That's a bad example.

    A common usage of stropping is used in .Net when you want to use the name of a keyword to maintain conventionality without unnecessarily bloating argument names.

    Here's a bad example of a Character class to demonstrate :p
  • 3
    sure it can make sense, there's to many generic keywords at times for some languages where you want to use them.

    In this example - what in the flying fuck are they thinking!
  • 4
    @C0D4
    "Don't understand why do. Just need finish example or more alpo for dinner."
  • 2
    @SortOfTested nothing wrong with a ramen diet, until there is!
  • 1
    @SortOfTested this is horrible. I love it
  • 0
    @C0D4 this body ignores carbs
  • 1
    How have you found Nim otherwise so far? I’ve shortlisted it for digging into when I find time for it, and I’d like to hear your impressions of it so far.
  • 1
    @SortOfTested i... don't understand what that is or what it does?
  • 0
    C# does that with a @ I think

    I would never use it myself, I think the main purpose is for code generator to be able to work with whatever names they come up with
  • 1
    @SortOfTested oh, wait, i read the wiki entry and now i get it.

    that's pretty stupid. millions of words to choose from but no, i have to have one of those about 20 which i can't have.
  • 1
    @100110111 I initially read about it when getting acquainted with Clojure's macro system. Someone on Hacker News (I think) had mentioned that the capability that Nim has for macro development and thus the inception of dsls was amazing, the fact that it created one executable model much like Go does for different systems was something that attracted me as well. The syntax is fairly descriptive, I generally prefer static typing since it does make my life easier for larger projects, not that I build lots of them, but I still like it. Type inference on Nim is superior to Go. It has amazing support for functional programming (always a big plus for me) as well as good async practices. You can select your compiler and GC model (yes it is a GC language) when generating C code, which is pretty good, but just like anything else never the same as actually writing C code.

    My biggest complain? syntactic whitespace. I really don't like it AND you don't get to use tabs....only spaces.
  • 1
    @AleCx04 ”you don’t get to use tabs” is really the main takeaway here. It would have to be a bloody exquisite lang to make up for that - at least for someone who hates using space much as I do. Is it still worth it?
  • 1
    @100110111 in my honest opinion: yes.

    There are a couple of things to learn from the language, it is very good if you ask me, and if you use an editor in which you have the support for it then the identation takes place for you, if you prefer tabs then you can just adjust the spacing for it and it barely makes it a disturbance.

    I am planning some mad shit for custom C based libraries interfacing with Pharo Smalltalk once I get to better grips with Nim, because I can't for the life of me sit down to learn all the nuances of C in order to make something remotely useful, I can't stand the syntax of Rust (for now) and C++ would be just as much of a big issue, so at least for me Nim happens to be a gift from the coding gods.

    I do recommend it bro :D would love to know what you think about it if you jump into it.
  • 1
    @100110111
    I just set tab width to two spaces and go about my life. ๐Ÿ˜ธ
  • 0
    @SortOfTested good point ๐Ÿ˜…
  • 0
    @AleCx04 so Nim stays up there in my shortlist of interesting languages to burrow into - alongside Rust and D.
  • 0
    @100110111 nim does look very interesting but I really, really dislike indentation based syntax
    Or using keywords instead of symbols like "and" instead of &&

    Just give me C-style syntax please
  • 0
    @LotsOfCaffeine that’s your loss really. I get it tho, if intendation based syntax brings to your mind Python. Guess you’ve never tried F# or any other ML family lang?

    That said, I really hate syntax that uses the ”end” keyword...
  • 1
    @100110111 I've seen F# before, but only a bit

    python gives me some sort of ptsd, as any python code I've ever looked at was messy.

    I always end up questioning, whether the code I look at is still in the same function or whatever

    Curly brackets just make things nice and clear
  • 1
    @LotsOfCaffeine I agree that curly brackets make for clarity.

    But speaking of intendation based syntax, there seems to be two outcomes: Python, that looks messy af, and F#, which is real clean and concise. But it’s not only due to having or not having curly brackets, it’s the rest of the syntax, too. At least in F# correct design choices have been made to make it clean and clear. Python’s just a hot mess...
  • 0
    @100110111 yeah maybe it's just python that left me disliking that type of syntax

    Though this makes the ‘tabs vs spaces’ debate 10 times worse.

    I gotta try nim at some point though, I've read that it can easily interact with C++ and that garbage collection is completely optional.
Add Comment