Ask HN: What ideas in programming languages do you find difficult to code?
Sometimes understanding a programming language paradigm/pattern/feature doesn't mean you can code easily using that paradigm/pattern/feature.
Maybe you struggle with object-oriented programming? Or maybe it's functional programming that's never clicked? Or maybe some other programming paradigm like stack-based programming (Forth) or goal-directed execution (Icon, Unicon).
Or is it a particular feature within a language (e.g Monads) that just doesn't make sense?
Do you avoid these ideas or features? Maybe you feel you have no need for them? Or do you still want to master or at least understand them better?
Or maybe you have the opposite problem: you know a pattern or feature so well that you reach for it every time regardless of whether it's suitable for the problem at hand? (Anyone brave enough to admit that :-)
(
17 comments
| 20 points
| on HN
)
Found it surprisingly difficult to code well, regardless on the language, esp. when there're many states.
In one of my prev workplaces we worked on state machines. Few good takeaways was to design state transition functions in a large array laid out with all possible hooks in order. And document the hell out ofit. Another approach was to generate boiler plate out of fsm given its grammar.
I wish someone would invent an approach suitable for generic FSMs, not just for async IO. External code generators work when you have grammar or protocol state UML, but aren’t without their problems.
http://docs.dapt.in/state_tracking/
Would love feedback.
[1] https://github.com/daptin/daptin
Here’s an example of FSM with relatively complex state, 1000-lines gc_execute_line function, it’s for CNC: https://github.com/grbl/grbl/blob/master/grbl/gcode.c
That’s not my code, but I’m not sure I would be able to do much better than that.
However, above that “case 4:” there’re another cases, “case 10: case 28: case 30: case 92: ” without break at the end of the code. Unlike some other languages, in C and C++ this means execution continues to the next case. The behavior is called "switch statement fallthrough".
That source code has the comment saying “No break. Continues to next line.”
I learnt a bit of Go during weekends. I love the power and simplicity of concepts it brings in. But syntax is weird - func args and return is so weird. And variable declaration is verbose.
A language's syntax familarity with existing langauges like c, java, pythn, ruby etc.. Helps the speed at which experienced programmers process code. This is not just writing but also reading lot of open source code. If i dont feel upto speed with reading and writing - it kind of discourages.
I feel like I'm learning new concurrency patterns every week or so. Visualization tools like gotrace help, but it's still a mental twizzler. The first time you see chan type os.Signal, or func() or chan chan, you can't help think to yourself "why would anyone do this?" But as you begin to realize its not just about passing data but distributed control flow through your system, you gain more confidence in experimenting.
I'm still trying to wrap my head around garbage collection and other optimizations that we can make at a lower level. Go is so fun, though.
Also, my understanding (please correct me if I'm wrong) is that Elixir doesn't yet support all the language/runtime features that Erlang does. Has that changed in the past year or so?