4 ms·
If I wanted a typed language I would use Java. Dynamic languages allow me to get the job done faster. It is extremely rare that I run into any issues regardin
by bcheung 12y ago
If I wanted a typed language I would use Java. Dynamic languages allow me to get the job done faster. It is extremely rare that I run into any issues regarding type. Every typed / object oriented language I have used so far forces me to jump through hoops to get at my data and I find myself needing to create way too many objects. I want to work with data, not objects, not types.
Parsing JSON to a hash is especially problematic in typed languages. Often they force you to create a class that maps from the JSON to a class. This is extremely tedious and wastes time. Also, if the JSON can change dynamically then you are screwed as it can't be mapped to a class anymore.
If you want type safety there are plenty of means to do this in a language that compiles to Javascript or some kind of linting step.
Please don't turn Javascript into Java.
- Bahamut 12y agoWhat if the typing was optional?
- bcheung 12y agoI'm down for that.
- seasoup 12y agoI'm still not, it's adding complexity in exchange for performance. I prefer ease of use of the language over performance, JavaScript is fast enough for most things and is still getting faster without adding complexity for programmers.
- enobrev 12y agoThat's what I loved about the [basically] now-deceased Actionscript 3 [1]. It was an optionally typed Javascript with compile-time and runtime checking, packages, and namespaces. It was an absolute pleasure to code with. I would generally start my prototypes untyped to get something running quickly as a throwaway, and then rewrite strictly typed as I better understood the problem. I was very happy to ditch Flash years ago, but I would have loved to have AS3 replace Javascript. 1: http://en.wikipedia.org/wiki/ActionScript#ActionScript_3.0 http://en.wikipedia.org/wiki/ActionScript#ActionScript_3.0
- detaro 12y agoHave you ever tried OCaml?
- olavk 12y agoThey are suggesting adding optional explicit typing to JavaScript. This will not impede your ability to use untyped dynamic JSON. But it allows you to take advantage of explicit typing where it adds value.
- paganel 12y ago> Please don't turn Javascript into Java. I'm not the best programmer out-there but when I started learning Python this blog-post had a pretty big effect on me: "Python Is Not Java" (http://dirtsimple.org/2004/12/python-is-not-java.html http://dirtsimple.org/2004/12/python-is-not-java.html) , I remember referencing it in one of my first job interviews and actually getting hired. It may sound crazy to a lot of people in here from this day and age when types are all the rage, but there was a time not that long ago when dynamic languages came as a huge (I mean huge) breath of fresh air. Without languages like PHP, Ruby, Python and JavaScript we wouldn't probably have this conversation in here, but on an ASP- or Struts-based forum thingie that would cost money to join and would be filled with horrendous ads (think ExpertsExchange or whatever the name of that website was).
- olavk 12y agoDynamic languages was a breath of fresh air compared to the clunky explicit typing of Java. The first versions of Java didn't even have generic, so just using collections required lots of explicit casting to make the compiler happy for little benefit. But today the breath of fresh air is powerful type systems and type inference which provides the benefit of typing without the syntactic overhead.
- ahoge 12y agoPlease don't dismiss optional typing without trying it first. Even if you don't add any type annotations yourself, you'll still benefit from the annotated libraries and from type inference. To get almost all of the tooling benefits, you only have to annotate arguments and the return value. That's it. Inside your functions you generally can omit them because there are enough types floating around. Literals have a type and if you call an annotated function, you also know what type you get back. E.g. this function is fully typed (none of the variables is purple): http://i.imgur.com/xHWlJVn.png http://i.imgur.com/xHWlJVn.png
- bcheung 12y agoI'm not dismissing optional typing at all. I'm completely for that. I have used it in JS when performance is needed when dealing with large data sets. It's forced static typing that I am against.
- olavk 12y agoWhy are you talking about forced static typing when the presentation is talking about optional typing?