Slashdot Mirror


Nim Programming Language Gaining Traction

An anonymous reader writes: Nim is a young, statically typed programming language that has been getting more attention recently. See these articles for an introduction: What is special about Nim?, What makes Nim practical? and How I Start: Nim. The language offers a syntax inspired by Python and Pascal, great performance and C interfacing, and powerful metaprogramming capabilities. The author of "Unix in Rust" just abandoned Rust in favor of Nim and some early-adopter companies are starting to use it as well.

69 of 520 comments (clear)

  1. The Secret of Nim by stoolpigeon · · Score: 5, Funny

    When that comes out - I'm buying it regardless of whether or not I actually need to learn or use the language.

    --
    It's hard to believe that's how Micronians are made. Why don't we see it right now by having you both kiss one another?
    1. Re:The Secret of Nim by buchner.johannes · · Score: 4, Insightful

      If I were to create a new language, I would not focus on creating the most beautiful syntax or the best built-in functionality. Instead, I would make damn sure it plays well with other languages and that it is trivial to use software packages already written. For example, R, Python, Java -- no one wants to recode the packages (machine learning algorithms, MPI, web automatisation) in yet another language.

      --
      NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
    2. Re:The Secret of Nim by diamondmagic · · Score: 4, Informative

      The example you gave is just an example of API designers being stupid: You could call that -1 indexed, because there is a zeroth dimension (mathematically, it has the value of 1 (unitless)).

      1-indexing has the problem of needing to subtract 1 from everything before it's useful for scaling, and much else. The 20th century is 1900...1999 inclusive because of 1-indexing. The year -0001 is also known as 2BC because of 1-indexing. And so on.

      Anywhere your index is an offset (which is most indexes), it needs to be 0-indexed.

    3. Re:The Secret of Nim by IamTheRealMike · · Score: 4, Interesting

      If I were to create a new language, I would not focus on creating the most beautiful syntax or the best built-in functionality. Instead, I would make damn sure it plays well with other languages and that it is trivial to use software packages already written.

      Nim looks syntactically a little bit like Kotlin, which compiles to either JVM bytecode or JavaScript. If you compile to the JVM then you can not only use libraries written in Java, but also JavaScript, Python 2.x (via Jython), Ruby, Scala, C (via JNA), there's even a Haskell for the JVM called Frege.

      The really neat trick, though, is that despite looking not much like Java at all, it compiles down to code that is binary compatible with Java and there is a Java-to-Kotlin rewriting tool, meaning you can convert existing Java codebases one file at a time whilst still having a fully compilable project. Thus you can not only leverage existing codebases written in many languages, but also slowly convert legacy codebases too.

      Kotlin has some syntactic features that look similar to nim, like if being an expression not a statement, ranges, type inference, compile time inlining control, operator overloading, generics etc. Kotlin also has a a variety of features that focus on creating DSLs, but doesn't do it using a full blown macro system.

      Nim has some things Kotlin doesn't and vice versa. I can write a more complete comparison (based on reading the docs) if anyone is interested. But the reason I mention it, is Kotlin's focus on interop with existing code.

    4. Re:The Secret of Nim by dargaud · · Score: 2
      Don't you mean:

      The 20th century is 1901...2000 inclusive because of 1-indexing.

      --
      Non-Linux Penguins ?
    5. Re:The Secret of Nim by photonic · · Score: 2

      I completely disagree. I have worked extensively both with Matlab and Numpy, and I much prefer Python's 0-based indexing and half-open intervals over Matlab's 1-based indexing and closed intervals. Edsger Dijkstra, the famous computer scientist, explained why this is a good idea. E.g. splitting the first n items off an array in Matlab is head = x(1:n); tail = x(n+1:end) , while in Python it is head = x[:n]; tail = x[n:] . Even worse is when doing some computation over blocks within an array, in Matlab you do for i=1:n; y(i) = fun(x((i-1)*m+1:i*m)); end , while in Python it is for i in range(n): y[i] = fun(x[i*m:i*m+m]) . In Matlab, you always have to think careful about the extra +-1, which causes many off-by-one errors, while in Python you just write it down intuitively.

      --
      karma police: arrest this man, he talks in maths; he buzzes like a fridge, he's like a detuned radio. [radiohead]
    6. Re:The Secret of Nim by IamTheRealMike · · Score: 3, Interesting

      Yes, that has been a persistent problem for speeding up dynamic languages for years. You can make a better runtime but then can't provide the interpreter API used by the C extensions.

      The Oracle Research JVM team has a totally crazy solution for this. They have implemented an extended version of HotSpot that is capable of actually JIT compiling interpreted source code of Ruby C extensions such that the end result is much faster than the Ruby interpreter using GCC compiled versions of those same extensions.

      The whole blog post is worth a read, but to summarise, what they've built is capable of actually inlining C into Ruby and vice-versa at the compilation level. So for example if a C extension function returns an array of three elements using the C extension API and then Ruby code unpacks it, it can actually compile down to returning those values in registers because the code is inlined together and then compiled in the normal way. Additionally, interpreting the C source code means that the JVM garbage collectors can still compact the heap and do other things that traditionally you cannot do with C.

      Graal/Truffle are unfortunately still research projects. This technology doesn't ship in the regular JVM yet and won't do so for some time. But it's an interesting glimpse at the future of high performance dynamic language runtimes.

    7. Re:The Secret of Nim by diamondmagic · · Score: 2

      SEE WHAT I MEAN?

  2. Scripting langs are like social media by Anonymous Coward · · Score: 4, Interesting

    A new fad sweeps through the kiddies every 3-5 years. I guess everyone wants to be one the crest of the new wave so they all rush out to learn the newest one, hoping maybe they'll get to write the book or teach a bootcamp, after it gets advertised on Slashdot of course.

    1. Re:Scripting langs are like social media by gbjbaanb · · Score: 3, Interesting

      I find the ones who rush to use the new stuff are the ones who never quite managed to make anything with the old ones. The grass is always greener but also they can blame their lack of progress on the tools.. obviously *this* time it'll be different, just once they've had the right training and given enough time.....

      Its when I was offered a job to make a system cope with the customer's increased load that I realised how damaging this is - it was written in Erlang, Ruby and Scala.

    2. Re:Scripting langs are like social media by smittyoneeach · · Score: 2

      If you were one to write books and training, you might welcome fresh technologies.

      --
      Get thee glass eyes, and, like a scurvy politician, seem to see things thou dost not.--King Lear
    3. Re:Scripting langs are like social media by BarbaraHudson · · Score: 4, Insightful

      If you were one to write books and training, you might welcome fresh technologies.

      +1 for cynicism, but I'll raise you 2:
      The other reasons why people go for this are two-fold.

      • 1. The whole industry is ADHD;
      • 2. It makes it easy to "abandon ship" for another job because your current project is over-budget and over-time and that's not going to change, and you have experience with the latest hotness;

      Bonus excuse: Since it's all new, nobody can tell at a glance that you're doing it wrong. :-)

      --
      "Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
    4. Re:Scripting langs are like social media by c0d3g33k · · Score: 2

      Nim isn't a scripting language. It compiles to native binaries by default (with an intermediate conversion to C code) and doesn't depend on an interpreter or virtual machine at runtime.

  3. Nim's community is very toxic. by Anonymous Coward · · Score: 5, Informative

    I lurk on the Nim IRC channel sometimes. The toxicity there is unbelievable.

    Look at these recent IRC logs, for example.

    We see insults like:

    17:46:17 ldlework EXetoC: the problem is that you're just spouting weightless and thoughtless generalizations about how you can whimsically avoid BlaXpirit_'s problems with magical design

    19:08:33 ldlework Your justification is piss.

    19:10:07 Zuchto BlaXpirit_: because ldlework is being an ass to the person that, as far as I know, is doing just that

    20:14:47 Zuchto ldlework: still being an ass, I would say that that makes any high ground you try and claim about being a "good internet citizen" pretty much null and void.

    And there's lots of unnecessary sarcasm:

    19:54:14 ldlework "Nim supports generics and inheritance but if you want to do OOP programming, Fuck You, Nim is really a functional language because we arbitrarilly limit the language to mirror limitations in F# (which show up for compltely unrelated reasons than in Nim)

    Then there's lunacy and quasi-psychotic ranting and rambling:

    19:58:39 Triplefox I like the modules as they are
    19:58:51 ldlework Triplefox: we're not trying to change the module system per-say
    19:59:06 ldlework And, great as long as they're sufficient for you, we should all shut up
    19:59:19 BlaXpirit_ damn you're good at arguments
    19:59:19 ldlework Let us remember to run by all our shortcomings with Nim through Triplefox first
    19:59:47 ldlework BlaXpirit_: because the actual answer here is "Oh right, just wait until forward type declarations."
    19:59:58 Triplefox Uh, so you want to bully?
    20:00:17 ldlework If Araq had just said that instead of taking some high-brow self-contradicting position for which he can provide no direct argumentation against, then we both would have been satisfied long ago.
    20:00:26 ldlework Because that's all that needed to be said about this problem.
    20:02:57 ldlework Triplefox: Uh, so you just want to sqaush other people's conversations that have no effect or bearing on you by making a wierd obersvation that you don't suffer the same difficulty as others?
    20:02:59 ldlework What?
    20:03:56 Triplefox Your conversation consists of forcing someone to say they're wrong
    20:04:06 ldlework Nope
    20:04:08 ldlework There is a problem X
    20:04:14 ldlework there is a sufficient solution Y
    20:04:23 ldlework But Y is purportedly bad because X shouldn't be a problem at all
    20:04:31 ldlework so instead of providing a solution to X
    20:04:32 ldlework we say
    20:04:34 ldlework You're wrong.
    20:04:37 ldlework You're thinking wrong.
    20:04:40 ldlework You're a bad programmer.
    20:04:42 ldlework Read this article.
    20:04:56 ldlework If there was a solution as nice as Y, that we were missing, everyone here would have provided it.
    20:05:03 ldlework Instead of the hand waving and high-browing.
    20:05:37 Triplefox Except that you're getting a change already
    20:05:45 ldlework Triplefox: right, that was my point, that's Y
    20:05:55 ldlework But we just had to pointout how people who need Y are terrible programmers
    20:06:06 ldlework Because there is some hidden unspoken thing you could do instead of X that would alleviate it
    20:06:16 ldlework Just it seems no one can actually produce what that altnerative is
    20:06:38 ldlework So the discrepency between "Shutup and just write your software correctly" and the blinding abscence of a simple solution being reported into the channel, speaks volumes.
    20:07:25 BlaXpirit_ this happens every time on this channel
    20:07:30 ldlework Maybe next time we can just skip the bullshit
    20:07:33 ldlework and talk about the engineering
    20:07:37 Triplefox Well, did you actually present the problem that requires your solution in a way

    1. Re:Nim's community is very toxic. by gnupun · · Score: 2

      Who cares? Do you want to use the language or chat with the community? Such people exist in most communities. AFAIK only one person, the creator of Nim (formerly Nimrod), Araq, is in charge of making all the decisions. He has also implemented most of the language and libraries.

      Nim = Python code + Turbo Pascal type declarations.

    2. Re:Nim's community is very toxic. by OzPeter · · Score: 2

      I lurk on the Nim IRC channel sometimes. The toxicity there is unbelievable.

      Given that the language's name was initially Nimrod, I find those IRC logs quite apropos.

      --
      I am Slashdot. Are you Slashdot as well?
    3. Re:Nim's community is very toxic. by OzPeter · · Score: 4, Insightful

      Who cares? Do you want to use the language or chat with the community? Such people exist in most communities.

      The problem with the toxicity is this:

      19:04:02 Araq ldlework: I intend to "fix" it because I'm tired of arguing ... not because it's a particularly good idea

      If solutions are being based on emotion and not what is correct, or best, then the language development is well and truly fucked.

      --
      I am Slashdot. Are you Slashdot as well?
    4. Re:Nim's community is very toxic. by drinkypoo · · Score: 2, Insightful

      AFAIK only one person, the creator of Nim (formerly Nimrod), Araq, is in charge of making all the decisions. He has also implemented most of the language and libraries.

      That's an excellent reason not to even consider using it at this point. Unless your idea of a good time is maintaining a dead programming language, you should wait until it already has a community and a fork before you even touch it.

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
  4. Re:Such potential by gbjbaanb · · Score: 4, Insightful

    Or because some people can't cope with another variation on C++.

    They're just tools guys, all these languages coming out, its just like making slightly different style hammers, only hammers don't need any training or lengthy experience to develop decent skills to use.

  5. Re:Such potential by Anonymous Coward · · Score: 2, Funny

    Or because they don't want to cope with C++ even though they can. Because C++ is like the BDSM of programming languages.

  6. It's kinda strange by invictusvoyd · · Score: 3, Informative

    There's no Wikipedia page on this language. Just an external link in the disamb page.

  7. Re:Such potential by One+With+Whisp · · Score: 4, Insightful

    Why did you conveniently list only languages that use braces to delimit code blocks? The common "FIOC" complaints have never been about "muh braces", they're about making code blocks implied by indents rather than explicit. Braces are just one form of explicit block delimiters, but there are others. Ruby, for example, starts blocks implicitly with if, until, while, etc and ends them with "end". Despite not having braces, it's fine, because the blocks are explicit. The start or end of a block does not accidentally occur, where as this can happen all the time in python.

    By the way, what is python's way of handling grouped statements like these:

    for (int y = 0;y < height;++y)
    for (int x = 0;x < width;++x)
    {
            code here
    }

    Technically the inner for statement is within the outer for statement, but an annoying additional level of indentation can be avoided because the language doesn't require it. Besides, it looks nicer to the programmer. Even if you contest the need for this as two loops instead of one, just look at C#'s nested using statements, which are often on the same indent for simplicity.

  8. Re:20 years experience! by siddesu · · Score: 2

    You'll be having interviews with companies you most likely won't want to work for.

  9. Caveat Emptor by OzPeter · · Score: 4, Informative

    I was looking at the last link in TFS and in the comments to that link there was this little gem that should force you to take a large grain of salt before committing to a major Nim effort

    Nim High Priority Issues

    Now, I am not familiar with how other, similar languages were at the same stage of development, but given things like this I would be putting Nim in the "Not ready for prime time YET" basket (which is also how I feel about Swift at the moment - there seems to be too many things in a state of flux right now)

    --
    I am Slashdot. Are you Slashdot as well?
  10. So? by QuoteMstr · · Score: 5, Interesting

    Nim is just yet another statically-typed GC language with an unsafe escape hatch. I can get the same thing (and much better syntax) with Java and JNI or C# and P/Invoke. Yawn.

    Rust, on the other hand, is something genuinely new: it provides completely memory safety without a requiring a garbage collector at all. It's sad to seeing people switch from Rust to Nim: they're often too inexperienced to know what they're giving up, and I feel like they're seeking (syntactic) novelty, not a programming environment that's actually useful.

    1. Re:So? by silfen · · Score: 3, Informative

      Rust, on the other hand, is something genuinely new: it provides completely memory safety without a requiring a garbage collector at all.

      The only way to provide memory safety in a language without a garbage collector is to severely limit semantics. So, either the Rust designers are ignorant or the language is severely limited. In the case of Rust, Rust makes trivial memory allocation, the kind other languages simply optimize quietly for you, unnecessary complex, while failing to work in complex scenarios.

      Rust is a badly designed language.

    2. Re:So? by IamTheRealMike · · Score: 4, Informative

      Wow, it sounds like you've certainly done your research, and are very familiar with what Rust is doing and how. I especially like your examples, and convincing arguments that Rust is unnecessarily complex. I mean, who even uses RAII anymore, or wants to have their code statically-verified at compile-time except by marking the unsafe bits as unsafe? Thanks, now I'm completely sold that you know what you're talking about, and that Rust is a badly designed language!

      I think he spelled out why he thinks Rust is badly designed. I haven't reached a conclusion on Rust yet ,but I certainly wouldn't be so bold as to say it's well designed, at least not yet. At best you can say it's an open experiment.

      First off, I'm not sure why you think RAII can't be done in a garbage collected language. For historical reasons C++ overloads the allocation of memory with the management of scoped resources hence the "resource acquisition is initialisation" name, but there's no reason that these tasks have to be joined together. Virtually all languages I know of have ways to do scoped resource management. Java has try-with-resources, C# has the using keyword, etc. The semantics are identical to RAII.

      Secondly, I'm not sure what you mean with the statement about unsafe. Yes Rust requires you to mark unsafe regions of code with the unsafe keyword .... exactly like C#. Java has the sun.misc.Unsafe class that lets you do manual memory management and arbitrary unchecked memory reads/writes, albeit without any native language syntax. This doesn't seem like anything fundamental to Rust.

      Now let's revisit silfen's criticism:

      Rust makes trivial memory allocation, the kind other languages simply optimize quietly for you, unnecessary complex, while failing to work in complex scenarios.

      Rust has a very complex set of rules that you must satisfy to make a program compile. "Fighting the borrow checker" is actually a thing in Rust. In some cases, the obvious way of writing a function that would work in any other language violates the language rules and requires workarounds. So let's not argue about this point specifically - Rust is a complex language and the lifetime management intrudes into even the most basic of programs.

      What about failing to work in complex scenarios? This one is arguable. Rust can express the semantics of any program, I do not believe there is any case where you cannot write a program in Rust that could be written in another language. So "failing to work" is perhaps a bit extreme. However it is undeniably true that for quite common design patterns the Rust lifetime/borrow checking infrastructure cannot apply and Rust programmers must either spend time thinking carefully about ownership design or fall back on the equivalent of reference counting smart pointers. My experience of reading online discussions is that Rust programmers tend to see this as a virtue and everyone else isn't quite so sure.

      The argument for Rust would be far stronger if it had been designed, say, 15 years ago, when garbage collectors were still very primitive. The problem Rust faces is that the key selling point of its design, the one that is used to justify all this unusual complexity, is "you can avoid garbage collection". But if you're working on a platform with modern garbage collector designs like the JVM or (to a slightly lesser extent) the .NET CLR, many of the old disadvantages of GC have been optimised away with time. On a properly tuned GC pause times are now very short even with large heaps, and some GC's like Azul or the new Red Hat developed Shenandoah GC don't actually have any pause times at all .... even with 200-300 gigabyte heaps. Google's ART runtime has shown that you can implement a concurrent compacting garbage collector on phones and get responsiveness that's basically as good as the iPhone. At least I don't perceive any obvious responsiveness difference o

    3. Re:So? by Lunix+Nutcase · · Score: 2

      But in these C++ systems, ownership design is one of the most vexing issues and must be very carefully considered at all points, without any compiler support. The whole concept of threads and data ownership has exactly zero level built in conceptual support, and that sucks.

      I suggest you look into C++11.

  11. Re: Such potential by Anonymous Coward · · Score: 3, Funny

    And suddenly C++ became much more interesting...

  12. Re:Such potential by Bander · · Score: 5, Insightful

    The second for loop should be indented. I have trouble believing that you really think the non-indented version is more readable, or conveys the algorithmic intent well. If you were applying for a job with my team and you made this argument, I would find it very difficult to hire you.

    Alternate interpretation: nicely trolled. I bit.

  13. Re:Such potential by narcc · · Score: 2

    Implicit blocks are bad, for many reasons which I'm sure you've already heard. The problems don't just affect developers, mind you, but the language as well. They're the sole reason why anonymous functions in Python are so horribly crippled, for example.

    The only reason Nim includes this retardation is that it's written by a guy convinced that the ridiculous mistake Guido made was actually a good idea. I get it: you like Python. Here's the thing, you like Python in spite of the ridiculous white space rules, not because of them. You've spent so many years defending that absurd design decision that you've convinced yourself that it's actually good.

    Oh, BTW, with a sensibly designed language, just about every editor out there can format code properly with a single keystroke. The only possible argument in favor of Pythons implicit blocks, forcing idiots to indent their code, is essentially meaningless.

  14. Re:Such potential by Anonymous Coward · · Score: 3, Insightful

    > What, you don't normally indent your C, C++, Java, C#, JavaScript or Perl code?

    OK, I'll bite. Not the OP, but I'm against *forced* indentation too.

    Programs have two target audiences: the compiler (I'll subsume interpreters here) and the human. Of those, the second one is the more important: a program must be written in a way that a human reader has a chance of convincing herself that it is doing the "right thing".

    That's why I enjoy having different channels. The indentation is for a human. Syntactic strukture is for both: compiler and human. And while there should be a tight correspondence between the channels (my editor helps in that), I enjoy tweaking the indentation from time to time to make a point towards the human reader.

    > You just left-justify every line? Is that why you're so against indentation?

    Nice red herring you have there.

  15. Psssssssst! by Applehu+Akbar · · Score: 2, Funny

    The compiler for it is written in Swift. Pass it on!

    1. Re:Psssssssst! by gnupun · · Score: 3, Informative

      What, why is this garbage modded up? The Nim compiler is written in Nim.

      Compiling the Nim compiler is quite straightforward. Because the Nim compiler itself is written in the Nim programming language the C source of an older version of the compiler are needed to bootstrap the latest version. The C sources are available in a separate repo here.

      https://github.com/Araq/Nim

  16. Re:Such potential by cjameshuff · · Score: 5, Insightful

    Thank you. The "why don't you like indentation?" argument is nothing but a ridiculous straw man...the issue is not the use of indentation to reflect structure (which, as you point out, Python actually interferes with in some cases...it gets worse with higher dimensional cases such as voxel maps), it's with the lack of properly delimited blocks. With blocks being implied by indentation, you lose an important visual anchor and cross-check of intent with the compiler, and what do you gain? Potential problems with tab characters, code truncation errors that are undetectable until you attempt to execute the code, huge headaches if you have to use code that has had its indentation broken...there are no positives here, unless the proponents are seriously objecting to the onerous burden of typing a few } characters or "end" keywords.

    Indentation significance is a design flaw, and it's disappointing to see it repeated yet again...

  17. Another language that has a fatal flaw by zJe · · Score: 5, Insightful

    Scoping by invisible characters is bad enough but modifying operator precedence by invisible characters? Why do people think that using spaces, the invisible character, as syntactically meaningful characters is a good idea? For readers of English the space is only important to separate meaningful bits and now we have a language that you will need to count spaces to determine operator precedence?!?! Of course it always cooler to use binary progressions so the operator precedence feature uses sequences of 1, 2 4, and 8 spaces. I can only hope that the language is a joke as per it's original name, nimrod.

    Maybe it would be useful if they dumped the space dependency, but after reading that I quit taking it seriously.

    1. Re:Another language that has a fatal flaw by jdeisenberg · · Score: 4, Informative

      Here's the direct link to the section of the manual, for those who, like me, couldn't believe this: http://nim-lang.org/manual.htm... (see the section titled "Strong spaces") You have to explicitly say you want this experimental parser directive, but it's still a horrible anti-feature, as far as I'm concerned.

    2. Re:Another language that has a fatal flaw by matfud · · Score: 2

      The manual does not even hint at why the experimental strong spaces may be a good idea. As far as I can tell they are a way to confuse people.

      People do not learn arithmetic that way for a very good reason. You can't write it down reliably. I would claim that anything you cannot write down or write as plain HTML (as we are in the interweb era) is sort of broken.

    3. Re:Another language that has a fatal flaw by JanneM · · Score: 2

      " 1 + 3 * 4 is still parsed as 1 + (3 * 4), but 1+3 * 4 is parsed as (1+3) * 4"

      What. The. Fuck?

      --
      Trust the Computer. The Computer is your friend.
  18. Not for everybody due to indentation by blind+biker · · Score: 5, Interesting

    nim, like python, requires strict indentation. That's not comfortable for some people. I, for one, have nystagmus and find it practically impossible to code in python. I suspect I'd have the same issues with nim.

    --
    "The agriculture ministry is not in charge of Gundam" - Japanese ministry official.
  19. Re:20 years experience! by BarbaraHudson · · Score: 2

    You'll be having interviews with companies you most likely won't want to work for.

    Hasn't that been true since at least the turn of the century?

    --
    "Transparent" is a shit show that trades on every stereotype going. A man in drag is NOT a transsexual.
  20. Re:Such potential by ThePhilips · · Score: 5, Interesting

    As I have recently found out, that also affects the code generation.

    It is hard to generate Python code, without actually analyzing what's precisely is being generated. If source is 100% generated - it is doable, relatively easy. But generally generated code also contains pieces of user code, which might/might not require its own indentation and also reindentation to make it proper part of the generated code.

    If Python at least allowed optional block statement - curly brackets or begin/end or whatever. But nope. It is appears to be sort of a religious issue for the language creator and some of his followers.

    I personally do not like Python for that reason. I prefer to have a visual marker that block is closed. You know, like a dot at the end of the sentence.

    --
    All hope abandon ye who enter here.
  21. Re:A good language that'll get slammed... by gnupun · · Score: 2

    Forcing code indentation is a sign you're going to be working with a bunch of "coders" who took a weekend course and not actual software engineers.

    IMO, only lazy, inept, or noob programmers don't indent correctly. So if a language requires them to indent properly, they call it forced indentation because they usually don't indent correctly in other languages.

    If I'm wrong, how many different ways can you indent the following code?

    for x in range(1,10):
          for y in range(1,10):
                if someCondition:
                        result[x][y] = a[x][y] + b[x][y]

  22. Convincing support by early adopters by mi · · Score: 4, Funny

    The author of "Unix in Rust" just abandoned Rust in favor of Nim

    Somebody, who wrote a book an a language I've never heard of, has now switched to another new language. Whether he has an agile and flexible mind or simply is not particularly loyal to anything, I'm not impressed...

    --
    In Soviet Washington the swamp drains you.
  23. Re:Such potential by TheGratefulNet · · Score: 4, Insightful

    I just recently learned python (learned it from a top python core developer, though, if that counts any).

    I like the language. almost all of it. BUT, the lack of curly braces was a huge mistake. indentation is fine. we all agree its needed.

    here's where 'whitespace only' indenting messes up. ever see what blogs do when you try to post code? yeah. that. and its a reality, too. you will never be able to guarantee that posted code won't be 'changed' by some web formatter or email formatter!

    twice in the last 2 months I've had to extract posted source (from clueless posters) and FIX their code since it did not run OOTB. I had to GUESS where things were supposed to be nested. its not obvious; if it was, you would be able to strip all spaces out and still be able to get the same meaning.

    guido just did not think about this issue. its ok, he thought about most things, but I wish he'd man-up and admit that in THIS case, curlies are truly needed. keep the rest of the forced indenting, but ADD an open and close curly so that the meaning is crystal clear, even if mis-posted or mis-indented. plus, you would be able to re-format the source to your local google 2-space standard or the rest-of-world 4-space standard.

    oh, and it would not really hurt if you did have static data types. there's huge value in:

    int foo (int a, char b, float c);

    if you just tell me you are sending a,b,c into a routine, there's a lot that I should know that you're not telling me. it was a shame to lose this. not sure the 'power' you gain is worth the loss of immediate documentation (in the code) by declaring the types of each var and having that var always (for its scope) be that data type.

    --

    --
    "It is now safe to switch off your computer."
  24. Re:Such potential by TheGratefulNet · · Score: 2

    I agree. it needs the curlies (which WORK great in C and takes up at most 3 chars; 1 for the curlie and 1 for a space before and after. 3 extra bytes for intro and maybe 3 for exit. 6 bytes. big deal. you should 'waste' more space with comments and vertical/horizontal whitespace, just for readability, alone.

    it should have been optional. require indentation, fine. but also ALLOW those of us who like seeing an 'open and close' semantic who is explicit (not just implied) would have been the right thing to do.

    someday, maybe guido will come to his senses. if/when that happens, a lot of us will breathe a sigh of relief. and then, posted code on blogs, emailed code, etc, will still be runnable without GUESSING what the source was before the formatter destroyed it.

    --

    --
    "It is now safe to switch off your computer."
  25. Re:Such potential by Bander · · Score: 4, Insightful

    Python has multi-line strings. I know that fact won't change your mind, but it might help you look less ignorant.

  26. Re:A good language that'll get slammed... by Bander · · Score: 4, Informative

    Please stop, this is getting really tiresome. Python has multi-line strings without special escaping:

    http://stackoverflow.com/quest...

    You just look like an ignorant idiot with an axe to grind with this obsession over a non-existent problem.

    Speaking of obsessions, Python programmers don't obsess over forced indentation. It's the people who violently dislike Python who keep harping on it.

  27. Re:Such potential by beelsebob · · Score: 2, Insightful

    Oh god oh god, please don't do that. Not indenting the inner loop here is horrifically unreadable.

  28. Re:Such potential by orlanz · · Score: 5, Informative

    OK, you can consider Python as a heavily standardized version of indentation. Python's entire objective is the human reader. It doesn't leave you and 10 other developers from "tweaking the indentation from time to time to make [their own] point toward the human reader". What people don't understand is that one's interpretation of what they write could be different from others. What one finds easier to understand, others find harder.

    There have been countless times that I have read really good Java and C code and could start picking out which individual developers developed where. Do you know how much start up time is wasted in learning Dev1, Dev2's... DevXs' version of the C language? And if you touch C++... each dev has "minor versions" as they learn new ways of doing the same thing. And these code reviews are done in highly standardized environments with docs and comments. Still each developer gets their own unique version of a standardized language. And don't get me started on Perl or Ruby. There are no such things, there are just a ton of individual essays that the Perl and Ruby interpreters understand and execute.

    With Python, there is still a lot of uniqueness among developers, but you really need to look for it at the higher levels. Like method & class relationships, program execution flows, or logic design. But at the low level of reading & understanding code from a team of developers, it is dead easy. There are slight variations, but not enough to need to learn that style of coding to help in the future. That is the benefit of Python, its a global coding standard that's built into the language itself. Something that development companies spend far too much money [re]implementing every year for their dev teams.

    Now, I am not saying this is best or the way it should be done. Its just one standard where none really exist.

  29. Re:Such potential by orlanz · · Score: 4, Insightful

    Right... and I have seen this same code written in the following versions:

    for (int y=0;yheight;++y) for(int x=0;xwidth;++x) code here

    for (int y=0;yheight;++y) {
        for(int x=0;xwidth;++x) code here
    }

    for (int y=0;yheight;++y) {
        for(int x=0;xwidth;++x) {
            code here
        }
    }

    for (int y=0;yheight;++y)
    {
        for(int x=0;ywidth;++x)
        {
            code here
        }
    }

    You ask C devs how they would write it, and you will see they spread out across the above. Of course this is an overly simple example.

    Python folks will mostly gravitate to reactor451's version. Are there other versions? Yes, especially when you add in iterators and generators, but for even those, developers will gravitate to ONE version of it totally dependent on if they use that feature in their coding.

    #Python 3.0+
    for y in range(height):
        for x in range(width):
            code here.

    And if this is too far in indentation, then the Pythonic way says that your code is already too complicated and this section of the code should really be delegated away in its own method.

  30. Re:Such potential by znrt · · Score: 2

    it should have been optional

    this could be easily added without breaking compatibility. you could even write a preprocessor, if it bothers you that much. it is indeed a big constraint with little or no benefit, but most python users seem not to mind, or even like it. many languages have made some of such arbitrary decisions that are purely idiosyncratic, usually pointless but defended with zeal. if the language has other values you simply live with it or hack your way around.

  31. Re:Such potential by buchner.johannes · · Score: 4, Insightful

    I agree. it needs the curlies (which WORK great in C and takes up at most 3 chars; 1 for the curlie and 1 for a space before and after. 3 extra bytes for intro and maybe 3 for exit. 6 bytes. big deal. you should 'waste' more space with comments and vertical/horizontal whitespace, just for readability, alone.

    Haha, here you all complain that Java is too fluffy, but if a language reduces the fluff it is also not good?

    In the case of Python, instead of intro/outro curled brackets or begin/end statements AND REDUNDANTLY indenting, using only one of the two was chosen. Why do it twice.

    --
    NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
  32. Re:Such potential by ShanghaiBill · · Score: 3, Informative

    Me, I love Python.

    Me too. But in spite of the indentation, not because of it. Indentation gets goofed up all the time. For bracketed languages, you just run "auto-indent". For Python, you interrupt your train of thought for ten minutes while you debug the whitespace.

  33. Holy Fuck by Anonymous Coward · · Score: 3, Funny

    Yet Another Programming Language.

    Same shit, different syntax.

    And now, some HR idiot is looking for someone with 5 years experience in it.

  34. Re:Why do we need another programming language? by Lunix+Nutcase · · Score: 2

    Someone has some books and training courses to sell to language hipsters.

  35. Re:Such potential by ThePhilips · · Score: 2

    Haha, here you all complain that Java is too fluffy, but if a language reduces the fluff it is also not good?

    Oh this hipster coders.

    Syntax is not fluff.

    Wrappers for wrapper for adapters for wrappers - commonly found in the huge, so called "enterprise" software, is fluff.

    In the case of Python, instead of intro/outro curled brackets or begin/end statements AND REDUNDANTLY indenting, using only one of the two was chosen. Why do it twice.

    Language is a tool.

    It should give me, the developer, the choice - not take it away from me.

    --
    All hope abandon ye who enter here.
  36. Re:Such potential by Marginal+Coward · · Score: 4, Insightful

    Python's block structure isn't about saving characters or about saving typing. It's about "There should be one-- and preferably only one --obvious way to do it."

    In C, for example, there are multiple ways to place braces. In fact, there's even a lengthy Wikipedia page on that very subject.

    In my own case, I have always used the K&R style, but my employer requires the Whitesmiths style. I have a large base of code at home that I wrote and maintain in the K&R style, and it's hard to switch back and forth between the two on a daily basis [sigh].

    Python's indentation is utterly Pythonic because it is compact, yet meaningful. It carries blocks to their logical conclusion. I started in Pascal with begin/end, then learned that braces were better in C, then learned that no braces were best in Python. QED.

  37. Re:Such potential by Grishnakh · · Score: 2

    In my own case, I have always used the K&R style, but my employer requires the Whitesmiths style. I have a large base of code at home that I wrote and maintain in the K&R style, and it's hard to switch back and forth between the two on a daily basis [sigh].

    Then don't. Use your preferred style at work, and then convert it to your employer's preferred style with "indent" before checking it in.

  38. Re:Such potential by Marginal+Coward · · Score: 2

    Exactly. Imagine a brand of beer whose primary selling point was that it came in a bottle so small that you could drink an entire bottle in one gulp. Although that might be a nice novelty, the beers that come in a larger bottle probably are more enjoyable overall.

  39. Nim appears friendly enough, just avoid IRC by caseih · · Score: 4, Insightful

    IRC is just a bad medium for mature discussion to begin with (but forums suck in many other ways, so where does that leave us). The IRC channel for most *any* project is unnecessarily toxic. Just because Araq is on the IRC channel doesn't mean the whole project is polluted by the ramblings of one or two fans/hecklers/wannabe devs.

    My view of Nim from the web pages presented in the summary, and the online docs is very different from your IRC-centric view. I've personally been very impressed with the quality of the documentation, tutorials, and papers I've read so far. I don't think I've seen as friendly and readable documentation for any project in a long time. Perhaps quality will drop as Nim becomes more popular and people concentrate on developing. But for a project that has seemingly come out of nowhere, this really impressed me. Not only is Araq apparently a decent programmer, he's also a good writer too.

    Thank you to the submitter for submitting this. I had never heard of Nim before today. Adding it to my short list of very interesting new languages to follow.

  40. Re:Such potential by makapuf · · Score: 2

    Of course python does allow block delimiters. Just remember to indent your code right.
    The delimiters are #{ and #} (should be put on their own line)

  41. Re:Such potential by Marginal+Coward · · Score: 2

    I've used "indent" many times in the past, and although it's better than nothing, it isn't really a solution for this problem. You have to go fix numerous other small style issues. For example, my employer has a very detailed - though quite eclectic - style. So, indentation and other issues that "indent" can deal with are only a small part of the problem. Also, K&R is my preferredstyle (I personally think Whitesmiths is dopey, but YMMV.) I'll concede my artistic integrity for pay at work, but not for free at home.

    Regardless, my primary point (and Guido's, in Python) is that braces lead to a variety of defensible styles. We all have our preferences, but there's really no way to determine which is "best".

    Also, for the record, I should mention that Python allows indentation to be any consistent level, with hard tabs counting as 8 spaces. Though it's seemingly contary to the aforementioned principle, that one can be filed under "practicality beats purity."

    Tim Peters once said explained such contradictions with something like "the key to any successful philosophy is to allow yourself enough wiggle room to do what you really wanted to do in the first place." [wink]

  42. Agree by MSJos · · Score: 3, Insightful

    It limits expressiveness for no reason other than dogma.

  43. Re:Such potential by fahrbot-bot · · Score: 2

    I like the language. almost all of it. BUT, the lack of curly braces was a huge mistake. indentation is fine. we all agree its needed.

    In addition, according to the Language Manual, Nim supports the directive "#! strongSpaces" to allow white space to affect operator precedence. An example from the manual:

    #! strongSpaces
    if foo+4 * 4 == 8 and b&c | 9 ++
    bar:
    echo ""
    # is parsed as
    if ((foo+4)*4 == 8) and (((b&c) | 9) ++ bar): echo ""

    So with/without the directive:

    • with: ((foo+4)*4 == 8)
    • w/o: foo+((4 * 4) == 8)
    --
    It must have been something you assimilated. . . .
  44. Re: Such potential by cjameshuff · · Score: 3, Insightful

    In Python, that could easily have been one or more statements that were unintentionally made conditional or removed from the conditional, perhaps while adjusting the indentation of adjacent just-moved code so the interpreter would put it in the right block. Python's indentation significance doesn't improve things one bit. If you want a fix for this problem, make the end delimiter non-optional, which would make it much more difficult to accidentally put a statement in the wrong block.

    And of course, the presence of delimiters does nothing to prevent a language from requiring indentation or producing warnings when it finds inconsistencies between indentation and delimiters.

  45. Looks like by bytesex · · Score: 2

    Looks like a readable python variant.

    --
    Religion is what happens when nature strikes and groupthink goes wrong.
  46. So many invalid arguments by fyngyrz · · Score: 2

    Yes, but it's quite possible that the code won't parse correctly w/o the braces (or with extra braces), where improperly indented Python probably will, and just execute incorrectly.

    Your argument that your poor code is likely to operate in a poor manner is not a valid objection to Python's indentation. It merely condemns your abilities as a coder (and perhaps your ability to choose an appropriate editor as well, but I repeat myself.)

    Write good code, no problem. Your argument simply boils down to you claiming you're a lousy programmer. As do many similar arguments, such as thinking types are required because you "might" call a function wrong, or use a variable in some stupid way. If you call the function wrong, or misuse a variable, you are failing as a programmer. Do it right. Problem solved.

    Back in the day, when we were writing in assembler more often than not, you'd have been laughed out of the building if you complained that the assembler should "know" what it was looking at beyond the most simple atomic architecture-related constructs. The fact is, as a decent programmer, you should know what you're looking at, and what you are doing at all times. If you don't -- the problem is 100%, entirely, beginning-to-end -- yours. You need improvement. You should seek it. Your failings will lead to bugs. Not the language's failings -- yours.

    --
    I've fallen off your lawn, and I can't get up.
  47. Re: Such potential by spongman · · Score: 2

    Except it doesn't complain when you have a mismatch.