
Ask HN: What ideas in programming languages do you find difficult to code? - open-source-ux
Sometimes understanding a programming language paradigm&#x2F;pattern&#x2F;feature doesn&#x27;t mean you can code easily using that paradigm&#x2F;pattern&#x2F;feature.<p>Maybe you struggle with object-oriented programming? Or maybe it&#x27;s functional programming that&#x27;s never clicked? Or maybe some other programming paradigm like stack-based programming (Forth) or goal-directed execution (Icon, Unicon).<p>Or is it a particular feature within a language (e.g Monads) that just doesn&#x27;t make sense?<p>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?<p>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&#x27;s suitable for the problem at hand? (Anyone brave enough to admit that :-)
======
Const-me
I’ve implemented finite state machines multiple times (network protocols,
format parsing, CNC controls, videogame AI, etc.) in different languages.

Found it surprisingly difficult to code well, regardless on the language, esp.
when there're many states.

~~~
samblr
When some one complains about how async nodejs and callback are hells. I
smile. FSM are notoriously hard to write, manage and debug. Because they are
async by design.

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.

~~~
Const-me
For asynchronous IO, we now have async-await in many modern languages. The
feature pretty much solves IO related callback hell; the compiler builds these
state machines automatically, and keeps them abstracted behind a nice API
making code easy to read, write and debug.

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.

~~~
ablaba
How about esterel? It seems to be a nice language based on FSM.
[https://en.wikipedia.org/wiki/Esterel](https://en.wikipedia.org/wiki/Esterel)

------
samblr
Strange as it sounds, a new language's syntax has become increasingly
important and difficult to learn.

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.

~~~
indescions_2017
There's a common refrain you'll hear among Gophers. It goes something like: "I
just wrote a 150+ line mind dump. And it successfully built on the first try.
No errors. That's never happened before!" So stick with it. It's designed for
that level of productivity ;)

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.

~~~
Jemaclus
I picked up "Concurrency in Go"
([http://amzn.to/2xiGSmi](http://amzn.to/2xiGSmi)) a few weeks ago. Total game
changer on the concurrency part. It totally explains the whole model with a
ton of examples and concurrency patterns. I'm still wrapping my head around a
lot of it, but my day job code has improved significantly since even my first
pass through the book. Highly recommend.

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.

------
twobyfour
Erlang's syntax. Ouch.

~~~
deathtrader666
There's Elixir for that..

~~~
twobyfour
Unless you're working on a project already written in Erlang.

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?

