Author Topic: Programming Megathread  (Read 104174 times)

Oh boy, I'm going into Unix Programming Environment as my next CS class for college

I program in Java and C++ for work, but 90% of the day I'm writing gnarly SQL queries to the point where I might just bold SQL on my future job applications.



Currently learning haskell and it's a lot of fun. You should add this to the OP:

Code: (Haskell) [Select]
main = putStrLn "Hello World!"

Here's a quick implementation of quick sort just for fun:
Code: (Haskell) [Select]
quickSort :: (Ord a, Eq a) => [a] -> [a]
quickSort [] = []
quickSort (x:xs) = smallerList ++ [x] ++ largerList
     where smallerList = quickSort $ filter (<=x) xs
              largerList = quickSort $ filter (>x) xs
« Last Edit: January 17, 2016, 09:18:39 PM by Scars75 »

Haskell bothers me. I once got into a really in depth argument with another programmer who used Haskell about it. They were really trying to push a point saying that Haskell offers a syntax that is somehow so so much better than C-like syntax, and that everyone who used C-like languages were stabbing themselves in the leg.

Personally I can't make any sense of it. It's just a bit too different and I'm not willing to put the effort into trying to learn something that is different on so many different fundamental levels.

Haskell bothers me. I once got into a really in depth argument with another programmer who used Haskell about it. They were really trying to push a point saying that Haskell offers a syntax that is somehow so so much better than C-like syntax, and that everyone who used C-like languages were stabbing themselves in the leg.

Personally I can't make any sense of it. It's just a bit too different and I'm not willing to put the effort into trying to learn something that is different on so many different fundamental levels.

The problem I have with it is that I'm so used to computers not having an "arrow" looking syntax, where you do stuff like

Code: [Select]
var foo -> 40
instead of:

Code: [Select]
var foo = 40
if you get what I'm saying. I'm so used to working with really low leveled stuff - symbols like that don't make sense, as usually you won't want to waste time by making it read over a string of "this comes after this".

That's just my ideas - maybe I'm way off what you're saying, and I'm confusing Haskell with another language.

Haskell bothers me. I once got into a really in depth argument with another programmer who used Haskell about it. They were really trying to push a point saying that Haskell offers a syntax that is somehow so so much better than C-like syntax, and that everyone who used C-like languages were stabbing themselves in the leg.

Personally I can't make any sense of it. It's just a bit too different and I'm not willing to put the effort into trying to learn something that is different on so many different fundamental levels.
I'm not too knowledgeable on Haskell yet since I'm still learning the basics, although I definitely wouldn't say that using C-like languages over Haskell is shooting yourself in the foot. Honestly the whole reason I'm learning Haskell is because it is so different from anything else I've done. Other than how interesting it is to me, I get to learn a whole new way of thinking about programs that I can apply to other code I write.
The problem I have with it is that I'm so used to computers not having an "arrow" looking syntax, where you do stuff like

Code: [Select]
var foo -> 40
instead of:

Code: [Select]
var foo = 40
if you get what I'm saying. I'm so used to working with really low leveled stuff - symbols like that don't make sense, as usually you won't want to waste time by making it read over a string of "this comes after this".

That's just my ideas - maybe I'm way off what you're saying, and I'm confusing Haskell with another language.
I kind of see what you're saying, although operators with multiple characters in them aren't really unique to Haskell (++, +=, ==, >=, etc in lots of languages, and even -> in C++). Arrows in Haskell aren't used like in your example (you would just type foo = 40), but when they are, it makes a whole lot of sense. For example, foo :: Int -> Int defines foo as a function that takes an Int and returns an Int.
The closest thing in Haskell to your example would be something like this, which just prompts for input then prints it out:
Code: (Haskell) [Select]
main = do
    foo <- getLine
    putStrLn foo
You use <- here because Haskell makes a clear distinction between pure code and code with side effects, like I/O. foo <- getLine runs the getLine IO action then binds the result to foo. If you typed foo = getLine, it would just make foo an alias for the getLine function.
« Last Edit: January 17, 2016, 11:39:59 PM by Scars75 »

Currently learning haskell and it's a lot of fun. You should add this to the OP:

Code: (Haskell) [Select]
main = putStrLn "Hello World!"

Here's a quick implementation of quick sort just for fun:
Code: (Haskell) [Select]
quickSort :: (Ord a, Eq a) => [a] -> [a]
quickSort [] = []
quickSort (x:xs) = smallerList ++ [x] ++ largerList
     where smallerList = quickSort $ filter (<=x) xs
              largerList = quickSort $ filter (>x) xs
adding
please hold
The problem I have with it is that I'm so used to computers not having an "arrow" looking syntax, where you do stuff like

Code: [Select]
var foo -> 40
instead of:

Code: [Select]
var foo = 40
if you get what I'm saying. I'm so used to working with really low leveled stuff - symbols like that don't make sense, as usually you won't want to waste time by making it read over a string of "this comes after this".

That's just my ideas - maybe I'm way off what you're saying, and I'm confusing Haskell with another language.
yeah thats what i hate about PHP alongside the __construct method
I really perfer = than ->

I have decided to create a userscript to provide functions and classes to make it easier to create other userscripts
latest cool thing it does: creates an event that is dispatched to the document when it's finished. this way, a script using this userscript can just do something like this:

document.addEventListener('utilsFinished', function () {
    console.log('Session ID: ' + window.sessionId);
});


instead of the user having to worry about load order -3-
I'm probably going to change the name of the event when I come up with a better name for the userscript. right now it's just "BLF Userscript Utils" which doesn't sound super great, nor can it be shortened to something cool

The problem I have with it is that I'm so used to computers not having an "arrow" looking syntax, where you do stuff like
A lot of languages use "arrow" operators. C/C++, C#, and PHP being the languages I've worked with that use it
« Last Edit: January 18, 2016, 07:12:28 AM by Headcrab Zombie »

A lot of languages use "arrow" operators. C++ and PHP come to mind
but both of them use it for member access, not assignment

True but he's wasn't really specifically complaining about that, just "arrow syntax" in general
Also I forgot about the => operator used in php (array declaration) and c# (multiple things)

Haskell bothers me. I once got into a really in depth argument with another programmer who used Haskell about it. They were really trying to push a point saying that Haskell offers a syntax that is somehow so so much better than C-like syntax, and that everyone who used C-like languages were stabbing themselves in the leg.

Personally I can't make any sense of it. It's just a bit too different and I'm not willing to put the effort into trying to learn something that is different on so many different fundamental levels.

That dude doesn't know what he's talking about and is probably a programming hipster who read Learn You a Haskell for Great Good.

Haskell is a tool in a programmer's toolbox, not a swiss army knife of programming ubiquity. I don't like when people swear by one language and only one language for all purposes. Don't use C++ for writing scripts that run inside a closed environment. Don't use JavaScript for writing firmware.

Anyway, Haskell is a functional programming language. It's functions completely differently than all the imperative languages you're used to, so it makes sense that it's a little confusing. However, that doesn't make it useless. Functional programming code is essentially a bunch of math problems for the computer to solve. This makes it (effectively) no good for things like video games where the majority of the calculations are simple state changes, but extremely useful for things like solving advanced equations efficiently. You'd rather use Haskell than C if you were writing a quantum physics simulator, but you'd rather use C than Haskell if you were writing essentially anything a mainstream programmer would write.


TLE Means time limit exceeded. Limit is 30 seconds
Brought 30+ second code down to 0.8 second code. Still gotta optimize it some more though