5 ms·
And it's likely the static vs dynamic programming debate has been around longer than you coding ;).
by wasd 10y ago
And it's likely the static vs dynamic programming debate has been around longer than you coding ;).
- deleted 10y ago[deleted]
- hota_mazi 10y agoDefinitely. And it's going to be around for a long time, but just because a debate perdures doesn't mean both sides have an equal claim to the truth. After all, there are still a lot of people who think creationism should be taught in school next to evolution.
- alexssung 10y agoComparing dynamic and static programming to creationism and evolution is passive-aggressively condescending and only weakens your credibility
- hota_mazi 10y agoIt's a parallel, not a comparison.
- ZenoArrow 10y agoLooking at it as objectively as you can, what advantages does dynamic typing have over static typing? The only potential candidate I can think of is 'more flexibility'. However, undefined behaviour is not a desirable trait when designing programs, and languages with static types have ways to provide polymorphic functions without unhandled behaviour (such as pattern matching on function arguments). Some may argue that dynamic languages are more readable, but there are languages with static types that are both concise and readable (Elm being a good example), so I wouldn't class that as a benefit. Some may argue that the speed of prototyping a solution is a benefit, but the time saved putting together a prototype is often negated by the time spent debugging as the prototype matures. So what advantages am I missing? There must be something that makes dynamic languages popular. What reasons are there to use a dynamically-typed language over a statically-typed one?
- barrkel 10y agoStatic types limit the expressivity of your code to what the type system is able to prove. Depending on what you're trying to do, you can spend more time arguing with the type system than getting things done. This really starts happening with a vengeance when you do increasingly lispy things, like creating dsls that move the language closer to your problem domain by writing programs that write programs. Consider e.g. the way activerecord introspects the database schema to enrich your model declarations without further work from you. Now there are ways to get similar effects in statically typed systems, but it's much more work, particularly if the dynamism comes from the execution environment (rather than compilation).
- ZenoArrow 10y agoOkay, can you give me one example of a useful macro that you'd write in a dynamically typed language. I'd like to see what challenges there are recreating it in a statically-typed language. Also, regarding activerecord, it seems you're hinting at the benefits you get from composibility, is that correct?
- phamilton 10y agoFor me, the benchmark is parsing a heterogenous data structure in JSON. For example, an array of inventory items. We get around this by shoehorning them all into a common structure, but in a dynamic language with a dynamic datastore we can store them and access them in a more native (to the problemspace) manner.
- ZenoArrow 10y agoOkay, so what problems do you see in using something like active patterns in F# for either parsing an array or a single value within a JSON structure? https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/active-patterns https://docs.microsoft.com/en-us/dotnet/articles/fsharp/lang...
- 10y ago
- dang 10y agoWe detached this subthread from https://news.ycombinator.com/item?id=13252935 https://news.ycombinator.com/item?id=13252935 and marked it off-topic.
- deleted 10y ago[deleted]