lol, at least they have interfaces in java
objects are not the right solution for pretty much all reuse and extensibility IMO
lol, at least they have interfaces in java
objects are not the right solution for pretty much all reuse and extensibility IMO
"Who needs objects when you can just sprinkle some Java interfaces on everything? 😂 #ThinkingOutsideTheBox"
The functional additions they added are great. I use those extensively.
closures are a mandatory language feature... go had them from the beginning
really cool thing for building work queues you can put closures into a channel, and the channel can be buffered so the load/unload sequence can be disjoint
closures are really cool for dynamic execution too, just have to create functions that initialise parameters and then you can construct a giant closure made out of many little closures that all runs in one go... this is used extensively in "Immediate Mode GUI" designs in go
and because go is go, you can also use closures for defer statements (that run before a function returns) or you can have a closure inside a function that spawns a goroutine - pretty much essential for any case where you have a second stage process so the main thread digs out data, then a second thread can assemble it, and when the main thread is finished, spawn a job on the collection that was assembled... i'm in the middle of debugging one of these... got some stray strange indexes popping up that i can't trace
Closures are great. Thankfully Java has them these days.
Context capturing is important. D was great closure support, even automatically detects when certain variables should be allocated on the heap when nested functions capture outter context.
D has something like defer but it is more tweakable. Scope guards.
Can run them on exit, exception or both. And in any scope, not just exiting a function.
yes, defers run at all times, and there is an exception catching mechanism you can put inside a defer closure
in Go there is functions and closures, these are scopes for entry and exit of subroutines, then there is logic blocks like if, switch, for and select, these have scopes also that you can create new variables inside in specific ways... to make a switch execute defer-like code you would use the "fallthrough" to let the switch check all conditions and then you put your defer code in the default
go can do all the things, just not in all the ways, because actually you don't really need that much flexibility
my first two languages were BASIC and Assembler... if you can't express an algorithm in a simple form then all you are adding by this complex language construct is a big cost in deciphering your intent in this "expressive" language
go has two different types of scope, there is imperative scopes, like inside functions and logic blocks, and there is declarative, which the main one is the top level of a source file
the reason why they do it this way is that it makes cutting up the source files so much easier, you literally search for the short set of sentinels (there is about 10 or so) and then you know what is inside each one
all these fancy constructs in other languages are all well and good but you pay for them in a proportionally longer edit/test cycle time, go prioritises being able to change one line of code and test it under 5 seconds later
Man is a Go enjoyer.
But have you ever used Forth?
bitcoin script is based on forth
when i was 12 years old i got a "work experience" time with an agricultural scientist who was making crop simulations, and his main language was forth
i learned lisp and C at the time
forth is just barely more than assembler, and BASIC is like complicated forth
there is a retarded mentality in the tech sector these days that you can reingineer mathematics somehow
STOP IT!
Forth is so fun. I played with Gforth a while back.