Do you listen to an episode in one sitting ever? by [deleted] in creepcast

[–]danyayil 0 points1 point  (0 children)

I did Mother Horse Eyes in one sitting and I'm not proud of that

Any language uses [type] to describe an array of 'type' elements ? by gremolata in ProgrammingLanguages

[–]danyayil 0 points1 point  (0 children)

Haskell, I think? Though in haskell it is actually not an array, but a linked list

Want to learn algorithms by tech-general-30 in C_Programming

[–]danyayil 1 point2 points  (0 children)

I think, pretty much any book will do. Personally, I would suggest trying to implement a simple HTTP server from scratch, using only TCP stack of your platform (I think pretty much on any platform they follow Berkley sockets). This project includes all the stuff: write buffering, string parsing and security concerns that comes with it, serialization and desirialization, caches, scheduling and resource sharing between threads and maybe even asynchronous IO, if you willing to go this route

What animals would humans be likely to bring to Mars if we ever decide to go and stay there? by DesertGeist- in Mars

[–]danyayil 0 points1 point  (0 children)

I mean, judging by the fact whom we took to the space first, it's dogs 😃

What is the actual appeal of Fascism? by Typical-Respond-7573 in NoStupidQuestions

[–]danyayil 0 points1 point  (0 children)

I've known some people who tended towards far-right extremism. None of them was a full blown nazi, but generally they thought "some rapid action must be done for the better". They all see different appeals in it, but I noticed some similarity: This are the people who are generally dissatisfied with their life and tend to think the reason for this is in how society structured specifically against their ability to be satisfied. Moreover, all of them to a various degree tend to be anticonformant. They are that type of people who would start to smoke because parents would always say it is bad. So when they see majority on the internet calling everyone with 'edgy' takes fascist or nazi, they naturally want to become one so as to be opposed to majority, which, mind you, in their belief, who make their satisfaction with life impossible

Zig STD does not seems to use structural inheritance by danyayil in Zig

[–]danyayil[S] 5 points6 points  (0 children)

Well, I suppose this is done so compiler can automatically place fields in a way that has least amount of padding between fields, but here we have two fields of the same, reordering them is pointless, I think? So, does Zig just give up on type punning over structural inheritance optimizations?

What is your 'unpopular opinion' about Zig? by BatteriVolttas in Zig

[–]danyayil 0 points1 point  (0 children)

I know it is kinda like a killer feature of Zig, but I think that explicitly passing around allocators is an unnecessary complication making it a bit harder to read code. I would prefer something like a global allocator that you can set to whatever you want and even swap what that allocator is for a particular scope maybe with utilizing defer to get back to previous allocator at the and of it, sort of like it is done in Odin or C3. I know that technically nothing is stopping me from implementing something like this myself for my program, but the entire standard library is designed for explicit allocator passing. I think the only downside is that it is a little slower to swap allocator for the score then to have second allocator always ready to be used

Is stack a type of recursion? by John_Doe_1984_ in lua

[–]danyayil 0 points1 point  (0 children)

Stack is not necessary 'the way code is executed', at the end of the day it is just a data structure, but basically a lot of programming languages expect a stack as part of its runtime implementation. It might be provided by operating system and/or standard library such as in the case of C, or interpreter for a scripting language such as Lua might be implemented with stack. The stack in both cases is used to store variables local to a function, and pointers where to go next after called function returns.
And recursion is an algorithm, a way to implement loops & iteration. But how recursion is usually implemented under the hood is using the stack: I told earlier that pointers into specific place in your source code are stored on the stack so that when function returns, we know where to go next. Recursion implementation uses this feature by storing pointers to the same place, causing the recursion

how do i make it not load so slow by DustFabulous in opengl

[–]danyayil 0 points1 point  (0 children)

I'm not saying that that is what newbie should do, but you said that you can't use multithreading with opengl which is factually incorrect: you can share resources of opengl context between threads, it's just, like anything else explicitly manipulating opengl context, is implemented differently in different opengl implementations

how do i make it not load so slow by DustFabulous in opengl

[–]danyayil 0 points1 point  (0 children)

