7 ms·
While I see a lot of examples of 1), I can't think of one for 2). Which successful statically-typed language has that?
by dudul 8y ago
While I see a lot of examples of 1), I can't think of one for 2). Which successful statically-typed language has that?
- cx1000 8y agoC and C++ are the basis for Python (CPython) and JavaScript, respectively. Lua was written in C.
- philwelch 8y agoLua is an example for the C-type languages, and Groovy is an example for Java.
- vorg 8y agoBeanshell is another example for Java, and did it before Apache Groovy did. Beanshell added features like optional typing and terse property syntax to Java, then Groovy extended Beanshell by adding closures to Java. Java has made these scripting languages less relevant lately because of more recent features like lambdas and inferred types.
- outworlder 8y agoI can't think of 2 as written. But big, successful programs will often do (2).
- naasking 8y agoC# has had a dynamic type built in for years now. It's literally a dynamically typed language embedded within the statically typed C#,which grew out of the work on gradual type systems.
- pjmlp 8y agodynamic is just based on COM variant type, before .NET even existed.
- naasking 8y agoC#'s dynamic type has nothing to do with COM.
- pjmlp 8y agoIt shows you never had to implement COM interfaces for Visual Basic Variant type via the IDispatch interface. https://msdn.microsoft.com/en-us/library/windows/desktop/ms221608(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms2... The way dynamic is implemented is exactly following the same idea using DynamicObject instead of IDispatch. https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicobject?view=netframework-4.7.2 https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.d... And if you actually bother to read MSDN documentation, one of the use cases for dynamic was to simplify COM automation interop. https://blogs.msdn.microsoft.com/srivatsn/2008/02/04/dynamic-dispatch-in-c/ https://blogs.msdn.microsoft.com/srivatsn/2008/02/04/dynamic... https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/dynamic https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...
- naasking 8y agoThat's not why the dynamic type was created, that was just one side benefit. The dynamic type grew out of the IronPython effort which grew into the DLR in order to better support dynamically typed languages on the CLR, by having reusable polymorphic inline caching for efficient dispatch. COM integration with the CLR has existed since the beginning, which I used quite extensively many years ago, they just took advantage of the DLR to make it easier.
- kentosi 8y agoThough more "inferred" types rather than dynamic types, scala does allow you to do: val s = "String" Rather than the more strict: val s:String = "String"
- dudul 8y agoType inference has nothing to do with dynamic typing.
- kentosi 8y agoI had no idea what you were talking about, so I did my own research (ie - googled "type inference vs dynamic typing") and I stand corrected. https://herbsutter.com/2008/06/20/type-inference-vs-staticdynamic-typing/ https://herbsutter.com/2008/06/20/type-inference-vs-staticdy...
- hellofunk 8y agoMaybe not languages but certainly frameworks, like Qt and many others, offer a dynamic language layer on top of the C++ or other static language.
- munificent 8y agoFor 2, I should have said "programs written in statically-typed languages". Oops. Examples are most text editors: emacs (elisp), Sublime Text (Python), Vim (VimScript), Atom (JavaScript). Many games and game engines: World of WarCraft (Lua), Unreal (UnrealScript), SCUMM, etc.
- weberc2 8y agoI'm guessing you meant these hypotheses to seem paradoxical (i.e., dynamic code bases are rewritten in static languages to improve maintainability; static code bases are rewritten in dynamic languages to improve maintainability), but I don't think they are. Dynamic codebases are rewritten in static languages to improve maintainability and code quality; programs written in static languages include an interpreter as a feature that supports user-defined programs, e.g., a browser's JS engine or emac's text editor and also for specialty domains where code quality is less important than developer velocity and the static language of choice is unnecessarily painful (games). Assuming I didn't misrepresent your thesis, does this seem more or less accurate to you?
- munificent 8y agoNo, I actually didn't intend them to be paradoxical. My feeling is that statically-typed languages and dynamically-typed languages are each better suited for certain kinds of problems. The former gives you better performance, long-term maintainability, and scales to larger programs. The latter gives you a faster iteration loop, is easier to learn, and is easier to dynamically load. I think what happens is that any sufficiently large program covers so many different requirements that eventually different parts of the program are best implemented in different styles of language. If you start statically-typed, you eventually get bogged down by the slow compile-reload cycle, need to dynamically load user-defined code, or what to express parts of the program in something higher level or more declarative. So you end up embedding a scripting or configuration language. If you start dynamically-typed, eventually your program grows to the point that you either can't maintain it or it isn't fast enough, so you end up trying to bolt a type system onto your existing code or rewriting parts of it in a statically-typed language. I think the costs for the latter are usually higher than the costs for the former, so I tend to lean towards starting statically-typed, but that's also because I'm comfortable using types.
- deleted 8y ago[deleted]
- cgdub 8y agoC++ and JavaScript in the browser that you're using to read this would be a good example of #2.
- NegativeLatency 8y agoC# `var` syntax, ExpandoObject and the rest of System.Dynamic
- umanwizard 8y agoC# `var` variables are statically-typed, not dynamically. Not having to write down the type isn't the same as the type not being determined at compile time, which is what "static" means.
- NegativeLatency 8y agoJava, ScriptEngineManager https://docs.oracle.com/javase/7/docs/api/javax/script/ScriptEngineManager.html https://docs.oracle.com/javase/7/docs/api/javax/script/Scrip...