16 ms·
Advent of Nim
- skocznymroczny 8y agoCan someone sell me Nim in few sentences if I am a D user?
- dymk 8y agoEvery feature you can possibly imagine, and then some. Not always a great thing. Features like implicit syntax rewriting macros or case-insensitive variable names are... interesting experiments in a language, but ultimately not good ideas. I’ve tried the language a few times over the years, and each time the compiler was just as buggy. Lots of corner cases to worry about with features, like generators working only if the code that invokes them can entirely be inlined.
- andrenth 8y agoDoes it have algebraic data types and pattern matching?
- alehander42 8y agoYes. ADT are case objects: they are widely used. https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants https://nim-lang.org/docs/tut2.html#object-oriented-programm... There are some macros for easier generation: https://github.com/andreaferretti/patty#constructing-variant-objects https://github.com/andreaferretti/patty#constructing-variant... There are pattern matching libs: pattern matching is implemented on top of metaprogramming. General pattern matching: the original https://github.com/andreaferretti/patty https://github.com/andreaferretti/patty https://github.com/alehander42/gara https://github.com/alehander42/gara (disclaimer: my lib) patty and gara should eventually combine into a single lib: including probably the current gara matching DSL(inspired by patty) and patty's variant DSL in the same place. AST pattern matching: optimized for macros, nice error reporting https://github.com/krux02/ast-pattern-matching https://github.com/krux02/ast-pattern-matching
- andrenth 8y agoCool. Do the pattern matching libraries check for exhaustiveness in the match cases? Do you see this eventually becoming part of the language?
- dom96 8y ago> Do the pattern matching libraries check for exhaustiveness in the match cases? I'm not 100% sure, but I would guess yes. > Do you see this eventually becoming part of the language? I can answer this with some confidence: no. Nim is designed to have a small but very extensible core via metaprogramming. This is why we encourage users to write such macros. They may end up in our stdlib eventually but it's unlikely they'll be part of the language.
- alehander42 8y agoAt least gara can't check exhaustiveness now: require one to add `else` to check all cases: it might be harder in general make sure branches match each possible value. However it should be possible for sum types/enums: `case` already does it
- p0nce 8y agoI'll stick with D then :)
- bhauer 8y ago> Features like implicit syntax rewriting macros or case-insensitive variable names are... interesting experiments in a language, but ultimately not good ideas. I'm not too familiar with the specifics of Nim, but how are case-insensitive variable names a bad idea, except that notion is so unfamiliar to programmers? Flipped around, if a language were to be designed today in a vacuum, what is the argument in favor of case-sensitivity in variable names? My feeling is that we take case-sensitivity for granted because the vast majority of languages inherited that behavior from history's lineage of great programming languages. But re-evaluated without that history, case-sensitivity seems only to create potential confusion at best and opportunities for trolling and obfuscation at worst. Today's use case to indicate scope, mutability, or permissions is an artifact of this history. As programmers, we know how to read something like this in Java, but if we were able to completely erase our historical knowledge and consider language design without that baggage, this seems like bad language design: // Local variable square is instantiated equal to // SQUARE constant in class Square. Square square = Square.SQUARE; I'm not sure what alternative syntax we'd have today if we had never adopted case sensitivity in names to begin with, but my hunch is I would prefer it even if it involved more typing (e.g., prefix or suffix symbols). Admittedly, a statically analyzed language will have most case typographical mistakes found and corrected at compile time, so they are a lesser annoyance than case-sensitivity in other contexts (such as filenames or column names in database tables). Generally speaking, I would be in favor of a hard break to drop case-sensitivity across the board, but I'll put that on the same list as adopting the metric system in the US (titled: "LOL, good luck.").
- dymk 8y agoA few reasons off the top of my head: * Simplifies refactoring tools. * Encourages a consistent style in the ecosystem from the beginning. * Not needing specialized tooling to grep for an identifier in a codebase. * Being able to Google a particular function name. * Consistency in identifier naming when looking at a stacktrace.
- nitely 8y ago> Simplifies refactoring tools. How? we would just have case insensitive refactoring tools. > Encourages a consistent style in the ecosystem from the beginning. Python, C, Java, etc are case sensitive langs, and it's possible to define function names in all upper-case and do all kind of inconsistent styling. Python has pep8 for a reason. > Not needing specialized tooling to grep for an identifier in a codebase. If all langs were case-insensitive, all those tools would be case-insensitive by default (or we would all know the right combination of flags to make them behave). > Being able to Google a particular function name. Is google case sensitive? In any case the lang would define a preferred style, like all case-sensitive lang do anyway. > Consistency in identifier naming when looking at a stacktrace. Same as above. Parent said "if a language were to be designed today in a vacuum", I don't think any of your arguments hold.
- jibal 8y agoNot in a few sentences, no. D and Nim are comparable in many ways but use different approaches. If you like D then no reason to switch.
- mratsim 8y agoTimothee Cour who's a heavy contributor to both lang did a comparison 8 months ago: https://github.com/timotheecour/D_vs_nim https://github.com/timotheecour/D_vs_nim
- Insanity 8y agoThat's cool :) We have a private leaderboard going at work, but IIRC the limit is 200 users on a board. If you haven't tried it yet, give AoC a try this year. It's actually really fun!
- rijoja 8y agoEven though I haven't taken it out for a spin just yet, I've gotten a good impression of nim. Anybody out there who has tested that can say if my hunch is right or not?
- qaq 8y agoplayed with it a bit the lang is really nice but lib support for things I needed was lacking. e.g. async PostgreSQL driver. Has good c interop though.
- tokai 8y agohttps://github.com/cheatfate/asyncpg https://github.com/cheatfate/asyncpg
- qaq 8y agoyou seriously proposing to use a db driver in prod that has 1 contributor and was abandoned more than a year ago?
- tokai 8y agoI wasn't proposing anything. I dropped a link with relevant content to your post. It was as much aimed at readers of your comment as it was aimed at you. Please turn down your scorn.
- jamespo 8y agoMaybe you could contribute to it
- qaq 8y agoPretty far from my area of expertise. BTW. I have 0 expectation that someone has to solve my problem but when looking at a lang to me the minimum req. are good PG support and decent http lib which is obviously not the requirements people actively working on Nim have.
- triodan 8y agoAdvent of Code is a really fun event in general and an excellent problem-solving exercise, I remember how /g/ won last year's global leaderboard. I'll definitely going participate this year as well.
- rijoja 8y agoActually /g/ was where I found out a bit nim, maybe it's really popular in that community for some reason?
- swah 8y agoI'm old - is /g/ an individual?
- DiabloD3 8y ago/g/ is an autonomous collective of people who can't code, but have an entire part of 4chan dedicated to misunderstanding the practice.
- escapecharacter 8y agoUnderrated comment ^^^
- hex12648430 8y ago/g/ is a discussion board on 4chan(nel). Last year's global leaderboard winner (anonymous user #193354) was part of a private leaderboard for /g/ users.
- sandov 8y ago/g/ is the board dedicated to technology discussion on 4chan.
- jventura 8y agoHas anyone tried to use Nim on an Android or iOS app? If yes, how's the workflow, is it straightforward?
- gameswithgo 8y agoI've seen it done. Since Nim compiles to C the process of getting stuff running on android or IOS is more or less the same as with C.
- mratsim 8y agoActually you can even compile it to Objective-C as well for iOS.
- iffycan 8y agoI'm working on a library to do that right now [1]. Currently, it's alpha quality, but you can make OpenGL apps in both, SDL2 apps in iOS and Webview apps in both. Also check out nimx [2] [1] https://github.com/iffy/wiish https://github.com/iffy/wiish [2] https://github.com/yglukhov/nimx https://github.com/yglukhov/nimx
- kryptiskt 8y agoI have done Advent of Code in C++ and Rust (2 years), it has been fun every time. This year I will change tack and use Factor, which I have admired for a long time but never used much in anger.
- jonenst 8y agoI've been doing the AoC in factor since the beginning and this year I'm trying rust. Looks like i'm following the opposite path as you are :)
- arendtio 8y ago> The Nim team has decided to reward the best (fastest) player on Nim leaderboard Does this mean the fastest developer (first to submit a solution?) or does it mean the fastest program in terms of runtime performance or something completely different?
- _pmf_ 8y agoYes.
- narimiran 8y ago> Does this mean the fastest developer (first to submit a solution?) Yes, it means the fastest player on Nim leaderboard, i.e. the one who will on the top of the leaderbord on December 25th. I guess the fastest program(s) could fall under "the solutions which best showcase the power and capabilities of Nim language".
- yarinr 8y agoThe first to submit a solution.
- PaulHoule 8y agoIf you win the contest do you really need the book?
- pjmlp 8y agoI guess if it would be signed by the language authors, it would be a nice thing to have. :)
- mratsim 8y agoThe book is not really about algorithms, it talks about async, multithreading, with example on a building a chat app or a Wikipedia parser and a tweeter clone. So it's more web backend oriented for the practical stuff. Obviously it also goes into Nim specific features like metaprogramming, interfacing with C and JS and the standard lib features in general.
- alexeiz 8y agoThat reminds me, I participated in a C++ contest some number of years ago in which I came out one of the prize winners. They gave me a C++ book. I opened it maybe once or twice because I already knew much of what it said.
- mhd 8y agoBy the way, does anyone know who started the "Advent of ..." series? Earliest one I'm aware of was Perl.
- deleted 8y ago[deleted]