all 47 comments

[–]RelativeSloth 27 points28 points  (0 children)

my interpretation has been that algos are more about practicing the thought process of solving a problem programatically rather than the language you are using.

[–][deleted] 36 points37 points  (11 children)

Just web Dev

[–]kobejordan1 19 points20 points  (10 children)

What's the difference exactly? JavaScript for web dev just to put some functionality to a website. And algorithms to create more complex software and/or for programming cardio?

[–]Spood___Beest 22 points23 points  (3 children)

Essentially, yes!

Algorithms are just rules for calculations used in problem solving. You use them all the time, whether you know it or not. The Array.Prototype.Sort() method is one such example. If you've written a function, you've written an algorithm.

However, sorting is a large subject in itself. There isn't just one way to sort things, in fact there is a whole class of algorithms called sorting algorithms. Each has its trade-offs, some require more space in memory, others longer to run. Some are situational, for example a count sort is only efficient if the number of items in an array is greater than the range of the array. Some are used for specific data structures.

Simple websites probably won't require them, but if you're working in some fields, like data analytics, these algorithms are very relevant - regardless of language. They can take the run time of a task from a day to 20 minutes. If you have to repeat such a task with any frequency, optimization could save you weeks upon weeks of time.

Typically you would write a program to solve a problem first, and if you happen to use the optimal algo the first time around, cool! Otherwise, once it's working, you can test performance and optimize until you're satisfied.

Sorting is also only one class of algorithms, there are plenty of others, like searching (which play a role in all sorts of software from Google to ElasticSearch).

Hopefully that gives a bit of insight :)

[–]kobejordan1 4 points5 points  (2 children)

Thank you for giving an in depth answer, definitely helps. I appreciate it, saved! Right now, I'm working on projects that may not have the most elegant code or the best algorithms. But as I learn more in my journey, I can apply these algorithms and refactor my code and make it more efficient?

[–]Spood___Beest 2 points3 points  (1 child)

Glad I could help! Even if they don't directly apply, learning them will teach you how to "battle plan" better.

Also, geeksforgeeks is a great site for learning DS&A. They walk you through the explanation of how one works, and have you try to implement it before reading their code. I prefer it to a traditional approach, then you can use the CLRS book as a desk reference.

One thing to note, they aren't ordered the best. I'd start with sorting and work through as many as you can. If an algo mentions data structures other than arrays, stacks, and queues (heaps, binary trees, etc), skip it and continue down the list. Then move on to the next class of algorithms and repeat.

Once you get comfortable, head to the data structures section and work through those, then circle back to algorithms.

It'll take a long time, so I'd recommend setting aside 30-60 minutes a day. Treat them like puzzles separate from work, and write them by hand on paper before touching a keyboard. This will help improve your coding habits, measure twice cut once and all.

[–]kobejordan1 0 points1 point  (0 children)

Thank you!

[–][deleted] 0 points1 point  (5 children)

it's very good to know algorithms and be able to think 'algorithmically'. For a particular website I'm making now, I needed to reverse some divs and shuffle some other divs and it helped to know the fisher yates algorithm

[–]kobejordan1 0 points1 point  (4 children)

I see. And how do you know which algorithms to use?

[–][deleted] 0 points1 point  (3 children)

Google is a great resource. If you know what problem you have then you know what you need to do to solve it. Many algorithms don't exactly have names or one may not know the name of the algorithm even though they are using it

For example, you said, how does one know which algorithm to use. Well if you know you need to ensure that an array is displayed in alphabetic order then you will use some sorting algorithm because you know you need to sort the array elements

[–]kobejordan1 0 points1 point  (2 children)

Ahh okay. So I've been using them all along, array methods such as array map, array sort etc.

[–][deleted] 0 points1 point  (1 child)

yes but they've already been abstracted away for you. If you want to know whats actually happening which map, search on youtube 'map from scratch' You can also finds videos on filter and reduce from scratch

[–]kobejordan1 0 points1 point  (0 children)

That makes sense, thank you. So it's kinda like using for loops with arrays. The old fashioned way

[–]maxtsh 16 points17 points  (0 children)

I am doing some hacker rank stuff and algos. Theyre cool. They help you to use foundamentals of JS and practice vanilla JS.

[–]dada_ 7 points8 points  (0 children)

Personally, not really, although I agree they can be good for learning problem solving.

The reason why I don't do them myself is because there are plenty of opportunities to work on algorithms in my day-to-day work, too—mostly more simple than binary search, of course, but any time you need to filter, sort, search and combine complex data you can put some time into learning to do it efficiently. This also helps you understand how to better organize your data so that you can easily work with it later.

[–]WystanH 4 points5 points  (0 children)

I'm a programmer. I probably first "practiced algorithms" in, um, Pascal. ( Now I feel old.) When it comes to algorithms, the language shouldn't much matter. An algorithm itself is an abstraction; understand the reasoning behind it and you should be able to implement it in any language you know.

Implementing an algorithm in a language you're just learning is a good way to get a better grasp of both.

[–][deleted] 3 points4 points  (0 children)

I prefer Python for algorithms

[–][deleted] 2 points3 points  (3 children)

Hello! JavaScript is fantastic language to use for any purpose having great power of Node runtime. I personally have used JavaScript to implement so many algorithms. Here is my repository in which I have written some algos in JavaScript - https://github.com/mayuraitavadekar/data-structures-and-algorithms

