Making 4k intro with Nim programming language
category: code [glöplog]
I made 4k intro samples using Nim programming language.
https://github.com/demotomohiro/nim-4k-intro-sample
I wrote a blog post about how to make 4k intro with Nim.
English:
https://internet-of-tomohiro.netlify.app/nim/nim4k.en.html
日本語:
https://internet-of-tomohiro.netlify.app/nim/nim4k.ja.html
https://github.com/demotomohiro/nim-4k-intro-sample
I wrote a blog post about how to make 4k intro with Nim.
English:
https://internet-of-tomohiro.netlify.app/nim/nim4k.en.html
日本語:
https://internet-of-tomohiro.netlify.app/nim/nim4k.ja.html
nice!
this rules, well done!
pretty language
hints for other languages with no visual noise characters like ';', '{' or '}'?
Thanks for pointing my attention to the Nim programming language, which seems to be interesting.
Quote:
hints for other languages with no visual noise characters like ';', '{' or '}'?
lisp could be one example.
@psenough, @ferris
Thx!
Python, Julia and Crystal are such languages.
But Python and Julia are dynamically typed language and I don't think they can be used for making 4k intro.
Crystal is statically type-checked but I don't know whether it can make 4k intro.
Thx!
Quote:
hints for other languages with no visual noise characters like ';', '{' or '}'?
Python, Julia and Crystal are such languages.
But Python and Julia are dynamically typed language and I don't think they can be used for making 4k intro.
Crystal is statically type-checked but I don't know whether it can make 4k intro.
nice!
Though, most of the "important" code in a 4k is either the softsynth or a shader, so this feels a bit silly to pursue?
But I can definitely see why using Nim (or Rust, or Zig, or ...) is a feasible option for eg. 64ks.
Though, most of the "important" code in a 4k is either the softsynth or a shader, so this feels a bit silly to pursue?
But I can definitely see why using Nim (or Rust, or Zig, or ...) is a feasible option for eg. 64ks.
Quote:
Though, most of the "important" code in a 4k is either the softsynth or a shader, so this feels a bit silly to pursue?
To be fair, I can see a softsynth working, depending on how good the compiler is.
langs with ';', '{' or '}'? = ❤️,
langs without = 🤮
langs without = 🤮
Will people ever get tired of inventing another bicycle?
There are new bicycle models all the time...
bicycle
obTopic: I find it hard to believe that a high-level language would make sense for a barebones 4k intro structure: getting a fullscreen quad for the shader and audio output from a soft synth. Maybe something that's specifically tailored to brute-force different instruction combinations and orderings to get the best possible compression out of Crinkler. For a soft synth a high-level language migth make sense.
Can this Nim framework beat, say, Compofiller Studio or Leviathan?
obTopic: I find it hard to believe that a high-level language would make sense for a barebones 4k intro structure: getting a fullscreen quad for the shader and audio output from a soft synth. Maybe something that's specifically tailored to brute-force different instruction combinations and orderings to get the best possible compression out of Crinkler. For a soft synth a high-level language migth make sense.
Can this Nim framework beat, say, Compofiller Studio or Leviathan?
Thank you Tomohiro! Looks very useful.
Quote:
obTopic: I find it hard to believe that a high-level language would make sense for a barebones 4k intro structure: getting a fullscreen quad for the shader and audio output from a soft synth. Maybe something that's specifically tailored to brute-force different instruction combinations and orderings to get the best possible compression out of Crinkler. For a soft synth a high-level language migth make sense.
Nim is a systems programming language and try to generate fastest code like C.
Nim compiler generate C code from Nim code and it call C compiler(gcc, vcc, clang, etc) to generate an executable file.
It has low level programming feature:
pointer
inline assembler
choose calling convention
type compatible to C type
string compatible C char*
All runtime checks can be disabled with -d:danger option.
Nim code can run on small embedded microprocessors with only a few kilobytes of memory.
There are people who hate C or C++. They might try to make a 4k intro with Nim.
Quote:
Can this Nim framework beat, say, Compofiller Studio or Leviathan?
This is just a simple sample code to show how to write a 4k intro in Nim and it can generate an executable almost as small as C.
NimScript is the subset of Nim that can be evaluated by Nim's builtin virtual machine. It can be used to configure compile options and runs. It might be able to automate build process or process GLSL code.
Seriously guys, not everything needs to strive for being the most optimal solution(which is subjective anyways considering size vs maintainability). Also although I'm a fan of semicolons, curly braces etc. I have a feeling that there's quite a large portion of developers who're not *coughs in python*, heck in some scenarios even I actually prefer indentation aware languages.
So I commend the effort to bring another flavor into the mix for the people who might like it.
That being said, you might want to look into using glCreateShaderProgram(also available through an extension in earlier GL versions) to shave off a bunch more bytes.
So I commend the effort to bring another flavor into the mix for the people who might like it.
That being said, you might want to look into using glCreateShaderProgram(also available through an extension in earlier GL versions) to shave off a bunch more bytes.
does it have dx11 bindings?
@LJ
Thx! It seems I can remove shader object related code with glCreateShaderProgram.
But when I want to use vertex and fragment shaders, I have to use pipeline object.
Anyway, I think it can reduce the number of OpenGL calls.
@Gargaj
You can search Nim Package in https://nimble.directory/.
I found this wrapper.
There are also tools that automaticall generate wrapper from C code.
https://github.com/nimterop/nimterop
https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst
But I don't know if they work correctly to dx11.
Thx! It seems I can remove shader object related code with glCreateShaderProgram.
But when I want to use vertex and fragment shaders, I have to use pipeline object.
Anyway, I think it can reduce the number of OpenGL calls.
@Gargaj
You can search Nim Package in https://nimble.directory/.
I found this wrapper.
There are also tools that automaticall generate wrapper from C code.
https://github.com/nimterop/nimterop
https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst
But I don't know if they work correctly to dx11.
It's of course interesting that there are new languages and compilers that can feasibly do 4k intros. But aside from using something different just for the sake of using something different, what is the problem domain that Nim helps to handle better? Why do you want to put x86 code in a 4k intro, unless it's the last resort? I thought you should generally avoid doing anything in x86 land, because the produced code is low-level and hard to compress. Compared to, say, GLSL which sits on a higher level of abstraction. Is the motivation being able to make a data-driven engine of some sort, for a soft synth or something?
It's the demoscene - why anything? The answer is because.
Well, *assuming* C is too low-level for my taste *and* I start to get fed up with C++, then it is certainly an interesting idea. Think platforms other than Windows 4k, basically anything where the buld of the work is done on the CPU.
bulk
Don't be that guy:
yawn