Live data from Hacker News

I learned seven programming languages

mode80.github.io

31–40 of 52 posts

Re: I learned seven programming languages

#31
I like nim but I've never really gotten used to the slicing syntax. I guess that I'm just too used to python, plus you have to be a bit careful to leave a whitespace when doing backwards indexing so that the operators work correctly.

So python:

    a = [0,1,2,3,4,5]
    a[0:5] => [0,1,2,3,4] - half closed interval
    a[0:-1] => [0,1,2,3,4] - negative indexing
    a[:5] => [0,1,2,3,4] - skipping start index 
    a[3:] => [3,4,5] - skipping end index
nim:

    var a = [0,1,2,3,4,5]
    a[0..5] = [0,1,2,3,4,5] - closed interval
    a[0..^1] = [0,1,2,3,4,5] - closed interval with negative indexing
    a[..4] = [0,1,2,3,4] - skipping start index
    a[..
I'm sure that there are good reasons for this behaviour and that if you use nim a lot, you just get used to it but I find the python syntax just nicer.

Re: I learned seven programming languages

#34
post #4

The author's experience is based on toy examples. Programming (and designing) in a professional setting is more than that, though. And the solutions are not the same for everyone: writing an Office plugin has different needs than writing a mobile game. For many of us, the availability of tooling and libraries is crucial. I'm not going to reinvent the web server by building on OS sockets or write a graphics rendering…

Yeah, languages are "easy" to learn when you already know a few from different paradigms. I can skim through the docs of an unknown language and know enough to start writing in it quite quickly. What takes time is to also learn all the tooling, not just the syntax. How do you build it, debug it, deploy it, what frameworks and libraries should you use, and spend time to learn them. Take javascript, for instance. If yo…

Right. The languages themselves are usually pretty straightforward; 80% of them have a "common DNA" as most other languages, which an experienced programmer can pick up quickly. The ecosystems, on the other hand, have a lot less commonality, though more recent languages like Rust and Go are bundling more of that stuff so it's less chaotic than C and JavaScript.

Re: I learned seven programming languages

#35
> I like named parameters for self-documenting code. Julia allows named parameters but naming them doesn't provide any flexibility with regard to their position when calling the function.

I don't understand this complaint? "Named parameters" i.e. keyword arguments in functions work great in Julia!

    julia> foo(;x = 1, y = 2, z = 3) = x + y + z
    foo (generic function with 1 method)

    julia> foo(; z = 4, y = 0)
    5
Perhaps the author meant default arguments?

    julia> foo(x = 1, y = 2, z = 3) = x + y + z
    foo (generic function with 3 methods)

    julia> foo(3)
    8

    julia> foo(0, 0, 0)
    0
> this flexibility does tend to cause bugs working with other people's code. This is compounded by Julia's pursuit of composability. If you cram your custom data value into someone else's function, and if it seems to be the right shape, it will probably work! Unless it doesn't. In that case you just get silently wrong answers. This is a deal-breaker for a lot of scientific computing people where Julia would otherwise shine.

This is almost entirely mitigated by most people using `eachindex` or `axes` or other functions that make the array related code index agnostic. The only reason I say almost entirely is because there's probably some really old code that doesn't work the right way and would silently fail or do the wrong thing if you changed the indexing convention. That said, calling this a "deal-breaker for scientific computing" seems extreme.

> I also find Julia's errors to be fairly obtuse. And I see a lot of them because dynamic typing means the tools can't catch most errors before run-time.

I 100% agree. Julia errors are my biggest gripe with the language at the moment.

> But the big dealbreaker with Julia is it only complies on the fly. That means you can't just hand a compiled executable to someone. You must give them instructions to install Julia and all your dependencies first. That's no good for anything you want to ship like a desktop app or a game. You also don't want Julia on your server recompiling with every web request.

There are packages like PackageCompiler that work pretty well. And I'm positive in the near future (3 years?) we'll have a version of Julia where PackageCompiler will produce small binaries. That said, the convenience of writing in Julia and shipping a precompiled app is pretty awesome, and I personally don't mind it taking more space on disk.

> Like all compiled languages, the development cycle involves a lot of recompiling as you go. For small programs it doesn't matter, but this creeps up as the program grows -- or when you add a heavy dependency, like a plotting library. Julia suffers from this compiled-language drawback, but without the normal advantage of getting a compiled executable you could distribute.

This used to be one of my biggest gripes, but things have gotten a lot better with every version of Julia.

----

My first order approximation when picking a language is this:

1) if I think it'll be easy to write in Python, I should write it in Julia. 2) If I want to ship a precompiled binary that exposes a command line interface, I'll think about using Julia first, and if the size of the binaries are an issue, I might pick Rust.

wrt to Nim, I'm waiting to see how the ORC story shakes out + better documentation about ORC to appear on the scene and for more packages to adopt it. I think Nim currently has too small a community. I've found packages that are commonplace in Rust or Julia are just not even available in Nim. Sometimes a package is 5 years old and hasn't been updated. Yes, it is easy to write interfaces but that requires a lot of work. If it is a project where I'm writing code just by myself, Nim might be a good choice but if I'm working with someone else, having them learn Nim is much harder. The error messages in Nim also need to get better in my opinion.