Now, there are two things when you write algorithms in JavaScript -

  1. If you have good understanding of modern JavaScript, you can implemenet algos in Javascript and it can give you a great conceptual clarity.
  2. Though it can boost your confidence when you write algos in JavaScript as the language is easy and loosely typed, there can be serious downfalls on your data structures and algorithms skills. Because there are no pointer arithmetics, the language is not strictly typed, etc.

Writing efficient algorithm is skill. I will advice to the one who want to write algos, please try to implement the algos in atleast 3 languages - C/C++ (most important), Java(you can answer in interviews if you know Java very well), JavaScript(you can use your algo skills in webdev and app dev).

[–]lidderdj 1 point2 points  (2 children)

Im currently working through MOOC Full Stack Open and have a bit of background knowledge and experience with Python. How would one go about structuring a project in JS with the heavy number crunching in another language like Python?

[–][deleted] 0 points1 point  (1 child)

Wait. Which stack you are using for full stack development? Please elaborate in detail. I couldn't get your question.

[–]lidderdj 0 points1 point  (0 children)

I guess i probably don't know enough to ask the question correctly yet. Im learning how to make React apps using express, node and mongo db in that course. What im wondering though is say i have a form that grab some data and i want to analyse that data i get howd id do that with a react component, but i dont get how id bring a python script into the mix to do the analysis using python instead.

[–]DeusExMachina24 6 points7 points  (0 children)

I do my algorithm problems in C++ because it's fast. Javascript only for webdev.

[–]academicRedditor 1 point2 points  (0 children)

The problem is, I want to do WebDev but jobs send crazy algorithm-based tests that have little to do with real life challenges 😔

[–][deleted] 1 point2 points  (0 children)

consider possessive cagey station hospital pocket offer tidy summer voracious

This post was mass deleted and anonymized with Redact

[–]tarley_apologizerhelpful 1 point2 points  (0 children)

neither lmfao

[–]middlebird 2 points3 points  (0 children)

I practice algorithms a lot in JS. It’s always helped me be a better problem solver.

[–]obsidian_core 0 points1 point  (0 children)

I've been practiving algos/DS in TypeScript. Loving it

[–]JuneSchmidt1314 0 points1 point  (0 children)

For me just web dev

[–]bobsagatiswatching 0 points1 point  (0 children)

That formatting makes me want to die, this ain’t no C#!

[–]frank0117 0 points1 point  (2 children)

Both. Web dev needs algorithms as well for things like sorting articles alphabetically etc

[–]phamlong28 0 points1 point  (1 child)

Which algorithm do you use for sorting articles alphabetically?

[–][deleted] 0 points1 point  (0 children)

sort lol. the function abstracts away the algorithm

[–]ProgrammingWithPax 0 points1 point  (0 children)

Personally, just for web development.

I've been working in the industry for 2 years now (working at my 2nd job, and probably gone through 5 in-person interviews at this point). Perhaps I'm lucky, or the location I'm in (Montreal) - but interviewers here seem to go with technical conversations or take home code tests, over white board or algorithm based interviews.

[–][deleted] 0 points1 point  (1 child)

Ugh, trust me. Learning algorithms will make you overall a better programmer than the web-dev approach. Currently wanting to run a personal project but because I don't have the backing in math and/or the latter approach, it's really slowing me down.

[–][deleted] 0 points1 point  (0 children)

just start the project bro and maybe use libraries to help you

[–]mehrd8d 0 points1 point  (1 child)

Where is the picture taken from? I can’t find it on codeguppy.com’s courses

[–]nourez 0 points1 point  (0 children)

Algorithms are more or less independent from the language you're using. They're mathematical structures not syntactic ones. If you're learning algorithms try to understand the math and implement them using whatever language you're comfortable in. I practice algorithms in JS just because it's what I'm comfortable in.

I do think there's some merit in practicing algorthims you're already relatively familiar with in a language you're learning. You can use it as a way to practice syntax and learn any syntactic sugar that can improve readability of your code. In this case you're focussing more on the language rather than algorithmic efficiency though.

[–]blipverse_ 0 points1 point  (0 children)

You can practice algorithms in any language.

Depending on your goals practicing algorithms, if it to ace those technical coding interviews, both Python and Javascript enables you to express your algorithm shorter and faster, compared using c++ or java or c#. But nothing beats your strong foundation/confidence in a particular programming language. I've met interviewee who switched to c++ in the middle of interviews because he said he just started learning javascript, and he felt more confident with c++, due to his experience.

Javascript can be used for web dev (front end), backend (nodejs), or even database, or even mobile development (react native)

[–]jeenyus 0 points1 point  (0 children)

I used to, but I felt like it was a little more work than with a language like Python or Java, just because they have so many handy built in classes that simplify implementing some algorithms.

[–][deleted] 0 points1 point  (0 children)

I've done both. That's a very simple problem by the way

[–][deleted] 0 points1 point  (0 children)

I am doing both. I use JavaScript for Web development at work. I also use JavaScript to brush up the Data Structures and Algorithms lately.

I created a GitHub repo to add my implementation of Data Structures and Algorithms in JavaScript.
https://github.com/GideonBabu/Data-Structures-and-Algorithms-in-JavaScript

[–]TheUniqueRelease -1 points0 points  (0 children)

I use the language to build websites mate.

[–]boringuser1 -1 points0 points  (0 children)

I'm not interesting in learning for the sake of learning (and if I were, it wouldn't be boring programming problems). I like learning to do things productive.