Nim thread

Why don't you try Nim?

nim-lang.org/learn.html

It's pretty comfy desu

Attached: nimexamplecode.png (453x293, 25K)

Other urls found in this thread:

youtube.com/watch?v=GOnENVylxPI
github.com/andreaferretti/patty
nim-lang.org/features.html
nim-lang.org/faq.html
twitter.com/SFWRedditImages

what does that "in" mean in that for??
actualy, what does that for do?

doesnt it just compile down to C
why not just write C

looks similar to a for loop in python. In another language it would be like...

for(line=0; stdin.lines[line] != '\0'; lines++){
sum += stdin.lines[line];
count++;
}

I'm not a good coder.

Ok the syntax looks decent, why else should I use it?

>python-isms
ew

I'll stick with Python, thanks.
import sys

sum, count = 0, 0

for line in sys.stdin:
sum += len(line)
count += 1

print('Average line length: {}'.format(
sum // count if count > 0 else 0
))

> using variables

kill yourself nigger

"for x in y" means that y is a collection/iterable/sequence/list/whatever

and the "for" means it's a loop

the "for x in y" then says that x should be assigned to each value in y in this loop.

essentially the same as saying

map(lambda line: ....)

I'm so fucking high right now pls help

it's like python, but with static typing, trans/compiles to C (sometimes even faster than C since it's super optimized), also can be trans/compiled to javascript

it's like the Rust of Python, except better syntax, and you can call python or C code from it easily.

etc etc penis penis

stop doing drugs.
they are damagin your brain.

youtube.com/watch?v=GOnENVylxPI

wow that actually looks pretty cool. how is the library support? can you use python libraries in this like julia?

i tried to get started with rust, wanted to make a basic program to read a file and do a few things but when i saw how much i had to write just to use clap.rs i thought about just doing it in python

Attached: brown thinking.jpg (563x886, 227K)

Ok is there type inference? Pattern matching?

local type inference

yes pattern matching but it's not built in github.com/andreaferretti/patty

also macros, ADTs etc

nim-lang.org/features.html
nim-lang.org/faq.html

vim > nim

What does nim offer that's new?

Attached: 1553217925433.jpg (480x459, 16K)

Attached: tattoo.jpg (804x768, 92K)

I use it every day, it's become my main language. I use it at work for writing a lot of miscellaneous tools (embedded developer, the meat of our codebase is all C). I have a few packages in nimble.directory that I'm actively maintaining, and I host documentation for them on my VPS.

it has some very powerful metaprogramming capabilities. Nim macros allow you to write procedures that generate AST that gets handed to the compiler, almost like a procedural version of lisp macros.
It's garbage collected, with the fastest GC of any actively developed language.
I think it's really up to the beholder, though. Give it a shot and see how it feels.

doesn't C just compile down to assembly
why not just write assembly

>forced indentation of code
No thanks.

>the fastest GC of any actively developed language.
yeah that's not an incredibly biased statement

>loosely typed transpiled trash
No thanks dude

Why should I learn Nim instead of Rust?

it's statically typed with algebraic data types

brainlet

>var
Its weak typed you retarded college fag youll never more than a js monkey with your weak typed trash meme langs

abstraction is a thing.

C compiles down to machine code, why not just use machine code.

>what is let
>what is const

it's not weakly typed u fag -- var, at least in js, is indicative of dynamic typing -- types being known only at runtime. weak typing means type conversions are allowed in a statically (known at design time) typed language.

all that being said, as someone versed in Golang and JS (professionally), I think that a strongly, statically typed language is the way to go. Design time type checking is great. By the time the compiler will even agree to compile your code, you basically know the shit is gonna work.

If it will error on compile and wont give a runtime error because of typings unless i tell it explictely to cast a generic to an incompatible object, then yes its not complete shit i guess

It's actually strongly typed with type inference much like Golang. Thanks for playing.

doesn't assembly just compile down to binary
why not just write binary

que es el font por favor

Because I have a job and don't have the time to tinker with toy languages.

It would be EOF, not \0, but other than that yeah pretty much

>initializing two unrelated variables in the same line
Absolutely disgusting.

if you want mutable assignment, use var
if you want single assignment, use let
if you want compile-time assignment, use const

it's very safe and statically typed, with the look and feel of a dynamic language (python)

Lol no 1.0

Nim has less of a learning curve while retaining the practical benefits that rust gets out of the borrow checker (performance and static analysis). Nim code tends to be more expressive, with less boilerplate crap than Rust. I'd say you should make your own judgement though. The thing that really sells people with Nim is when they actually start using it, from what I've seen.

Their website says "We take pride in supporting all three operating systems fully". Linux is not an OS, I will not be learning this shitty language.

>based andreas btfo'ing freetards

Attached: 1550885097585.jpg (720x723, 173K)

it's a nice example that python is slow sorely because cpython devs are retarded and can't engineer a good interpreter and language runtime

It's pascal meets python.
I like it, I hope it gets popular.

are you from /v/?

doesn't binary just get executed by the cpu
why not just execute it using your own brain

>translates to C
>faster than C
breh

Attached: groo.jpg (676x514, 38K)

>what are language semantics, the thread

then explain PyPy

assembly is already machine code, just in a text presentation. It doesnt "compile down"

I think he means in the same way that c code can often produce more optimized assembly than manually written assembly code.

But I'm also skeptic

>c code can often produce more optimized assembly than manually written assembly code.
anything a compiler can write, you can also write

definitely, but using the registers in the most optimal way possible is not trivial

>count

Attached: BF0EAD3940444B028FFE414DC74FA63B.jpg (2234x1801, 337K)

@70355074
Go back to /v/ you inbred crossboarding nigger

What's wrong with variables?

>he thinks compilers use registers optimally
Hello newfriend :-)
you obviously haven't seen the SIMD monstrosity generated by compilers have you...

Attached: eek.jpg (382x382, 40K)

I like it, hope it gets more popular

>Why don't you try Nim?
Why would you try Nim ? It's a language which has zero direction and just incorporates EVERY GODDAMN concept under the sun (it makes Rust look conservative), which means that two different projects written in Nim could look like they were written in two different languages (even doesn't differentiate between upper-case/lowercase, Foo, foo and FOO are the same variable...).

No wonder it's going nowhere despite having been around for 11+ years. At least the syntax has improved since they dropped the Delphi/Pascal style.

Looks interesting, I'm going to learn a bit.

So it supports FreeBSD, OpenBSD, and NetBSD. Right? The three operating systems?

machine code compiles down to XML. Why not take acid and sing happy songs?

Couldn't remember if C arrays were null terminated or \0 terminated or EOF terminated.

neither of those 3

I'll stick with Haskell, thanks.
import Data.Function

averageLength :: (Fractional b) => [[a]] -> b
averageLength [] = 0
averageLength x = ((/) `on` fromIntegral) (sum (length x)) (length x)

main :: IO ()
main = interact $ ("Average line length: " ++) . show . averageLength . lines

Attached: haskell.png (1200x847, 15K)

>shills for nim
>can't code

String arrays are null terminated, normal arrays have a defined length and no terminator.

based

It's still only 7.6 times faster than CPython on average. That's still slow, user.