/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/nothings/stb
web.stanford.edu/class/archive/cs/cs110/cs110.1176/spring-2017/
youtube.com/watch?v=YQs6IC-vgmo
twitter.com/NSFWRedditVideo

making pearl relevant again.

first for crystal

>Actually Crystal is much faster than Java. It's faster than Go, and Go is faster than Java, so there you go. Granted, pictured here is only a single design problem being tackled, and the graph is being shown from a biased source (the Crystal project itself), but if you search for yourself "is go faster than java" you'll find the general consensus is that it is, and if you search for yourself "is crystal faster than go" you'll find the general consensus is that it is. (I just did this myself just now to make sure.) However, if you search "is crystal as fast as c," which it claims to be, you'll find it usually isn't, actually.
To elaborate, Crystal is as fast as C if it's written like C, but obviously not if you use any of the features that actually make it good.

...

>tfw haven't programmed in over 15 years
>tfw most complex program I made was a text-based calculator in Pascal

Which language would you recommend for someone who wants to casually write programs?

Just pick a language suitable for your interests.

I never understood the point of the original quote.
>The Jew is immunized against all dangers: one may call him a scoundrel, parasite, swindler, profiteer, it all runs off him like water off a raincoat. But call him a Jew and you will be astonished at how he recoils, how injured he is, how he suddenly shrinks back: “I’ve been found out.”
I am a jew. (By descent and cultural heritage, but not by faith; I'm actually an agnostic deist.)
I just called myself a jew and it sure didn't hurt. And yet, if anyone called me a scoundrel, parasite, swindler, or profiteer, I certainly would be hurt, especially because I don't actually make money, at all, doing anything.
Can someone explain this to me?

Well, good for them then, but I still think it has more with the Java/D/C#/Go/Kotlin cluster of GC-based statically-typed OOP languages than with C/C++/Rust in terms of its niche.

...

Are you sincere?
Because there's a lot of stuff I'd regard as obvious from that original quote.

>there're Jews who don't have to deal with the irrationality of anti-Semitism every day
Feels good.

youre calling yourself a jew in the declarational context. The connotation is neither positive nor negative. The context of that quote is more in the connotation of being a kike. Just like how druggies get offended when you call them druggies in a negative connotation or alcoholics.

Calling a jew a jew for being a jew because he does jew shit is an insult.

> Calling a go-fag a go-fag for being a go-fag because he does go-fag shit is an insult.
Makes sense.

#ifndef _WIN32
namespace std
{
template
std::unique_ptr make_unique(Args&&... args)
{
return std::unique_ptr(new T(std::forward(args)...));
}
}
#endif


I don't have access to c++14 features. Is extending namespace std like so undefined behavior?

I was in your situation and I started with C, and then just anything you need to know for the things you want to do, specifically... (In my case, it was LUA and then C++ and I'm currently just building up more practice with those)

std is a reserved namespace, don't do that.

Rob "Faggot" Pike needs to divorce or stop letting his wife draw mascots for his projects.

The standard allows extending the std namespace for stuff like std::hash specialization, otherwise it's prohibited, but I'm not sure if it's UB. Still, don't do it, just put it in your own namespace.

Got it, thanks.

what's std::hash for?

to get an object high on hash

It's the standard way to compute hashes for use in std::unordered_map and likes, so your types can be used as keys.

Why do you not have access to C++14?

Oh okay thanks. That makes more sense. It's offensive because it's in the context of the irrational worldview that all jews are money-grubbers, which is itself offensive, especially if you happen to be both a jew and a money-grubber, because in that particular case you have no grounds to raise a counterargument.

This thread will devolve into language v language within the first 30 posts.

Golang a shit

Not quite. Something even worse has happened: we're being invaded by israel

you are currently experiencing the synthesis of summer and leftover us election hype

+1

Is there a way to get a maximum without branching?

r = x ^ ((x ^ y) & -(x < y))
bitwise magic is fun

>(x < y)
What operation is this if not comparison?

compare doesn't imply branch

why define a type of a function in haskell if ghc can infer the minimum required type bounds for you better than you?

Top tier:
ASM
C
C++
Rust

Okay tier:
D
Go
Java
C#

Slow as fuck/skid tier:
Python
JS
Ruby
Lua

Autism tier:
C
C++
Rust
Hasklel
Scala
OCaml
Erlang
FORTRAN
Clojure
Coq
Agda
etc

Emerging tier:
Elixir
Nim
Crystal

Ah yes of course.

the GOAT language: the best one for the task at hand

Sometimes it can't and sometimes you don't need overly generic code.

How do I write a proper makefile that compiles a lot of similar files? Like:
lvl0: ../rsc/0.lvl ../rsc/0.frames ../rsc/0s.frames
./lvlgen.py < ./rsc/0.cfg > ../rsc/0.lvl
./flgen.py < ./rsc/0.cfg > ../rsc/0.frames
./sflgen.py < ./rsc/0.cfg > ../rsc/0s.frames

and so on (50 of them).

user you really can't say that.

I know C#, Java, JavaScript, and PHP.
What other languages should I learn to round out my skill set? I hear a lot of good things about Pythong and Rust.

i know being reasonable is out of favour these days but still

Learn C and a Lisp.

It's not reasonable to have a programmer learn a new language to niche himself perfectly for the project. Far more unreasonable than sticking to just one language.

Compile time variables or runtime variables for configuring your application?

You can use variables in Makefiles, read the documentation.

Depends on what kind of variables they are. If they're 'constants' that are used deep within math routines then you absolutely want them to be compile time settable.

I would suggest spending some time in Rust or LISP.

Rust will give you a whole different world of idea, and will clear up any memory related confusion you might have. It's a very good training ground.

LISP will introduce to you the power of macros. Plain and simple. Never underestimate macros.

Yeah, I know, but do I still have to declare 50 blocks for each level target? Can I do a for loop, listing every dependency?

Why C and not Rust?
Why Lisp? What does anyone use that for?

>Rust
Because nobody uses it.
>Lisp
Learning FP I guess

systems level programming languages:
C (only as glue between languages and to old code)
Rust

in-the-middle programming languages:
Common Lisp
C++

rapid prototyping languages:
Racket/Scheme
Python
Visual Basic botNET

network backend languages:
C++
Go
Python

web languages:
PHP
JavaScript (backend and frontend)

niches like compilers and parsers:
Haskell

embedding languages:
Lua

research languages:
Haskell
Racket
Rust

native mobile:
Swift
Objective-C
Java

don't know where you'd use them:
Ruby
C#

>Lisp
>Learning FP I guess
kek
stop posting

>Why C
A good reason is because most languages have some sort of foreign function interface and writing certain things in C makes them go fast.
FFI with C++ is just not sensible, not unless you're gonna actually dig into it. Doesn't sound like you are.

Lisp is great because of the macros, otherwise it's just decent dynamically typed general purpose language.
It is also very easy to implement so lisps are generally used as embedded scripting language.

People learn C because they gotta do FFI

prove me wrong

I can't...

>rapid prototyping languages:
>Racket/Scheme
>Python
>Visual Basic botNET
Prototyping implies it's just a quick proof of concept thing. What do you use afterwards when you want to make the final software?

C has occupied a niche that only now is being filled by a new language (Rust)

github.com/nothings/stb
Counter example.
But yes of course there's people who do learn C for that reason.

>Lisp
>Learning FP
Wew, lad.

#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \
|| defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \
|| defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \
|| defined(STBI_ONLY_ZLIB)
#ifndef STBI_ONLY_JPEG
#define STBI_NO_JPEG
#endif
#ifndef STBI_ONLY_PNG
#define STBI_NO_PNG
#endif
#ifndef STBI_ONLY_BMP
#define STBI_NO_BMP
#endif
#ifndef STBI_ONLY_PSD
#define STBI_NO_PSD
#endif
#ifndef STBI_ONLY_TGA
#define STBI_NO_TGA
#endif
#ifndef STBI_ONLY_GIF
#define STBI_NO_GIF
#endif
#ifndef STBI_ONLY_HDR
#define STBI_NO_HDR
#endif
#ifndef STBI_ONLY_PIC
#define STBI_NO_PIC
#endif
#ifndef STBI_ONLY_PNM
#define STBI_NO_PNM
#endif
#endif

What a joke the language is.

>using the preprocessor
What a joke you are.

If you want to write a Linux GUI application, what's your default language?

It's actually pretty nice. Allows you so many things in the user-code.

C++/Qt

C#/WPF

Trying to get into basic graphical stuff.
What are some good reading materials/tutorials for SDL?

python and gtk for just linux stuff.
But if I were to write GUI application I wouldn't limit myself to just linux so I would choose something like
python / kivy
java / javafx,javafxports
scheme, lambdanative

any alternatives to the preprocessor? do tell

I don't know what to fucking make. I'm fine at work or school when assigned shit but I can't come up with any ideas for stuff to make.

traits

you mean unreadable metaprogramming hell?

>just started CS
>first program teachers made us write wasn't "Hello world".

> go to college for CS
hope you're happy, spending all your money to be taught PHP for 4 years.

show me one example of code you did in college that isn't worthless. post an excerpt.
you cant

>PHP
more like Java

>go to college for CS
So, you are telling me that it is better to be self-taught, when it comes to CS? What about the companies that won't even give you the time of the day without a Bachelors?

m8 it's only the first day and I already knew C before starting CS.
Education is free here and I just want to get a degree.

>I already knew C
pfff

dumb frogposter

>>first program teachers made us write wasn't "Hello world"
>> m8 it's only the first day
>which one is it user. got any of those juicy (((college))) examples to show me or not?

not true. no company will ignore you if you don't have a degree. only if you fuck up the interview.

>Implying that going to school for CS won't bring your attention to things that you never would've thought of looking at being self taught
>Implying that having a BcS wouldn't be worth it because "pfft just teach yourself user!"

If you're self taught you're going to fly through the first year of CS. Take that time to properly network with people in your cs department. You'll get references for jobs, and learn a bunch that you didn't know. You'll get a leg up over everyone else whose having to learn it for the first time.

#include
int main( )
{
char name[20];
printf("What is your name?\n");
scanf("%s",name);
printf("Hello %s!\n", name);

return 0;
}

For performance sensitive application I would use C++ with GTKmm.

Don't fall for the Qt memers, it may look flashy but it's really brings out the true horror of C++.

GTKmm is fundamentally more modern than Qt ever will be.

if you're self taught and miss a lot of topics its your own fault. its stupid easy to find references; esp when most universities post most of their work online for anyone to see.

example
web.stanford.edu/class/archive/cs/cs110/cs110.1176/spring-2017/

Took me 10 sec to find

stupid simple to find info to learn from.
here are the steps

1. find resources from 'top tier' universities
2. look at assignments/data/presentations/tasks etc
3. learn if you dont understand something research it
4. done

too hard? if you cant do this, then no university will help you sorry

But my name is longer than that.

There must be a better way, right?
/*Write a program that asks for a user first name and last name separately.
The program must then store the users full name inside a single string and out
put it to the string.
Modify the program so that it then replaces every a, e, i , o, u w/ the letter
z.
Modify the Program so that it reverses the users name
*/
#include
#include
#include
using namespace std;

auto sanitize(string& name) {
for (size_t i = 0; i < name.size(); i++) {
switch (name[i]) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
name[i] = 'z';
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
name[i] = 'Z';
default: {}
}
}
}

auto main(void) -> int {
string firstName, lastName;
cout > firstName >> lastName;
string fullName = firstName + " " + lastName;
sanitize(fullName);
reverse(fullName.begin(), fullName.end());
cout

Then kill yourself for being a filthy Tamil.

rude

> i know C
> buffer overflow
> perfect for American universities

That's certainly true, but what about the other things that university has to offer other than just coding. You have peers that you can reference for help on certain topics, you have professors who are always there to help, and you take other classes than just coding on CS.

Another thing, at the end of the day [spoiler]no one fucking cares that you're self taught[/spoiler]

>ask me what teachers made us write
>post exactly that
>lol u suck user

what the fuck is that?

That's about as good as it gets, you could replace the loop in sanitize with a range-based one.

>what the fuck is that?
learn to read

use std::transform

What's there to sanitize.

C++'s iterators are so traumatizing that I rather stay away from them. C++ isn't really meant for modern functional style.

youtube.com/watch?v=YQs6IC-vgmo

Traumatizing, how?