/dpt/ - Daily Programming Thread

"Go is actually pretty good" edition.

What are you working on Sup Forums?

Previous thread:

Other urls found in this thread:

skilldrick.github.io/easy6502/
twitter.com/AnonBabble

Fact: OCaml programmers are the most powerful race in the world.

nice try OP

>go

Why can't they just make it as an extension to C or C++? Hate having to learn new syntax

>Which parts don't you understand?

>extension of C
pretty sure Go is a contraction of C

I don't know rust at all but the whole syntax is confusing to me. Usually I can at least get an idea looking at other languages but this is just weird.

The apostrophe

I think i'm burned out of programming. Bye guys.

Because that would break a lot of things

Yeah, because that user is making retarded shit.
Rust's syntax is not the easiest to swallow, but it's not as bad as that unless you're trying really hard to fuck it up.

Only real artisans can work with Rust.

Lifetimes.

...

perl is the best programming language

I've heard a lot of about perl and people seem to love it or hate it. Why is it so good?

use std::collections::HashSet;
use std::iter::FromIterator;
use std::hash::Hash;

fn intersectthese are actual programming languages a small minority of "people" use

What's the most minimalist language? C?

They wanted to rid the world from python.
Therefore it was python friendly.

C and Scheme are both cute languages.

what language do you use user?

>what language do you use user?
I use languages that don't look like these turds.

Can you give me their names?

ARGHHHH THERE'S JUST TOO MANY PROGRAMMING LANGUAGES

TOO MANY OPTIONS

TOO MANY PARADIGMS

TOO MANY SHILLS

Why can't we go back to a simpler time, when languages were few and people were happy and did a lot of cool shit with them despite their limitations?

If you used DOS: you had Basic, Pascal, C, assembly.

THAT'S IT. NO NEED FOR MORE.

who here still uses lisp?

It's a swiss army chainsaw.
It'll do anything, anywhere, with any other language, and it'll do it in the ugliest fucking way possible.

People don't like it because it's not very C-like, it doesn't have a strict sense of data types or anything. You've got scalars, arrays, and hashes ($, @, %) and everything else is based on the operator sense. + means treat it as a number, . means concat it as a string, > < eq ne ge lt all do different things on context.
Basically it's confusing as fuck to newcomers because TMTOWTDI and being operator sensitive makes things obtuse if you don't know them.
EX:
$STR1 = "4HG";
$STR2 = "5HG";
print $STR1 + $STR2; #Prints "9" with warnings
print $STR1 . $STR2; #Prints "4HG5HG"
print $STR1 > $STR2; #Prints "False" with warnings

That and the way hashes work is actually the same as arrays, they're just anonymous lists. (1, 2, 3, 4, 5, 6) is the same as (1 => 2, 3 => 4, 5 => 6), what matters is how you call that list by either $ @ or %.

>Can you give me their names?
No.

translation: I'm a brainlet

intersect :: (Foldable f, Foldable g, Eq a) => f a -> g a -> [a]
intersect f g = filter (`elem` g) (toList f)

main :: IO ()
main = do
print (intersect [4,7,9,7,6,7] [5,0,0,6,1,6,2,2,4])
print (intersect [1,1,2,2] [2,2])
print (intersect "aabb" "bx")


optionally use Set.fromList on the result of intersect (and change Eq to Ord) to remove duplicates

dumb frogposter

You're living the worst era for programming and you don't know it yet.

You know all these people that keep talking about muh strong type safety, muh elegance, etc.
Well perl, the "swissarmy's chainsaw", just wrecks through all of it.
It has a lot of cons, but at least it doesn't make you believe that everything should be written in it (unlike python). Some hate it because it's ugly, others because it's a "scripting" language. And a lot of brainlets hate it because they're unable to read it.

Personally I love it. It's very powerful (in it's own way). I originally learned it to make quick on-liners for CTFs or sysadmin stuff. It let's you do such crazy stuff. If you really want to know, you should try it yourself, and then compare what you did with sick perlmonks, you'll be amazed.

In lisp it's just:
(defun (f g)
(filter (elem g) (to-list f)))

>all these new langs
>all these new concepts
>FP on the rise
>immutability and purity in imperative langs on the rise

not really

>everything is too damn complex for me, why can't we go back to tech prehistory?

That being said, it's incredibly comfy and stupid powerful once you learn how to use it.
EX: Here's my solution for Advent of Code 2017 Day 4, part 2
sub part2 {
my $f = $_[0];
my $count = 0;
while (my $line = ) {
my @phrase = split /\s/, $line;
for my $i (0..$#phrase) {
$phrase[$i] = join "", sort split //, $phrase[$i];
}
my @unique = uniq @phrase;
$count++ if $#phrase == $#unique;
}
print "$count\n";
}

my $file = $ARGV[0];
open my $info, $file or die "Error opening $file";
part2 $info;
Which took me about 3 seconds to write

Once before a programming interview I applied to, the company assigned the candidates a simple programming task in Perl. It was something like read from a database a set of data, then do some transformations, then write it to a CSV file. I have to say I enjoyed doing it a lot. The syntax is weird and hard to read, but fun to write.

I passed the test and got an interview but I didn't get the job :(

(defun (intersect g) (filter (elem g) (to-list f)))
intersect f g = filter (`elem` g) (toList f)

i'll take the second thanks

btw
(`elem` g)
is equivalent to
\x -> elem x g

No im pretty sure you're just a brainlet

