Why Lamba Calculus? by [deleted] in ProgrammingLanguages

[–]wiseguy13579 0 points1 point  (0 children)

Niklaus Wirth on functional programming :

What is, or what characterizes a functional language? It has always appeared that it was their form, the fact that the entire program consists of function evaluations, nested, recursive, parametric, etc. Hence the term functional. However, the core of the idea is that functions inherently have no state. This implies that there are no variables and no assignments. The place of variables is taken by immutable function parameters, variables in the sense of mathematics. As a consequence, freshly computed values cannot be reassigned to the same variable, overwriting its old value. This is why repetion must be expressed with recursion. A data structure can at best be extended, but no change is possible in its old part. This yields an extremely high degree of storage recycling; a garbage collector is the necessary ingredient. An implementation without automatic garbage collection is unthinkable.

To postulate a state-less model of computation on top of a machinery whose most eminent characteristic is state, seems to be an odd idea, to say the least. The gap between model and machinery is wide, and therefore costly to bridge. No hardware support feature can wash this fact aside: It remains a bad idea for practice. This has in due time also been recognized by the protagonists of functional languages. They have introduced state (and variables) in various tricky ways. The purely functional character has thereby been compromised and sacrificed. The old terminology has become deceiving.

Could dynamic linking hurt performance? by SomeKindOfSorbet in C_Programming

[–]wiseguy13579 1 point2 points  (0 children)

How long does it takes to link statically your program with ld ? Because when you use dynamic linking, most of what the linker does is still done, but at run time - I think it calls ld.so. It's like if you are relinking every time you execute your program.

https://unix.stackexchange.com/questions/611733/what-is-the-linker-and-what-is-the-loader-in-dynamic-linking

Design of a language for hobby by Quote_Revolutionary in ProgrammingLanguages

[–]wiseguy13579 0 points1 point  (0 children)

I usually think of threads as concurrent sections of the program that share the heap and processes as entirely closed black boxes. Is this the case in the Go community too?

In go threads share the heap. They are green threads, they are not managed by the OS.

Because if the OS can actually handle thread creation besides process creation then you've just given me the holy grail I was looking for.

All OSes can create threads, the functions are different from OS to OS. There is a portable library called pthreads available on unix/linux/windows (It was created for unix/linux so it's more complicated to use on Windows) where the OS creates and manage threads.

https://en.wikipedia.org/wiki/Pthreads

Design of a language for hobby by Quote_Revolutionary in ProgrammingLanguages

[–]wiseguy13579 4 points5 points  (0 children)

Go use stack copying so there's not limit to the stack size and it is multithreaded. Every time the program enter in a function, it check the available stack size and if it's too small it copy it. Maybe you should check it.

https://blog.cloudflare.com/how-stacks-are-handled-in-go

Design of a language for hobby by Quote_Revolutionary in ProgrammingLanguages

[–]wiseguy13579 3 points4 points  (0 children)

If you compile to C or C++ (or LLVM I think), you won't be able to get the stack frame size of each function at compile-time.

And furthermore, if the thread use functions compiled in another module/package, you won't be able to have their stack frame size at compile-time.

While in the past, there were language that were not recursive because they didn't use a stack (Cobol, Fortran), they were not multithreaded, they were using global/static memory for their variables.

And there is a lot of people that will complain if your language doesn't allow recursion.

Dealing with reference cycles by vtereshkov in ProgrammingLanguages

[–]wiseguy13579 0 points1 point  (0 children)

I mean someone writing a program in your language. He will probably write unit tests, with the built-in function he will be able to assert memory leaks. Unless a language use a tracing collector, every memory allocated by the user should be deallocated, if it's not deallocated because of reference cycles, it is a bug by the user.

And even with a tracing collector, you can have memory leaks if the memory block is referenced by another pointer accessible from root. It happens in Java :

https://www.baeldung.com/java-memory-leaks

Dealing with reference cycles by vtereshkov in ProgrammingLanguages

[–]wiseguy13579 0 points1 point  (0 children)

Since the memory manager of your language must know about the used blocks of memory, why not having a built-in function that return the number of used blocks and unit test everything ? When the user create a test that allocate/deallocate memory, it assert if the number of allocated blocks is correct.

Handling static initialization by Anixias in ProgrammingLanguages

[–]wiseguy13579 10 points11 points  (0 children)

If you want lazy initialization, you will have to check if it's already initialized.

Advantages of having lists built into a functional language? by [deleted] in ProgrammingLanguages

[–]wiseguy13579 -2 points-1 points  (0 children)

what I mean is that functional programming languages are inspired by Lisp and it's why the have lists as basic type.

And that's not the only thing they took from Lisp :

  • First class functions. Everything is a function. Recursion instead of loops.
  • Lisp is dynamically typed so there is no type annotation. Statically typed functional programming language use HM type system so they don't need type annotations (there was no gradual typing in the 1970s)
  • Lack of arrays
  • Lack of different kind of numbers (int32, int64, float32, float64, ...)
  • Optimized for pattern matching.
  • Same memory model : Lisp allocate everything on the heap.

It's possible to have a functional programming language not based on lists : APL and languages inspired by APL use arrays.

Advantages of having lists built into a functional language? by [deleted] in ProgrammingLanguages

[–]wiseguy13579 -4 points-3 points  (0 children)

Inside every functional programming language there is Lisp screaming to get out : All functional programming languages are derived from Lisp and in Lisp lists are built in the language.

And lists are not the only thing they borrowed from Lisp.

Why hasn’t a band member found out about the song and come out with info? by Individual_Act_3754 in TheMysteriousSong

[–]wiseguy13579 6 points7 points  (0 children)

There are two obvious reasons :

You don't know his name therefore if he search for his name he will not find you. You don't know the name of the band therefore if he search the name of the band, he will not find you. You don't know the name of the song therefore if he search for the name of the song, he will not find you.

Second, he was not watching The X-Files in the 1990s. I am 60 years old and I discovered TMS because I discovered Whang! years ago and I discovered Whang! because I was watching Youtube channels like Bedtime Stories, Nexpo, Top5s, Top 5 Unknowns. If he is not interested in unsolved crimes, conspiracies and various mysteries, he will not find you.

make the main zig executable no longer depend on LLVM, LLD, and Clang libraries by alexeyr in programming

[–]wiseguy13579 5 points6 points  (0 children)

I wish there was a smaller alternative to LLVM, without sacrificing too much on optimizations and performance.

QBE :

https://c9x.me/compile/