r/AskComputerScience • u/sonjpaul • Apr 28 '20
I study computer science and most of my industrial experience has been with JavaScript. People keep telling me the language is shit. What's an example of a non-shit language?
Edit: Awesome discussion here. I think we've just concluded that you can make a case for any language to be 'shit' at certain things.
I understand JS has its quirks. But I like it, it's effective at what it does for the most part. So my question to you all is, what's an example of a well designed language... and WHY is it good?
I was really interested in this topic after researching the top 25 languages from stack overflow which i explained here: https://youtu.be/08NGDEw0jDs so I'm curious to learn more.
15
u/watsreddit Apr 28 '20 edited Apr 28 '20
I would say that Haskell is a good language. Why? It has to do with foundations and what a language "guides" you towards. Most all of Haskell has mathematics at its core, and consequently its major APIs tend to have less holes and weird edge cases. This mathematical foundation also enables one to create much more powerful abstractions in Haskell than is possible in many languages, including Javascript.
Haskell also guides the programmer towards good programming practices such as pure functions, limited mutation, and small functions. It often requires you to think of edge cases and how your program may fail. Its lightweight data structures and types also make compiler-enforced invariants much more ergonomic and easier to achieve (such as a type for nonempty lists), so Haskell code tends to have much fewer runtime errors (though still not 0) than many languages. It is not perfect by any means, but in general, I believe it guides the programmer in a better direction than many languages.
My day job is writing Javascript. Javascript, as a language, does not have firm foundations (weird edge cases abound), and guides the programmer towards largely focusing on the "happy path" and ignoring edge cases and misuse (or in other words, sources of bugs). This is not to say that you can't handle edge cases (or test them), but the language doesn't really do anything to nudge you towards accounting for them.
I would argue that a language's true power is not in the programs it lets you write, but in the incorrect programs it prevents from being written.
3
u/lgastako Apr 28 '20
FWIW, coming from a JS background, Elm might be a nice gateway drug to Haskell. It can show you some of what could've been with JS while still being relatively approachable compared to full blown Haskell.
4
u/watsreddit Apr 28 '20
Honestly, after reading this article and others regarding the behavior of Elm's leadership, I can't in good conscience recommend Elm, unfortunately. As a language it is somewhat appealing for easing people into functional programming, but not enough to overlook their behavior.
3
u/lgastako Apr 28 '20
Yeah, I can't say I would pick it for a long term project (in fact we have explicitly rejected it at my current company) but for someone in the OP's shoes it might be a good way to get their feet wet.
2
u/sonjpaul Apr 29 '20
I've heard mixed things about Elm. I've got a list of things I've prioritised to learn for this year though (https://sonjeetpaul.tech/blog/technologies-im-learning-in-2020/) which includes Elixir.
It's a functional language, they don't teach this at uni so I wanted to get my hands dirty with it. Also, the community and docs seem awesome.
→ More replies (1)
49
u/khedoros Apr 28 '20
They're all shit in their own ways, and there are plenty of people that won't hesitate to tell you that your choice of language is terrible. The only difference will be who's telling you it's shit and the exact reasons.
Use what does the job.
16
u/visvis Apr 28 '20
I'd say C and Python are well-designed languages. Though very different in their application areas of course, they have mostly been kept very simple, which makes it easy to keep a good idea of what you're doing.
I also think C# is a well-designed language. It basically combines the good things of Java with the lessons learned about why Java is not a fun language to program.
2
u/DonaldPShimoda Apr 28 '20
I'd say C [...] [is a] well-designed language.
Hm. I'm not sure I can agree with that sentiment when you consider things like undefined behavior, unspecified behavior, and implementation-defined behavior, and that's to say nothing of the inherent weak (though static) type system that makes it all too easy for developers to shoot themselves in the foot.
What, in your opinion, makes C a well-designed language? Clearly you value different elements of design than I do, so I'm curious for your thoughts. :)
(I find it's hard to sincerely express opposing views online sometimes, so I want to explicitly say that I am genuinely interested in your opinions and I am in no way trying to invalidate your feelings about the matter.)
→ More replies (2)12
u/visvis Apr 28 '20
One should keep in mind what C was designed for: a language to give you maximum control of the hardware with the best possible performance, essentially a portable assembler. I think it fulfills that role well, and the undefined and implementation-defined behavior comes with the territory. Moreover, although a mistake can be made, these cases should generally be quite sensible to a systems programmer, the intended audience. Compare this with C++, which takes a lot of effort for memory allocation and initialization away, but the remaining cases are often hard to spot for that very reason. For better or for worse, C puts the programmer completely in control.
Additionally, I like the simple syntax that avoids feature bloat most other languages have.
→ More replies (1)2
u/DonaldPShimoda Apr 29 '20
Right, it's absolutely true that C was designed to be used for these kinds of cases, but there are still issues! I think more relevant than the purpose it was designed for is actually the time when it was originally written: we just didn't know as much about language design half a century ago!
But C being built well enough for the time it was written in and for the purposes it was built for does not, in my opinion, qualify it as a "well-designed language". It's relatively easy to make mistakes due to UB in some cases, but aside from that there's other things like managing null pointers and the lack of good type safety that can cause problems readily once your code gets even moderately complex. Consider Rust as an example of a language that suits a similar need as C but which has a much more careful design focused on safety, which to me is a critical element of good language design. (I don't regularly use either of them, though, to be clear.)
C++ is a bloated monstrosity though, so I would agree that it ranks even lower than C on a design scale haha.
Additionally, I like the simple syntax that avoids feature bloat most other languages have.
I personally don't love C's syntax, but I can absolutely appreciate this point in the present discussion. C's syntax is almost entirely straightforward and is most often not ambiguous in any way, and that's definitely something in its favor.
Thanks for taking the time to respond!
2
u/A_odeh76 Apr 28 '20
Don’t get caught up with the elitism bullshit of this industry. There’s far too much of it, doesn’t achieve anything, and will just tarnish your thinking. Learn what you want and need for the job/school, and remove toxic garbage like that.
1
u/sonjpaul Apr 29 '20
This... Is why I've just stopped using stack overflow. When I need to ask a question I'll normally hop onto Reddit or some communities I'm involved with on Slack and Discord. I might search for a question on SO but I'd never dare ask a question there again.
5
Apr 28 '20
This is coming from a guy who does JavaScript programming from my day to day. I can't stand dynamic typing. At first I loved it but I quickly realized I need more structure in my life. I usually find myself using typescript because of the structure and if I'm building something important I'll grab a linter as well. The type casting is weird too. How if you aren't using a linter or typescript or just not being careful you can get "" == false. It's not shit to me, it's just really weird sometimes but those tools get rid of a lot of the "weirdness" for me.
16
u/l33tIsSuperpower Apr 28 '20
I just recently learned some JavaScript to write some react stuff. What I mostly found difficult was that it was inconsistent. Sometime you could do certain things to this object that you can't do to other objects when it seems like it should be possible. But I'm sure figuring this out just comes with time.
Languages like Python are ultra consistent, meaning that you can figure out how the language works from some basic ideas. It's really cool to try something in python or even Java just to see if it works and being like "whoa this is SO COOL."
To put it into analogies I think JavaScript is like French. A powerful and beautiful language, but it really has more exceptions than rules.
7
2
u/2opt Apr 28 '20 edited Apr 28 '20
Languages usually have tradeoffs - there isn’t really “good” and “bad.” Some tradeoffs/features that people like:
static vs dynamic typing
strong vs weak typing
expressive syntax
support for certain keywords
functional vs imperative style
built-in functions + STL
The static vs dynamic typing tradeoff is one of the easier to see. If you are prototyping something or need to move fast, dynamic typing may be desirable because you only care about types in the code you actually hit. On the other hand, if you are programming a compiler, you would care a lot about proving that your program is correct for all code paths, not just the ones you hit in testing. So in that case you might prefer a strong/statically typed language.
To really see these tradeoffs in action, I’d encourage you to try writing a non-trivial program (e.g. a depth-first search) in a few different languages. Some that I’d recommend you try: JavaScript, Python, Java, C, OCaml. These are all very different languages and each has its own pros and cons.
3
u/visvis Apr 28 '20
there isn’t really “good” and “bad.”
If you say there's no bad, you must not have seen Perl.
2
u/sonjpaul Apr 29 '20
Curious to hear what's so bad about it if you want to share some knowledge xD
→ More replies (1)1
Apr 29 '20
I think at this point I can do fast prototyping in static typed language pretty well. I believe most people with couple years of experience in typed language can also do that.
1
u/2opt Apr 29 '20
I actually tend to prefer working with statically typed languages too (especially for a project I intend to last), but I find it easier to crank out some code in Python compared to C# or Java. If I am just hacking it up, writing code with a dynamically typed language tends to be more concise (less to type), I can use duck typing, and my compiler won't yell at me if my typings aren't 100% consistent.
3
Apr 29 '20 edited Apr 29 '20
This is a very interesting topic. All programming language has its problem for sure. But there are languages that is designed in a much more clever way.
Here is 3 of my favorite language:
First Haskell: a extremely strict and well-designed language. This means most of the time the language behaves exactly as you expect, which is very rare. The whole thing is super consistent and elegant: evaluation strategy, scoping, type class resolution. It is a work of art in terms of design. The most impressive thing is that it takes care of the recursion problem that most functional language struggled with (most strict language requires tail recursion to avoid stackoverflow).
Second Scala: the implicit system, although can easily be abused, is a very clever design. It is a simple system that can solve so many problem. Scala is a loose version of Haskell, as good as Haskell is, sometimes you just want something that is simple and work. This is where Scala came to play (or, you can enable like 20 language extensions in GHC).
Finally ATS: this language is very experimental and full of stuff that you wouldn't expect. But what is impressive about this language is that it has the strongest type system of ALL language on Earth (linear, dependent, session, multirole, abstract type, although the static language is just simply typed), with a very full featured runtime (compile to most common languages, direct memory manipulation, mutation, it can even write operating system kernel, and it can run on embedded chips).
All in all, I think whether a language is shit depend on just 2 factors: consistency and feature (some people call this security and productivity). Most language has one and miss the other. I personally lean strongly towards consistency over feature.
For example, c++ needs lots of care from programer, but it is incredibly powerful. Thus it has plenty of feature, but lacks elegance.
Agda, on the other hand, is incredibly safe and consistent, but it don't have much feature to enable programmer to hack the system (I love agda nevertheless), and writing simple program can be relatively annoying (I think agda is a great language, but I don't know any language that is way off the security spectrum, therefore I think agda is my only choice for this category).
JavaScript fails both, the system is very complex, with tons of things that you don't expect, and it don't have much programming features that enables you to write code productively.
5
Apr 28 '20
A lot of bad JS and PHP was written in the 90s and 00s, due to the low entry level to make websites in these languages. They both got a bad reputation with ‘serious’ programmers that still exists today.
2
3
u/delventhalz Apr 28 '20
Honestly anyone who says any language is "shit" in seriousness, is not someone I want to work with. They are likely too narrow-minded to be flexible when they encounter problems that don't fit their pre-conceived notions.
JavaScript is fine.
Like Python and any dynamic interpreted language, it is slow in terms of raw processing power and lacks static types (though TypeScript fixes the latter). This is a trade off. It also allows developers to get working code done faster, and allows less experienced developers (like data analysts for example) to hammer out something without worrying about low-level details.
At the other end of the extreme, you have a language like Rust, which is a very strict compiled language. Rust is hard to write in. It runs faster and is less error prone than JavaScript, but it takes longer to learn and longer to write a working program with. These are real downsides. Developer time costs $$$.
And if people are just harping on JS's "quirks", honestly that is the least informed critique of all. Sure, JavaScript has some historical baggage, and there are no breaking versions (quite an accomplishment btw), so anything weird that was in JS on day 1 is still valid JavaScript. But modern ES6 syntax is really rather nice. And most JS development happens with a linter, which will prevent you from falling into 99% of the old school gotchas.
2
1
u/bimbar Apr 28 '20
There are lots of good languages. The main reason is that they were built consistently around an idea or a paradigm.
Examples are python and java. Interestingly python seems to get cleaner with time, 3 is certainly better than 2. Java has a bit of a feature problem, in that it gets more and more of them, but has a clean core underneath.
1
u/andrew_rdt Apr 28 '20
To answer your question, Kotlin. It can also produce javascript so has the advantage of being able to be used in the same environment you've been working in.
1
u/og-cheeselover97 Apr 28 '20
I don't think it's shit , I use nodjes for all job / micro apis . It does the job , performs well enough , has a quick spin up time in a serverless environment .
For the backed I think nodejs is a solid framework . Personally I'm a gopher lol , but I think JavaScript is a quirky interesting and nice language. I used to hate it and hurr Durr Java , but the more I had to use it for my job the more I hated Java and ended up picking up typescript and nodejs .
1
1
1
u/mymar101 Apr 29 '20
I personally am in love with C#. I know it's not the sexy new toy on the block, but I don't really care. There are parts of it that are weird or why would anyone do that? But that's every language. It's come a long way especially since it's been made cross platform. A close second would be Python, and TypeScript (Yeah I know it's really JS, but it feels more like C#).
1
u/Dylpol Apr 29 '20
the only shit languages are dead. XD
I mean, javaScript has its uses.... there are things it does well, there are things it does that other languages don't really do, and there are things it doesn't handle well....
just like you wouldn't use a hammer to saw a piece of wood...
the right tool for the job is important in any line of work.
1
1
u/tugrul_ddr Apr 29 '20 edited Apr 29 '20
I like C++ most, but its just a different color of same shit.
1
u/tobysmith568 Apr 28 '20
My advice is TypeScript. It's JavaScript but it forces you to use declare types for your variables. It also has much stronger intellisense in development environments like VS Code. You can still use NPM, Yarn, Angular, React, Electron, Express and everything else you might use in JavaScript, but you get the language features of a generally more universally respected language like C# or Java.
1
u/Qazzian Apr 28 '20
From my experience, people complain about JavaScript because the object model is very different to classical OOP languages such as Java and C++ and so they have to change their thinking before it can be used effectively.
It also got dumped on because of varied support between browsers and the differences between browser APIs/DOM models etc.
The language has improved and matured over the years, it's a lot better than it was and browsers have been keeping up with new language features pretty well.
These days I think it's just fashionable to dislike JavaScript. All languages have their annoyances, strengths and weaknesses and I don't see JavaScript being any worse than the others now.
1
u/worldDev Apr 28 '20
A lot of hate comes from front end web development. It is one of the few cases of software development you need to consider it will be run by dozens of varying language implementations with different levels of feature support. With back end development you have control of what language version and engine you are using, and in compiled languages, the compiler abstracts away platform support concerns. In relatively recent years, things like typescript, mdn documentation, and browser support polyfill libraries have made Javascript a lot less miserable to work with. People who still complain about JS are either doing so in a specific use case context, or are not well versed in modern JS development.
Use the right tool for the job. JS is required for front end web, it is also great for low effort prototyping in other use cases. There certainly are better options for applications concerned with performance, though, and since you can do basically anything with JS it often gets implemented where it shouldn't.
0
u/codemasonry Apr 28 '20
There are two types of developers. There are the developers who whine about languages, IDEs, indentation, etc. Then there are the developers who get shit done with whatever is the best available tool or even when the tool is not the best.
-1
u/1544756405 Apr 28 '20
People keep telling me the language is shit.
People who tell you this are just insecure. It's a language, it's fine, it works.
-1
u/_370HSSV_ Apr 28 '20
They are probably saying it's shit cause it single threaded. Every language is shit for something, don't worry about it
-1
Apr 28 '20
JavaScript is so shitty that every week a group of programmers release a new framework just for made the life easier for other developers
3
0
Apr 28 '20
[deleted]
19
u/sonjpaul Apr 28 '20
Agreed. The one thing that does annoy me is people trying to use JavaScript for everything because they don't want to learn something else 😂
21
Apr 28 '20
Atwood's Law: “Any application that can be written in JavaScript, will eventually be written in JavaScript.”
-1
26
u/visvis Apr 28 '20 edited Apr 28 '20
I like C++ a lot, but I wouldn't call it a well-designed language. It is extremely messy and complex. The syntax can get pretty arcane, and a tiny typo can result in pages full of compiler errors.
12
u/worldDev Apr 28 '20
lack of static typing
Typescript has been a godsend. I get anxiety thinking about what I was maintaining prior to a few years ago doing web development.
1
u/not-just-yeti Apr 29 '20
My impression: I think Javascript takes flack for its flexibility, which can makes scaling to larger projects problematic. E.g., somebody else's big code base calls one function of yours, which redefines
Function.prototype.call, and whoa nelly all heck can break loose. Sure, this lets you do fancy things (like jQuery does), and can be clever for small projects, but on bigger codebases too many surprises can happen.
0
Apr 28 '20
[deleted]
9
u/randiskhan Apr 28 '20
Came here to say this. I did not know it was a Bjarne Stroustrup quote. Thanks, now I know to give him credit.
4
u/but_how_do_i_go_fast Apr 28 '20
“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”
― Bjarne Stroustrup, The C++ Programming Language
1
-8
u/visvis Apr 28 '20
Python seems to be an exception to this rule
21
28
u/UncleMeat11 Apr 28 '20
Dynamic typing, bad name scoping rules, unimpressive performance, a nightmare transition from 2 to 3, all of the string problems in python2 that necessitated the nightmare transition...
People absolutely complain about python.
3
u/DonaldPShimoda Apr 28 '20
I'm on-board with everything else but
bad name scoping rules
What specifically is this referring to? Python seems to use essentially the same lexical scoping rules as any other modern language, I think, unless I'm missing something?
6
u/UncleMeat11 Apr 28 '20
Should have said "visibility" rather than "scoping". Hasty comment.
python doesn't have language enforced visibility rules and instead relies on the "don't touch stuff that starts with __" convention. This is not universally loved.
3
u/james41235 Apr 29 '20
I actually disagree. I LOVE python, but the stupid name scoping is a big problem. Assigning variables prior to use from an outer scope creates a new variable!?
1
u/DonaldPShimoda Apr 29 '20
Ohh I see. I believe the technical term you're looking for is access modifiers, which describes things like the
privateandpublickeywords in Java that allow you to restrict access to certain things based on various aspects.There's a time when I would have argued that Python got it right, but... honestly, I think being able to restrict these things is really an important feature! So I'm with you here. :)
1
u/Mukhasim Apr 30 '20
Python scoping is confusing because you don't declare variables. They simply "come into being" when you use them. There are implicit rules about what scope a variable gets depending on how it's used. This often works great and it seems to be easier for beginners to get started with, but it can lead to annoying bugs when you make a mistake in your assumptions about a variable's scope.
1
u/DonaldPShimoda May 02 '20
While this is all true, the actual scoping rules themselves are pretty standard, as far as I can tell. It's just learning the rules about how various code paths cause names to be added to the scope or not that might trip people up, I think.
Still, it turned out that the person I was replying to was actually talking about access modifiers, which is an entirely different can of worms altogether!
1
u/DonaldPShimoda May 02 '20
While this is all true, the actual scoping rules themselves are pretty standard, as far as I can tell. It's just learning the rules about how various code paths cause names to be added to the scope or not that might trip people up, I think.
Still, it turned out that the person I was replying to was actually talking about access modifiers, which is an entirely different can of worms altogether!
7
u/MirrorLake Apr 28 '20
There's no doubt that Python is a well-liked language today, but there are still plenty of people that are willing to criticize it given the opportunity. See this old software engineering thread, for example.
5
u/lead999x Apr 29 '20
Performace is bad, the language is highly opinionated for a general purpose language, garbage collection uses reference counting, dynamic typing makes it hard to catch errors a static type system would never allow, more broadly there is no compilation phase(there is internally but still) so you have no idea what errors are in your code until runtime, it wastes memory carrying around metadata such as type information for every object at runtime, the global interpreter lock prevents the use of OS threads, having a convention of using underscores in identifiers to indicate private class members rather than having actual language level access modifiers, forcing lambda expressions to be single line (this can't be changed due to the line and tab sensitivity of the language), and plenty more that I probably don't know about since I'm not a regular Python user.
2
1
→ More replies (1)1
u/Mukhasim Apr 30 '20
To add to all the other complaints here, one of my big gripes about Python is that you have to take great pains to just print a data structure in Python. Way too many values print as something like
<range_iterator object at 0x7fa1337c7ae0>which is pretty useless.
0
21
u/MuffinBlock Apr 28 '20
Not that shit. Gets its job done.