I'm sure you have done lots of interesting projects to show you dominate these languages ;)

>FP on the rise
laughed hard

>he doesn't know how `elem` is defined in my imaginary lisp

They're intentionally making lifetimes look confusing.

then rerwite it to be the most simple you can.

>I passed the test and got an interview but I didn't get the job :(

>Looking for an internship
>Pass a test
>Pass a second test
>get an interview
>get a second interview
>get yet another interview (with a small test)
>"hello user, we're not giving you an internship, sorry ! But your profile is very interesting and we'd really like you to come back once you graduated."

your imaginary lisp is less concise than my real haskell

...

A noble goal but an utter failure.

>Type safety doesn't matter!

t. never involved in a large project in my life

>your imaginary lisp is less concise than my real haskell
Only for tiny toy examples.

When we have trillion core processors you won't laugh no more. Threading in pretty much every oo language is broken.

I bet you guys don't even use Visual Studio Code. Why spend forever trying to remember commands in VIM and Emacs when you can have something with mouse support, more features, and things that just werk?

golang is shitware

that's why it's imaginary

> vs code just works
You obviously never used vs code either

THIS
In a couple decades FP will be very dominant in industry
this will be judgment day for the brainlets

What is "type safety"?

>that's why it's imaginary
The only imaginary part of it is that crappy elem function, user. The rest of it is very real, and blows Haskell out of the water. ;^)

hi, I want to learn assembly. I've learned some simplified assembly before (real processor but some early 8 bit) and want to take it seriously. What 'dialog' should I learn? Some good sources? I've seen some people mentioning that there is some publication with C examples and how the code translates, that would be very useful.
Is NASM the goto assembler? What are the differences?

>threading in OO is broken
t. pic related

Agreed, but your theme is cancer.

Man sequences are so nice. Just another reason why Kotlin is the master race language.

except when it comes to performance or type safety

c++ is the greatest language of all time

>Kotlin is the master race language
Lisp is the master race language, ftfy

...

Which one are you? :)

Go has a very different syntax but it's also very easy to learn. You should give it a try, I wouldn't use Go for everything but it's pretty comfy

Shut up faggot, my theme is better on the eyes than any shitty "dark" theme.

C and early scheme versions have very minimal specs. C isn't really minimal because in real word you have to use gcc or clang which are bit monsters, and posix C stdlib is both bloated and empty at the same time.
Go has both small specs (bigger than ANSI C but still fucking small), complete yet simplistic stdlib and small yet good compiler. Would be in a top list for this category for sure.

(Whatever
(You (Say)
(user)))

he's all of them, schizophrenia

Ah yes I also like feeling like I'm burning in hell while programming

The with the bicycle helmet patting your shoulder.

(deposit (account (((You)))) 0.6 shekels)

See you next thread

aoc with perl was comfy
my ($total, $invalid) = (0, 0);
while(my $line = ) {
chomp $line;
my @words = sort map { join "", sort split //, $_ } split / /, $line;
for(0 .. $#words-1) {
++$invalid && last if $words[$_] eq $words[$_+1];
}
$total++;
}

say "part2: ", $total - $invalid;

In c++ if you have a virtual method and you want to override it in a child class, do you:
a. write both virtual and override in the child declaration
b. write virtual but not override
c. write override but not virtual
I like C++ but these things trigger my autism

I haven't written a single line of code in nearly two months

How do I stop crippling depression from kicking my ass (besides meds)

I have yet to master combining everything into one-liners with perl, I have trouble using anonymous functions and maps.

getting back to working my text editor after letting it sit for a few months

beer

depression never goes away lad

Why do you want to write code?
Writing code for the sake of it isn't a good motivator, you need to set goals.

You have a virtual method. You declare it virtual everywhere because it is virtual. You add override when you're overriding a virtual method. How hard is it, seriously?
Exercise, meds, therapy, gf.

Alcohol

Are you just gonna clone Vim, or turn this into a modern TE?

don't bother with learning how C translates to asm. that's just a good way to get confused after a while, I think.

Anyway, assembly is pretty simple. It's just loading/storing memory, branching, and arithmetic for the most part.

There's tons of articles on basic 68k or 6502 programming, those are good places to start and fun to program ISAs

>Exercise, meds, therapy, gf.
lmao everyone of these are memes

>gf.
How do I apply my code skills to get one of these?

do some sport periodically (not necessarily daily), eat healthy (breakfasts, don't dinner in midnight, fruit and shit), stop masturbing

Worked for me senpai.

I haven't cloned Vim at all as far as I know, if anything the commands are emacs-style key chords

Don't know any programming, what do I need to learn to make a comic reader?

C syntax is awful, which is why C++ syntax is fucked up even more. Go's syntax actually max sense and avoids the pitfalls in C's syntax.

>if anything the commands are emacs-style key chords
neat, god-speed

Programming makes girls as dry as a desert.

>How hard is it, seriously?
The fact that the virtual and override keywords are trivial and if you take them out the functionality will be the same as long as the parent method was declared virtual. override is a legacy keyword, and you can opt out of declaring children methods as virtual

Why would you learn Go when you already know C/C++?

>C++ syntax is fucked up
It's the 9th wonder of the world.

6502 is a fun little thing like the other user mentioned.
skilldrick.github.io/easy6502/

Also, the way a compiler turns C-code into assembly isn't anywhere near what a human would write in assembly.
Also, if you're into electronics, maybe you could try your hand at assembly for microcontrollers like the AVR ones.

Are you using space?