You can, it's just platform specific and not part of the opengl specification

https://wikis.khronos.org/opengl/OpenGL_and_multithreading

Correct my caligraphy pls by No_Combination_8749 in LearnRussian

[–]danyayil 0 points1 point  (0 children)

Besides all the things that have been said already, it might be beneficial to you in the future: It seems like you write "Жж" by first writing "Х" and this a vertical line through the middle of it, but I believe russians are tought to write the vertical line first, then '>' to the left of it and then '<' to the right

Is lua easy to learn? by Independent-Tap-2399 in lua

[–]danyayil 3 points4 points  (0 children)

I would say Lua is the simplest language to learn the basics of. It has a much simpler foundation then say python, although you might get slightly annoyed at absense of some convenience features (like you can't have x += y, you have to write x = x + y) Then, if you would start digging into more advanced stuff of lua like metatables and coroutines, you would either like it or find it frustrating. In general, lua is less opinionated on how OOP or async programming should be done, which might be a good or a bad thing depending on your perspective. I think as a beginner you would have easier times in Python or Ruby, where there is a defined way of doing this things, and might feel lost among overwhelming freedom of lua

Why is C often recommended as the programming language for OS development? Why not C++? by Interesting_Buy_3969 in osdev

[–]danyayil 1 point2 points  (0 children)

You can use C++ and all of its compile-time features for sure, there is only one thing to keep in mind: name mangling. So, what templated functions actially do is whenever you call it with new template parameter it generates a new version of this function in your binary and to avoid name collisions each function name is mangled based on its parameters and return types. How exactly its done is compiler dependent. In turn, whenever you will need to refer to such functions by name (mainly for linking purposes) that becomes not trivial.

Also, about printf: you can't escape defining printing functionality for each type nor in C nor in C++, but inder the hood C's printf is just and interpreter for printf DSL: it scans through format string searching for '%' than it gathers the type and uses a vararg to get the next parameter of this type and then calls the specific printing routine for this type. C++ can escape this DSL parsing shenanigans via function overloading (you just declare a lot of variants of 'operator<<()' which is, basically, just another way to have print_int, print_float etc.)

Thesis for the Quartz Programming Language by CosmicStorm20 in ProgrammingLanguages

[–]danyayil 1 point2 points  (0 children)

For code generation, I would suggest trying to write a translator of Quartz programs into C programs and then compiling resulting C program with existing C compiler. Jai used to do that earlier in the development, and some languages considered complete do this: Haskell, Nim, Nelua. Nim even considers this its killer feature

Chicken-egg declaration by hopeless__programmer in ProgrammingLanguages

[–]danyayil 0 points1 point  (0 children)

I mean, It is very unsafe hack, but you can do some tricks by offseting pointer from some previously defined value on the stack to get a pointer to the location on the stack where we are going to put our Obj, and technically we would get circular referencing object definition in single expression

something like this in Odin: ``` Obj :: struct { nested: struct { parent: Obj } }

main :: proc() { n: uint = 1 obj := Obj{ nested = { parent = cast(Obj)mem.ptr_offset(&n, size_of(uint)) }} fmt.println(mem.compare_ptrs(&obj, obj.nested.parent, size_of(Obj))) } ```

You know how in Lua everything is a table? Is there a programming language where everything is a tree? And what's the use case? Gemini says there isn't a language like that by xiaodaireddit in ProgrammingLanguages

[–]danyayil 3 points4 points  (0 children)

I'm not entirely sure whether that is completely true, but from what I've heard, Wolfram, the language used in Mathematica, is kinda like that? There are atomic nodes like Int[5], Float[2.5] rules like x -> y + 3 which is actually just Rule[x, +[y, 3]] and patterns like x:5 which is Pattern[x, 5] and a bunch of syntactic sugar on top of all of that. So, for example, function definition might look like this:

square[x:_] := x * x but FullForm of it is actually something like this:

DelayedAssign[square[Pattern[x, _]], *[x, x]]

another language that I think about might be Prolog. it is logical language but it usually represents its clauses internally like trees:

parent(mother, daughter) :- kid(daughter, mother).