5 ms·
Automatic type conversion I think is a mistake. It’s a huge cause for bugs. But even if not, automatic string to number parsing is definitely not something I wa
by dkersten 7y ago
Automatic type conversion I think is a mistake. It’s a huge cause for bugs. But even if not, automatic string to number parsing is definitely not something I want in my production code. Not only is it something that causes hard to debug errors, if in a tight loop, it can have big performance impact. There’s a reason modern languages have become stricter on type conversation, instead of less strict. This language looks cool, but I will never use it for this reason.
- noobermin 7y agoI might cause a flame here, but I feel like academics and people who give conference talks have adopted stricter typed languages. Actual developers instead embraced from the get-go rather dynamic languages (Python,Javascript,etc.) and continue to use such languages without the type hints because it's easy and they have things to build.
- em-bee 7y agodynamic languages still have strong typing. the given example of type conversion is one of weak typing. it has nothing to do with strict typing that enforces type declarations. in python this is an error: >>> i = 10 >>> s = "20" >>> s+=i; TypeError: cannot concatenate 'str' and 'int' objects >>> i+=s; TypeError: unsupported operand type(s) for +=: 'int' and 'str'
- willtim 7y agoIt's a nice error message, but it's a runtime error, it might not happen until weeks into production. It's technically just a crash with a useful error message. "strict typing that enforces type declarations" is generally called static typing, and does not necessarily always require annotations or declarations. It spots such errors at compile time using static analysis.
- F-0X 7y ago> it might not happen until weeks into production. It should never happen in production - there should be a test that proves this.
- em-bee 7y agowith declarative or static typing i don't need a test for this case.
- lispm 7y agoThat's where a dynamically typed language with optional typing gets handy, when a compiler supports it... In Common Lisp, the SBCL compiler would be such an example: * (defun foo () (let ((i 10) (s "20")) (concatenate 'string s i))) ; in: DEFUN FOO ; (CONCATENATE 'STRING S I) ; ; caught WARNING: ; Derived type of I is ; (VALUES (INTEGER 10 10) &OPTIONAL), ; conflicting with its asserted type ; SEQUENCE. ; See also: ; The SBCL Manual, Node "Handling of Types" ; ; compilation unit finished ; caught 1 WARNING condition FOO *
- willtim 7y agoTo quote Dijkstra, testing shows the presence, not the absence of bugs. If you want to actually prove the absence of these classes of bugs then you need a static type system.
- em-bee 7y agocorrect, and i am a fan of that too, but the poster above was conflating weak typing with dynamic typing, which are entirely different things. my preferred language is pike, which is a strong and declarative typed language (declarative typing is the term i prefer since not everyone defines static typing the same way, and some statically typed languages are weak, like this example here) pike does catch type errors at compile time, but behaves like a strong dynamic typed language at runtime. i understand that python and rubys optional types now allow for something similar.
- colatkinson 7y agoIME dynamic typing is super easy and fast until it suddenly isn't. Then you're going through ten layers of functions to check if None is a valid value for some parameter because some intern three years ago figured that would be the easiest way to do it. I'd say that while there's certainly a ton of purely dynamically-typed code out there, there's also a current reversal of the trend, with static and gradual typing coming back in vogue. Python has fully-supported type annotations, and Typescript is the trendy new way of writing JS. Facebook has ReasonML and Hack/PHP 7. Go and Rust, the current "cool kid" languages, are fully statically typed. I think that the bad taste left in people's mouths by "enterprise" Java and its 30-character type names is fading, and that we'll see a few years of static types. Then of course the cycle will repeat itself, as is tradition.
- dkersten 7y agoMy favourite language is Clojure, but this exact thing leaves a bad taste sometimes. Clojure has the attitude that you should validate on the edges, using spec or similar, and then have dynamic types in between. This is really super convenient! However, as the codebase grows, subtle type errors do slip through and it gets rather hard to catch, since its now a runtime error that may not happen until a long time later (and then Clojure's notoriously bad error messages certainly don't help). So you hope your test suite catches it. Luckily, with generative property-based testing, which Clojure has reasonable support for, this can often get caught early, but during tests is still not as early as with a type checker and generative tests could still take a very long time to catch subtle issues (but it catches a lot more than just type errors!). Of course, Clojure also encourages developing in the REPL, so most of the time, you can be pretty confident that it will work before you even run the tests. Still, I feel like some kind of static typed Clojure (not a separate thing like Typed Clojure, which is slow and clunky, but something with first-class static type checking as part of the language) would be awesome. Maybe in reality it would conflict with many of Clojure's other niceties though.
- haolez 7y agoI’ve just started a project in Go coming from Python and I don’t feel less productive. In fact, I’m digging Go’s decoupling mechanisms when you use interfaces “as intended”. I might get more productive in Go rather than Python soon.
- gigatexal 7y agowelcome to the fold. Python -> Go dev here and what a refreshing change of pace strong types and a super opinionated language are.
- tempguy9999 7y agoAs a dev and not an academic, I totally disagree. "dynamic languages" sounds more Kewl than static (well, it's dynamic, innit, it's probably got fundamental synergisms too) but they are a bitch to work with when things get large unless you get really disciplined, and in less careful hands you get bugs. Lisp lovers say it works for them and I won't argue as I've no experience, but in such langs I've used (python, SQL, javascript, VB), well, the road to hell is warm and inviting, especially for the less experienced. I'm saying this as an experienced dev, please consider from this and others that you may be wrong, and avoid the trouble we've had. Or not. Everyone has to find their own way.
- dkersten 7y agoSure, less strict languages have more production use, but they’re typically older too. That doesn’t mean that conversion bugs aren’t a problem or aren’t hard to find, just that the burden is pushed onto the test suite.
- Chris2048 7y ago> and continue to use such languages without the type hints because it's easy and they have things to build I continue to use python without type-hints because of know of no other similar languages with type-hints that are as popular.
- TulliusCicero 7y agoIt's common for especially bigger companies that use JavaScript to use some framework that mandates static typing. This is true here at Google, for example.
- clauderoux 7y agoI have been working for years in the NLP and one of my main difficulties during all these years (I will not give any figures, some may think that I belong to a species that has long since disappeared: -) ) was the preparation of the corpora. The corpora are big dirty vicious beasts full of mistakes and traps. The first problem I encountered was the mixing of encodings where a piece of UTF8 mixes with some LATIN leftovers. Tamgu provides quite sophisticated means to solve this problem. The second problem was the parsing of the files to extract the relevant information. That's when I made the decision to offer automatic conversion elements. On the other hand, it should be noted that Tamgu is a typed language and that the interpretation of an object is done in context. When I write: string s = 10; s += 20; What I define is an operation within a string. The context is defined by the recipient variable. In the same way: int i = 20; i += "30"; The variable "i" defines an integer context and therefore string 30 is considered in this case as a number.
- zimbatm 7y agoAutomatic conversion hides type mismatches in all the program, even the parts that are not concerned with input validation and cleanup. So that makes static typing a bit less useful. As a source code reader I would much prefer to see at least a keyword or function call to make the casting explicit. string s = cast 10; s += cast 20; (I had the same reaction as the parent and think the language looks really cool otherwise)
- clauderoux 7y agoThank you for your comments. Actually, it is possible in Tamgu to have an explicit cast: i = int(s)+10; Each type can be used as a "function" to create the object you like, which is basically what a cast is...
- dkersten 7y agoI get that you made it to scratch an itch you had and solve a problem you had with other languages and that's cool, but as an external person looking in, who doesn't have that exact itch, its not for me, despite the rest of the language really looking quite awesome, because for the kind of code I'm writing, this seems like it will cause a lot more frustrating bugs than convenience. I don't deal with a lot of ad-hoc data, but even when I do, that data usually needs strict validation, as it tends to not be very clean. Having things silently convert hides this and while it may make the code simpler, that code should have validation anyway, so it really won't be any more work in the long run (for me). Slight errors in data cause billion dollar bugs, after all. Maybe not in NLP though, so, again, we have different use cases. But that's just me and obviously my priorities differ from yours. In any case, congratulations on building this, that's quite an achievement.