> You don't have to decide between snake_case or camelCase. You can define your variable either way and both references will work. Ditto for most cases of capitalization. I thought this might be problematic, but in practice it's brilliant. I think that sentiment applies to many of Nim's unexpected design choices.

I personally don't like this at all. Every time I search a nim codebase, I have to use `nimgrep` instead of using `ripgrep`. I have SO many aliases built on top of things like `ripgrep` and `fzf` and none of them are certain to work in `Nim`. It's frustrating that the community is so divided on this, because even though I can see there are benefits to this approach, the benefits pale in comparison to getting user adoption and buy in to use the language.

One of my senior developers on my team agreed to learn Nim in their spare time as a favor to me, to evaluate it for a project at work, and as soon as they came across this "feature" they were so turned off, they wrote the language off as being too weird.

There's a LOT of average programmers out there, and a lot more analysts and data scientists that just want to get shit done, and from personal experience I think it's extremely hard to get adoption for Nim in the scientific community. If 7 out of 10 people have used Python, 4 out of 10 people may have heard of Julia and heard that it's new and modern, but 0 people have even heard of Nim. I've gotten SO many quizzical looks over the years, it is not even funny.

Re: I learned seven programming languages

#36
post #18

The criticism of Julia seems strange: > But the big dealbreaker with Julia is it only complies on the fly. That means you can't just hand a compiled executable to someone. You must give them instructions to install Julia and all your dependencies first. That's no good for anything you want to ship like a desktop app or a game. You also don't want Julia on your server recompiling with every web request. That's an issu…

Also, you can precompile a whole package and just ship the binary. We do this all of the time. https://github.com/JuliaLang/PackageCompiler.jl And getting things precompiled: https://sciml.ai/news/2022/09/21/compile_time/

How well does this work? I've seen this library but never used it. Julia is really slow from a cold start, which limits its utility for scripting.

About a year ago I was very off-put by someone on Reddit who sort of scolded me for wanting to use Julia as a general-purpose scripting language at the CLI. The Redditor said this wasn't as idiomatic usage of Julia. Idk how representative this is of the community at large.

Re: I learned seven programming languages

#37
I have used Nim for personal projects for 6 years now and it continues to surprise me on how well versed it is for many problem domains. I am fond of it's SPA framework, karax https://github.com/karaxnim/karax for which I wrote a translation utility https://github.com/nim-lang-cn/html2karax Latest Nimv2 release candidate has improved in the ergonomics and syntax that affect compilation to js, so I was able to cleanup my webapp's code to be less verbose. On GPU programming there has been a few projects that touch GPU programming, most notably https://github.com/treeform/shady

Re: I learned seven programming languages

#38

I have used Nim for personal projects for 6 years now and it continues to surprise me on how well versed it is for many problem domains. I am fond of it's SPA framework, karax https://github.com/karaxnim/karax for which I wrote a translation utility https://github.com/nim-lang-cn/html2karax Latest Nimv2 release candidate has improved in the ergonomics and syntax that affect compilation to js, so I was able to cleanup…

Also on the game development front, I maintain a raylib wrapper https://github.com/planetis-m/naylib As long utilities like c2nim https://github.com/nim-lang/c2nim exist, it's trivial to create bindings of C/C++ libraries. One thing I want to experiment more is making it more automatic by writing a callback exposed by c2nim that transform the generated code using Nim's AST. But regardless in that project I was able to write safe language abstractions on top of the bindings that provide a more native experience. It has scope-based memory management, generics and ... function/enum overloading.

Re: I learned seven programming languages

#39
post #32

I’m surprised about Python being the language OP would teach his kids first. Racket seems more approachable for children. http://emmanueltouzery.github.io/blog/posts/2016-10-13-teach...

Idk man. I started with BASIC on the CPC 464. Then moved over to the C64 and ASM. I believe it was good starting so low level. At times I had to type in the actual machine code to program. When you're young your mind is very capable of learning. The more complex the better. The lower level the better.

Although a former co-worker said in a break-chat that it's best to learn something from both sides top down and bottom up. I'm just not sure how that would work.

Re: I learned seven programming languages

#40

Earlier quoted context omitted.

Also, you can precompile a whole package and just ship the binary. We do this all of the time. https://github.com/JuliaLang/PackageCompiler.jl And getting things precompiled: https://sciml.ai/news/2022/09/21/compile_time/

How well does this work? I've seen this library but never used it. Julia is really slow from a cold start, which limits its utility for scripting. About a year ago I was very off-put by someone on Reddit who sort of scolded me for wanting to use Julia as a general-purpose scripting language at the CLI. The Redditor said this wasn't as idiomatic usage of Julia. Idk how representative this is of the community at large.

By any chance, was your post about starting Julia in a tight inner loop? If so, this really isn't idiomatic and exactly one of the few cases where Julia isn't great. Though it can be circumvented.
Post reply on HN