[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 312
Thread images: 20

File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
Maki edition!


What are you working on, /g/?

Previous thread: >>56138414
>>
First for Rust
>>
Kan jeg norskposte her?
>>
>>56145553
>Anime website
>>
C++ is shit
Prove me wrong

>you can't

Source: Linus Torvalds
>>
I recently started learning C++ but a lot of people say that it's extremely complex and messy. Should I start learning C instead? I'm just doing it for fun anyway
>>
>>56145542
Du må bli kvitt dine japanske animasjoner
>>
>>56145577
C++ isn't shit because lots of people use it, just like millions of people shit in the street in India so open defecation is good
>>
>>56145581
learn kys it's a better language
>>
File: comfy.png (82KB, 1183x628px) Image search: [Google]
comfy.png
82KB, 1183x628px
>>56145581
Try Haskell if you want a different experience
>>
>>56145564
>>>/a/ weeb shit
>>
>>56145664
you again with the haskell meme?

don't you have something better to do?
>>
>>56145686
Come back when semigroupoids and lenses and mtl are practical in your language
>>
>>56145686
You're right

I could be writing Haskell right now
>>
>>56145542
what a joke

girls cant into autistic CS maths
especially not maki, who canonically doesn't know how to turn a computer on
>>
>>56145716
>you need to understand computers to know how to program
>>
File: eve.jpg (64KB, 634x356px) Image search: [Google]
eve.jpg
64KB, 634x356px
Does anyone here play Eve Online?

We should form up a /dpt/ group
>>
>>56145726
You don't need to, but if you don't, then you need to stop immediately and pursue something different.

People who don't understand shit and try to weasel their way into programming are the main cause of the sorry state of bloated "apps" today.
>>
>>56145726
Umm, yes?
You should have at least a middling understanding of the computer memory model before you go around writing shit code and passing kilobyte-sized giant structs by value.
>>
>>56145734
I might be autistic but I'm not *that* autistic
>>
>>56145699
Come back when you written a compiler for your language
>>
>>56145771
Come back when writing a compiler is practical in your language
>>
>>56145771
>saying this to the guy supporting the language practically designed for writing compilers
>>
Who /Java/ here?
>>
>>56145966
Not really into java.
Used it with abcl common lisp and kawa scheme though.
The only good thing is java has ok amount of decent libraries and the scripting languages have really easy interface to it compared to c++.
>>
>>56144874
He claims C++ is the best language effectively. You should learn it because every other language is easy to learn after that and you learn how software should be written.

And you're saying he has no burden of proof on that statement?

You've probably misunderstood this discussion.
>>
>>56145581
It's fine to use C++. The problem is when you start using language features obsessively. Like templates for the sake of templates.

You often find that the most effective way to write code is procedural programming, which is similar to C style programming.
>>
>>56146084
No, I don't.
>>
Why do I have to use a reference for
scanf("%c", &myChar);
?
>>
>>56146153
Isn't it obvious?
>>
>>56145610
Is this AppleScript
>>
>>56146153
It's not a reference, you're just taking the address of myChar because the function expects a pointer to the variable.
>>
>>56146153
do you not know C?
>>
>>56146177
Alright, thanks. Does scanf always expect pointers?

>>56146179
Why do you think I'm asking?
>>
>>56146153
You're giving the function the address of the character. That way it can place the input in the place where you have your character.

If you just give it the current character it can't really do anything with that.

And the & operator is taking the address. If scanf would take a reference you'd just type
scanf("%c", myChar);


In the function declaration for scanf it'd say
void scanf(char* formatString, char& char)

(well not really but to keep it simple)
The multiple meanings of & can be confusing.
>>
File: akari lewd.gif (1009KB, 497x281px) Image search: [Google]
akari lewd.gif
1009KB, 497x281px
scanf only expects pointers if your format string asks for pointers to write to.

Look up what C vaargs does.
>>
>>56146176
Ja, man bruker det for å spise epler
>>
>>56146153
// Casting and all that bullshit aside, let's entertain OP with this.
myChar = scanf("%c");
// NOW WHAT THE FUCK DO I DO?
??? = scanf("%c %c %c %c");
>>
>>56146143
>No, I don't.
This doesn't seem like a response to my post.
Maybe
>No I don't find procedural programming to be effective in many situations
Well in that case you're literally useless and I'd never hire you and I pity those who do.
>>
>>56146232
Makes sense, thank you senpai
>>
>>56146248
hello can someone decrypt perl for me
ty /g/
>>
>>56146268
I find functional programming effective in most situations.

My employer is very happy with my code.
>>
>>56146307
You write functional C++ and people are happy with that?

Teach me your ways.
>>
>>56146337
No, we use a more sensible language for functional programming.
>>
>>56146423
So why are you responding to a post thread which was clearly about C++, C and absolutely no other languages were mentioned as options.

kys?
>>
>>56146453
I took issue with your assertion that procedural programming is the paradigm one often finds to be most effective.
>>
>>56146481
In C++.
Read context. Funny how analogous this misunderstanding is to our preferred programming styles.
>>
Help me out on the P versus NP problem.
I know that the traveling salesman problem is NP, because it runs in exponential time. But what if the graph only has 4 vertexes? Computers are fast enough to solve that within reasonable time, right? Doesn't that make it P?
>>
>>56146295
Norsk er mer logisk enn mange programmeringsspråk, og norsk# er et språk som man kan bruker med .NET
>>
>>56146551
Fuck off.
This is programming general not computer science general. Academics don't belong here.
>>
>>56146531
Perhaps use of C++ limits one to solutions that are not clumsy to express in it, regardless of their overall elegance.
>>
>>56146602
That is to say, it limits the solutions one comes up with and tends to think of.
>>
Rust 1.11 has just been released: https://blog.rust-lang.org/2016/08/18/Rust-1.11.html

Why aren't you using Rust yet, /dpt/?
>>
>>56146675
Sell me on it. Does it let me write efficient software without a bunch of programming friction?
Is it easy to learn?
>>
>>56146675
I need something I can extend with scheme
>>
>>56146675
I'm learning it right now.
Is MIR up and running yet?
>>
>>56146714
I think it will be on by default in 1.12: https://github.com/rust-lang/rust/pull/34096
>>
>>56146577
still can't understand this forth example
>>
>>56146708
It has no GC while making memory management easier than in C or C++. Easy to learn depends compared to what. Easier than Python or Ruby, no. Easier than C++? At least for me personally, yes. And even if you don't end up using Rust, it would still make you a better C/C++ programmer because, for example the compiler basically enforces RAII and other stuff that would are useful.

A good place to start is the official book: https://doc.rust-lang.org/book/
>>
>>56146837
>enforces RAII
Terrible.
Great way to write bad programs.
Computers don't have anything called a 'resource'. And RAII is planning for failure.
>>
>>56146868
>Computers don't have anything called a 'resource'.

Computers don't have a lot of things that PLs provide.
>>
>>56146551

The whole point of complexity classes like P, NP and other (i.e. NP complete..) is to give an upper bound for either the time or the space DEPENDING ON LENGTH OF THE INPUT.

I can have a NP hard problem and then my algorithm accidentally finds the best solution in the first trial. I can have a nasty problem with a complexity of O( exp(exp(exp(n))) ) - but then I choose an input of 2 digits and it's still managable.

That doesn't mean it's an "easy" problem, it only means I avoided a super long computation by chosing a small input.


HTH
>>
>LEARN CODING IN 10 MINUTES
>>
>>56146916
WITH THIS ONE WEIRD TRICK
>>
>>56146908
Hello mummy
>>
>>56146908
Yes but most aren't things that give you extra work to do for no reason. Depends on the language of course but if you're writing code and you care about performance to any decent degree you keep those to a minimum. RAII is terrible because it's there for bad reasons, like exception handling. Exceptions shouldn't be used in the first place because they're a terrible idea. RAII in other situations is just slow and useless, if you rely on it you're writing buggy code.

So that's my gripe. Having it enforce RAII sounds like an extremely high friction construct. I don't want to write constructors for every single datatype I have for absolutely no reason.
>>
>>56146708
>better type system than C++
>less flexible than C++
It's a systems programming language that isn't flexible enough for my use cases.
>>
>>56145966
People here tend to have a little bit of brain left so nobody.
>>
>>56146941
Rust has "RAII" without making you write the boilerplate. Memory is automatically freed when the scope ends, unless it is "moved". Rust doesn't have exceptions.
I don't really like Rust, but "RAII" is no the reason.
>>
Python wrapper for arch linux maintinance commands. Pacman -Syu ,-Sc etc.
>>
>>56146976
So programs can't even close fast anymore..
Ok.
Well. I might check it out just so I can complain accurately.
>>
>>56146911
So when is a problem NP? 'it takes very long' is really abstract.
>>
>>56146941
>>56146976

Rust doesn't even have constructors:

#[derive(Debug)]
struct Foo {
a: i32,
b: char,
}

fn main() {
let x = Foo {a: 1, b: 'x'};
let y = Box::new(Foo {a: 1, b: 'x'});
println!{"{:?}, {:?}", x, *y};
}

Output:
Foo { a: 1, b: 'x' }, Foo { a: 1, b: 'x' }


x is allocated on the stack, y on the heap. I don't have to explicitly free any of them
>>
>>56146947
People here use the most meme hipster languages

Java is actually useful
>>
>>56146980
>python
kys
>>
>>56147014
So you do admit that you do not belong here.
Java is shit and not useful by any means.
>>
>>56147014
>java
kys
>>
>>56147012
when there's no polynomial solution algorithm, but you can verify a soluton in polynomial time
>>
>>56147025

This general should bring programmers together... smhtbh
>>
>>56147040
Not an argument.
>>
>>56146675
>still no unsafe unions
>>
>>56147001
>So programs can't even close fast anymore..
What the fuck are you talking about?

>>56147013
X::new is the stylistic convention of a constructor... not that it matters.

>>56147103
What good has unsafe unions ever done?
>>
>>56147103
It's coming, not a long way off:
https://github.com/rust-lang/rfcs/blob/master/text/1444-union.md
https://github.com/rust-lang/rust/issues/32836
>>
>>56147012

Why not using Wikipedia?

It's pretty clear in it's definition, but I'm not gonna spoonfeed you.

Basically it all depends on differnt theoretical "machines" (i.e. deterministic and non-deteministic turing machines) and the time they would need to "solve" a problem (--> this point is also more complicated).

Better ask here:
>>>/sci/
>>
>>56147116
they're pretty important for C FFI
>>56147122
ik but it's been forever since someone brought it up and they haven't bothered putting it in any of the recent releases
>>
>>56147116
The point is Foo::new is by convention just an associated function used as a pseudo-constructor, not something forced on you.
>>
>>56147125
Yes that's right, P is a subset of NP.
>>
File: Screenshot - 180816 - 20:40:23.png (31KB, 927x220px) Image search: [Google]
Screenshot - 180816 - 20:40:23.png
31KB, 927x220px
what did he mean by this?
>>
File: indians.png (5KB, 235x117px) Image search: [Google]
indians.png
5KB, 235x117px
I'm going to create something horrible with all these extension methods.

I have no idea if I'm just ruining myself in the longrun by allowing extension methods to both mutate the source object, as well as return the source object's type to whatever.

sourceData
.MutateColumn("Created_By", x => "Some asshole") // replace text in specific column
.MutateColumn("ID", x =>
{
var ayy = (int)x;
FizzBuzz(ayy); // perform a full round of fizzbuzz for each of the millions of rows based on their ID
return ayy * 2;
})
.MutateColumn("Resolved_By", x => "Some other asshole")
.MutateColumn("Number_of_Cocks", x => (int)x * 7); // this line increased the number of cocks sevenfold
>>
>>56147192
She doesn't even know how to use a computer, to be quite honest family.
>>
>>56147192
Ruby because her hair is ruby-colored
>>
>>56147192
virgin++
>>
>>56147095
just kys
>>
>>56147210
>being this butt blasted

kek
>>
>>56147192
end your useless cringeworthy life
>>
>>56147210
>>56147227
Is this another case of trolls trolling trolls?

Why would you even respond to someone that makes the claim that Java is never useful?
>>
>>56147227
>still not dead
that's not fine
>>
Should I take Field Theory and Topology?

Have they ever helped you?
>>
>>56147308
take cyanide instead if you cant answer that question yourself
>>
>>56147308
take Zyklon B instead if you cant answer that question yourself
>>
What are essential or useful C libraries?

#include <lua.h>
#include <getopt.h>
#include <gmp.h>
#include <curses.h>
>>
>tfw no qt programmer gf to pair program with
>>
>>56147400
>Lua
Lua is shit

>getopt
POSIX, global state

>gmp
It's trash

>curses
Sure, if you make terminal GUIs, not something that you would use all the time.

Also, all of these are headers, not libraries.
>>
>>56147338
>>56147354
Thanks switched my major to math
>>
File: 1460094546032.png (756KB, 2022x1450px) Image search: [Google]
1460094546032.png
756KB, 2022x1450px
>>56147414
>tfw my bf has a qt programmer gf to pair program with him
>>
>>56147426
yes i know thats the reason you posted your question in the first place to show your studying math

look at me mamma, you proud of me daddy?
>>
>>56147432
No traps.
>>
What (linux) text editor do you guys recommend for editing the Linux kernel?
>>
>>56147471
Emacs, just like Linus.
>>
>>56147471
vim
what you're editing literally doesn't matter idiot
>>
>>56147482
>>56147491
i'm not installing autistic software
>>
>>56147498
then install eclipse+netbeans integrated with visual studio
>>
>>56147471
nano

>>56147432
can i have regular hime?
>>
>>56147421
What about guile instead of Lua?
>>
>>56147590
Better but why?
>>
>>56145542
An awesome database for AUR that everyone will love.
>>
>>56146153
C simulates out arguments by taking in a pointer to a variable to write to. It's not the only thing that passing in a reference is used for, but it's the relevant one here. And it doesn't need to be a reference to a local variable; any pointer to a writable storage space large enough (one byte for %c) will do fine.
>>
Asking for genuine replies as I'm in some money struggles right now, sorry if this gets asked often.

Which area of programming / language is best to get into that allows for the quickest progression of skill or offers ways of making money quickest whether that be through freelancing or a normal job?

I'm in it for the long haul, not in this just for money either, but kinda desperate.
>>
>>56147637
database for AUR? What?
>>
>>56147728
none
go sign up for neetbux
>>
>>56147728
Webshit
JavaScript, and a backend language, node.js, Python, Ruby, etc
>>
>>56147607
I don't want to write all my code in C
>>
>>56147807
Why? Also, why not just not write none of your code in C?
>>
>>56146084
How are templates antithetical to procedural programming? Of all the things to pick out...
>>
>>56147828
I'm writing the base code in C for portability, performance, and library support, but I want to use something more high-level for creating tools and GUIs based on my code
>>
>>56146251
You make the domain type depend on the format string. Like this, but dual: https://www.youtube.com/watch?v=fVBck2Zngjo
>>
>>56146551
>But what if the graph only has 4 vertexes? Computers are fast enough to solve that within reasonable time, right?
Usually yes. Trivially small problems are trivial.
News at 11.
>Doesn't that make it P?
No. What if you have a problem of size 100 instead? Well, if it was a linear problem, it would take about 25 times longer than the size 4 problem. If it was NlogN, you'd be looking at around 50 times longer. Quadratic, 625 times longer. Cubic, around 15000 times.
But NP means that we need an exponential search (with current known algorithms), which means that a size 100 problem takes something like 33.5 million times longer than a size 4 problem. That's a different order of nasty, turning something you can solve in 100us into something that takes the best part of an hour.

Size 100 isn't very large for most problems. Real problems can easily hit the millions in scale.

Of course, NP is tricky because we have a cheap answer checker, so if we could only guess the answer right in a small number of goes then we'd have an awesome way to get the solution. But in general we don't have any such algorithm; a full scan of the problem space is required and it's that scan which hammers you. (The P vs NP problem has to do with determining if there exists an algorithm at all to do the guessing magic, or if we should stop pounding effort down the rat-hole.)

Also, NP is nowhere near as large as algorithms get. Some specialist algorithms hit things like EXPEXPSPACE and that's just fucking scary.
>>
Nothing, im playing urbanterror and masturbating to traps
>>
>>56146941
>Exceptions shouldn't be used in the first place because they're a terrible idea.
GR8B8M8
>>
>>56146941
RAII is convenient. It's perfectly possible to write code with linear types where you have to destroy everything yourself, but affine types are WAY easier to use without any major drawbacks.

It's not just exception handling, but any branching.
>>
>>56147754
Cool, currently learning JS so I'll just carry on with that then
>>
I'm familiar with the Haskell style of functional programming, and ML to a lesser extent. Will this help me at all if I'm learning Scheme, in particular using SICP?
>>
>>56148319
No. Instead of types and purity being the selling point, Lisps have homoiconicity and macros (roughly equivalent to TH).
>>
>>56148319
a bit yeah

>>56148354
SICP doesn't use either of those though
>>
>>56148360
SICP is about programming, not wanking yourself off with S-expression juju.
>>
>>56148367
i don't know why you're responding to me cause that's what i was basically saying
>>
>>56148384
I guess my point is that SICP doesn't teach Scheme, it uses Scheme.
>>
>>56148393
Yeah, it doesn't really teach much of scheme
>>
>>56148393
>>56148414
In that case, what could I use to teach myself more Scheme, after SICP teaches me a bit of its syntax if nothing else?
>>
>>56145577
C++11 and newer are good.
>>
>>56148483
Rust is better for all the same reasons.
>>
>>56148042
>>56148090

Not that anon; I'm just some other random asshole chiming in.

My experience with exceptions has been having to shuttle them around with std::exception_ptr, then the catch site not being able to do anything with them but log and/or die.

They literally carry concerns (implementation details) from one layer to another, or are just useless.

I've found myself reverting to printf-style logging (fprintf(stderr, ...)), or similar with an interchangeable handler for such things.

Where I've seen exceptions would provide a clean solution, they are slow (sockets), and where they are messy, they are useless (containers, etc...).

Moreover, we have bad_alloc. This can only really be thrown by custom allocators, then the catch site needs to know what to do with it. Almost always this code ends up looking like a signal handler - close out extra handles, log if possible, and die.

No, I'm not a fan of C signals, either.

Just bitching, feel free to bitch back.
>>
>>56148551
My point was that RAII is useful even in the absence of exceptions.
>>
>>56148569

Ah, ok. Probably the drink thinking for me.

Completely agree, though.

Much preferred for deterministic resource management. I've had many miserable years investigating memory issues with managed languages.

Having a symbol fall out of scope meaning the resource is no longer allocated makes code easy to debug.
>>
>>56148483

Good luck being able to only be able to use C++11 style code only. Mixing C with Classes code and Modern C++ is like a disaster.
>>
>>56148622

Long ago, VLAs immediately made C and C++ very different languages. C++1x is like a tiny step further on a journey that has already seen standard C disappear over the horizon.

Basically, we can only use C90 and pieces of C99 with C++1x.

This is why we never say that we know "C/C++". Its like saying we know "C#/Java/D". Or I have a "dog/cat/snake".
>>
File: 1465770696702.png (1MB, 960x736px) Image search: [Google]
1465770696702.png
1MB, 960x736px
Someone halp me please.
I have a Prolog program, trying to compile it in Visual Prolog 5.
DOMAINS
name = valentin; leonid; valery; andrew; michael
faculty = physics; history; biology; geography
instrument = sax; piano; bass; drums
student = student(name, instrument, faculty)

PREDICATES
nondeterm student(name, instrument, faculty)

CLAUSES
student(michael, sax, _).
student(_, piano, physics).
student(_, drums, _) :- student(leonid, _, _); student(michael, _, _); student(valentin, _, _); student(andrew,

_, _).
student(_, _, geography) :- student(michael, _, _); student(valentin, _, _); student(valery, _, _); student

(andrew, _, _).
student(michael, _, _) :- student(_, _, physics); student(_, _, geography); student(_, _, biology).
student(andrew, _, _) :- student(_, _, physics); student(_, _, history); student(_, _, geography).
student(andrew, _, _) :- student(_, sax, _); student(_, bass, _); student(_, drums, _).
student(valery, _, _) :- student(_, _, geography); student(_, _, biology); student(_, _, history).
student(_, drums, _) :- student(_, _, physics); student(_, _, geography); student(_, _, biology).
student(leonid, _, _) :- student(_, sax, _); student(_, piano, _); student(_, drums, _).

GOAL
student(valentin, Instrument, Faculty).

It gives me errors 'The variable is not bound in this clause _' with _ variables at the first, second lines and the second variable at the fourth line.
What do?
>>
File: thatPic.png (27KB, 578x527px) Image search: [Google]
thatPic.png
27KB, 578x527px
So I have two Constructors for a class,
one with a specified name, the other without any parameters.
When using the one without parameters a name should be randomly selected from a list(here implemented as an array).
How should I implement this random selection? I already have a Random object but it obviously isnt initialised. You also cant initialize one in the parameterless constructor since the call to the other constructor must come first.

Currently I use an additional static Random but that seems Pajeet af desu. Also thought about not calling the other constructor and simply c&p ing.
Pic related
>>
meme shell is open source
https://powershell.org/2016/08/18/powerscripting-live-tonight-with-jeffrey-snover-about-powershell-open-source/
>>
>>56148846

Interesting. This is a good thing.
>>
>>56148846
Okay
But when are they going to fix the tab-complete?
>>
File: ChipOnDime2-1470331838410.jpg (217KB, 1482x1020px) Image search: [Google]
ChipOnDime2-1470331838410.jpg
217KB, 1482x1020px
http://spectrum.ieee.org/tech-talk/semiconductors/optoelectronics/mit-lidar-on-a-chip

When have programmers ever accomplished something this incredible?
>>
>>56148701

Yes, but unfortunately in certain domain areas, that is not the case.

I do agree that this split between needs to happen immediately if C++ refuses to pick up C features introduced back in C99 and C11 like designated initializers, anonymous structs, restrict, and some other stuff.

The following function signatures will never compile on a pedantic compiler for C++, yet is perfectly fine C11 code.

size_t strlen(char const string[static 1]);
char* fgets(char s[restrict], int n, FILE* restrict stream);


Either C++ updates itself to accept syntax changes from later versions of C or code should split up and decide whether to go C++ or C. Because keeping to C89 holds both languages back. The subset of C and C++ is barely better than C89 these days.
>>
>>56145664
Damn, that font is beautiful.
>>
>>56148777
ravintolassa
>>
>>56145716
Girls can code better than men do.
>>
>>56145555
What have you used rust for, /g/?
>>
>make an application that tries to determine the general mood of twitter based on recent tweets
>classify tweets as overall angry, sad, or happy
>finish it this afternoon
>it's almost always at 29% angry, 32% sad, 39% happy
well that was a waste of time
>>
>>56145542
I'm making an app for Pokemon GO players.

It's all the rage right now, so that's where the money are.
>>
>>56147734
You will shit bricks
>>
You have 5 minutes to write a binary tree depth-first traversal that uses constant space.

GO
>>
>>56148777

So in your first constructor each Cow has it's own number generator for the single purpose of getting a random int..?

Hahahahahha..
>>
File: 2440169_300x300.jpg (11KB, 300x300px) Image search: [Google]
2440169_300x300.jpg
11KB, 300x300px
It's 2016 and I can't figure out how to set up an ADA development environment and compile hello world.
>>
>>56149522
Nah
>>
>>56149536
It...it's used in another part of the class aswell pls no bully senpai
>>
>>56149547
It's 2016 and you shouldn't be using Ada.
>>
>>56149522
Actually constant or O(1) ?
>>
Hey guys so when I convert the double variable "widgets" to an into, why does it cout as a float?

//calculate how many widgets are on the palet given the palet weight and the total weight
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
double pWeight, widgets, netWeight, widgetWeight = 9.2;

cout << "How much does the palet weight?: ";
cin >> pWeight;
cout << "What is the total weight?: ";
cin >> netWeight;

widgets = (netWeight - pWeight) / widgetWeight;
static_cast<int>(widgets);
cout << "There are " << widgets << " on the palet.\n";


}
>>
>>56149586
But what if I want a language designed for safety that isn't a meme?
>>
>>56149632
*to an int
>>
>>56149632
//calculate how many widgets are on the palet given the palet weight and the total weight
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
double pWeight, widgets, netWeight, widgetWeight = 9.2;

cout << "How much does the palet weight?: ";
cin >> pWeight;
cout << "What is the total weight?: ";
cin >> netWeight;

widgets = (netWeight - pWeight) / widgetWeight;
cout << "There are " << static_cast<int>(widgets) << " on the palet.\n";


}
>>
>>56149677
So when you cast a variable it doesn't permanently stay as the variable type you change it to??
>>
>>56149696
In your original snippet of the code you're casting the widgets variable to an int but discard it completely since you do not assign nor use it at all.
>>
>>56149696
That's right
http://en.cppreference.com/w/cpp/language/static_cast
>>
>>56149696

Yes, if you don't save the return value of the cast to a variable, you have done nothing with the parameter or the thing you want casted.
>>
>>56149566

OK, some hints:

You want static stuff whenever it's not important to create one thing for each object.. --> for example number generators.


You might want to use "contructor chsining":

public Cow(String name){
this.name = name;
}

public Cow(){
// this works even if we add/delete names !
this( NAMES[ myRand.nextInt(NAMES.length) ]);
}
>>
>>56149291
https://panopticon.re
>>
>>56149759

>contructor chsining

* constructor chaining
>>
>>56149021
anonymous structs and unions are incredibly useful from a convenience standpoint. I'm not sure why C++ never adopted them.

>>56145577
I don't understand why Linus hates it. My guess it name mangling and compile times. But with it you get templates instead of insanely obtuse and type unsafe pre-processor macros; constexpr instead of hoping the compiler can deduce the statement is constant, especially through inline function calls. Basically, C++ is far superior in terms of metaprogramming. But VLAs and VLSs are pretty fucking useful in terms of efficiency, not sure how much they are used in the kernel though.

Really though, I just want a metaC language.
>>
>>56148701
>>56149021

Is it possible to write good C code with using only the "overlap" between C and C++?

Or would I miss really important features?
>>
>>56149625
same amount of space regardless of the size of tree
>>
>>56149866
>Or would I miss really important features?
You would be massively limiting yourself and have to dance around the many semantic differences between C and C++.
Trying to write code that can compile as both is a fool's game.
>>
>>56149866
You could, but you would miss some nice features. Pretty much no one just writes plain C89 functions.
>>
File: 1460416382055.jpg (274KB, 1269x1431px) Image search: [Google]
1460416382055.jpg
274KB, 1269x1431px
gimme something not too complicated to do
beginner-to-intermediate level, C or python
>>
>>56149946
C
>>
>>56149934
>>56149945

Thanks, that's what I wanted to know.
So it's really good practice to keep them seperated then.
>>
File: angry_panda.gif (982KB, 500x346px) Image search: [Google]
angry_panda.gif
982KB, 500x346px
>>56149989
>>
>>56149838

Add designated initializers too. Some of the features would not clash with Modern C++ semantics but no. It's actually frustrating looking at C++17 adopting the C11 standard library but not some of the syntax. C++ might as drop the compatibility if they aren't willing to go the distance with what they call is "C compatibility".

C++ just has a humongous runtime that supports a ton of stuff that a portion of applications just do not need and embedding that runtime sucks especially in Linux's context which means that it will never make it in the kernel.

>>56149866

You wouldn't be writing good C or C++ code. You would be essentially be writing C89 with // comments, variadic macros with the C99 preprocessor, and C99 standard library. C++17 will give you limited C11 standard library functions and remove tgmath and other stuff.

Modern C11 and C++14 are vastly different languages. C2x, the next standard for C, should, I hope, have some better metaprogramming features.
>>
>>56149946
Making an LMC might be fun
>>
Really digging clojure so far. What should my first program be?

Hard mode:
something actually useful
>>
>>56150077
>C2x, the next standard for C, should, I hope, have some better metaprogramming features.
Don't count on it. I'm getting to work on a MetaC language that accepts valid C syntax, but allows you to 'escape' certain parts that allow you to stage execution a la multi-stage programming as in MetaML and terralang.
>>
>>56150124

Build your own Lisp dialect.

:)
>>
>>56150077

Unfortunately, array versions of designated initializers (e.g. int a[4] = {[0] = 3, [3] = 0};) would look like lambda introducers.

However, C++ is desperately in need of something along those lines for constructors (or functions, really).

Another thing that would be nice is WYSIWYG evaluation order for expressions. As someone who has written compilers for older versions of the language, I know there is no excuse to make argument evaluation order unspecified - the AST can be arranged intuitively, and the backend can do whatever is necessary to optimize.
>>
>>56150224

meant to say "WYSIWYG evaluation order for _argument_ expressions"
>>
>>56150077
>C2x, the next standard for C, should, I hope, have some better metaprogramming features
I've taken a look at the proposals so far for the new standard:

Closures.
OpenMP-like multi threading.
Standard way to do comma deletion in macros. It seems like they're leaning towards __VA_OPT__, which is a lot more useful than the current non-standard solutions.
C++-like attributes, although I think this one is unlikely to get through.
New enums where you can specify the representation.
"short float" type for (possibly) representing half-precision floats.
And maybe some others that I'm forgetting.

I don't think you'll ever get anything like C++ templates in C, and I think they don't even belong in C.
The C standards committee doesn't add features that lead to shit-loads of executable code to be generated.
Also, it would be all sorts of ABI-related shit that it would break.
>>
File: asm.png (11KB, 334x550px) Image search: [Google]
asm.png
11KB, 334x550px
Who x86 here?
>>
>>56149325
post the code
>>
>>56150250

The proposals so far are pretty bad, at least half of them. I like the closures and the enum changes.

If you've read Modern C, the "Ambition" portion of the book is really great, as unfinished it is. But I dunno if the author will be able to get some of the proposals in the standard.
>>
>>56150279

Wrote a disassembler a while back. Used the Intel spec sheets, too...

Do I win?
>>
>>56150315
>The proposals so far are pretty bad, at least half of them
Yeah, several of them aren't that great, but they're just proposals at this point. They're probably going to change a lot, and several probably won't be included at all.
>>
>>56150427
Please make an IDA ripoff that people can actually afford.
>>
>>56150510

It was for automated injection.

That would be one hell of a project, though.

Retirement may afford the time. Have to play wagecuck for some time, sadly.
>>
>>56150556
How old are you?
>>
>>56150556

30
>>
>>56150646

meant to reply to this one:

30

Also, my shoe size 9 and I live in a barn
>>
What makes a language a "meme language"?
>>
>>56150920

I call it a meme language when 90% of its users are hipsters.

I also call it a meme language if it does not yet have a self-hosting compiler written in the language itself.
>>
File: mfw (2).gif (930KB, 200x200px) Image search: [Google]
mfw (2).gif
930KB, 200x200px
>software engineering class
>says it's writing intensive, and we have to write a paper
>>
>>56151064

> engineering
> writing

It means your teacher is an idiot that can't into real lesson plans.

That, or they have race/gender/disability quotas to fill, and they can't do that by testing real intellect.

Prepare to have your oxford commas marked as grammar errors where convenient.
>>
>>56151064
>software development class
>prerequisite for almost every interesting course
>very limited space
>it's just basic C and UNIX
>literally a class about lurking /g/
>>
>>56151106
Sounds like it would have been fun desu. The only programming I'm seeing this semester is SQL.
>>
>>56151106

Then lurk, copy & paste away.

The other possibility is that its just another course there to eat up a semester.

Keep an eye on your student loan balance. Protip: Don't let it get above $0.
>>
>>56151130
It would be fun if I could actually get into it, and if I didn't already know the material.
>>
>>56150279
What's that supposed to be, a factorial?
>>
I'll start a job where I'll need to work with legacy fortran code in two weeks. Code base started in 1995 and they compile to the 2003 standard.

I'm confident in C in the same application are the Fortran stuff will be, find my way around C++03 and worked as a Python dev.

Any ideas how to prepare? Fortran is a fucking ugly language and all toy projects that need reasonable input/output suck in Fortran.
>>
>>56151106
Limited space is usually not a concern, you... ARE signing up for classes the night when registration opens, aren't you?
>>
>>56150966
> 90% of DSLs are meme languages
>>
>>56150920
A toy language with a lot of hype around it and no substance to its claims. Everyone is talking about it but it's a waste of time because it can't be used at your workplace and it'll be forgotten in a matter of months (or, charitably, years) when the next stupid programming fad rolls around.
>>
File: Sad Winston.jpg (68KB, 1280x720px) Image search: [Google]
Sad Winston.jpg
68KB, 1280x720px
When was the last time somebody told you the thing you wanted to program/script couldn't be done and they were right about it?
>>
>>56151419
Couldn't be done because you suck or because it's not computable within some bound?
>>
>>56151488
It was Fizzbuzz :(
>>
>>56151515
Are you a grill?
>>
>>56151515
>that kind of abstract math
>>
Is optimizing my AI with an evolutionary algorithm the "lazy" way out? I'm writing an AI for a card game and there are a bunch of personality weights that I have that it considers when choosing which card to discard, depending on the state of the deck, what cards are visible, the probability of it finishing a certain hand, etc. The problem was, my AI was only winning like 30% of the time vs pure random opponents because the weights were kind of garbage.

So I just set each personality weight to mutate a VERY little bit in a random direction, sim 1000 matches, and if it did worse than the previous weights, revert and mutate again. After simming 100,000 games I've gotten the winrate up to 85% but it feels like I cheated.
>>
>>56151064
I had to take a Software Engineering class that was basically working in a group, gathering requirements for a software project, interviewing the Prof and TA like they were a company you were designing software for, and we had to write all the documentation for the project and write an insignificant amount of code to prototype it
It was basically all about writing a liek 30 page software doc though
>>
>>56151598
That's the smart way out. Humble brag.
>>
>>56150279
I'm more z80 myself
>>
>>56150279
>hand writing assembly code that's less efficient than two-line Haskell
>>
>>56148551
>My experience with exceptions has been having to shuttle them around with std::exception_ptr, then the catch site not being able to do anything with them but log and/or die.
so, the designers of Go are right.
>>
>>56151606
the syllabus also mentions having a team so i bet it'll be this. the only thing i hate worse than papers are teams. end me now i guess
>>
>that one asshole coworker who never checks for nulls

I fucking hate Pajeets.
>>
>>56151677
it was kinda fun for me but I was in a group with like 4 of my friends and 1 foreign grill that just kinda went with the flow
we ended up being the best in the class too
>>
>>56151707
you sound like a normie
>>
I wanna make a turn-based RPG (with just a little bit of 3D in the BG.

Would I be safe using Allegro? Or should I just hoof it and try and make my own engine in C++
>>
>>56151723
just not a complete autist
I still fuck up socially on the occasion
>>
File: 1382372691777.gif (676KB, 300x368px) Image search: [Google]
1382372691777.gif
676KB, 300x368px
>tfw it-ebooks is back
>>
>>56151819
>Or should I just hoof it and try and make my own engine
No, don't do that.

You could try using Unity or whatever, and see where you get with a prototype.
>>
>>56151869

I've considered Unity, but it seems really heavy-duty for what I want (just some 3DBG to make the sprites stand out during combat and literally nothing else), plus it doesn't have the ability to make txt files, right?

Have you made (or tried making) an engine of your own in C++? What was your experience?
>>
>>56151698
>not using Option types
>>
>>56152021
However heavy-duty Unity might seem, it's still a far smaller investment than a hand-rolled engine.

I've worked on games built in a number of different languages. C++ was, in general, far more trouble than it was worth, no matter what we did. Haskell was surprisingly pleasant for turn-based nonsense; of course, it couldn't really keep up with real-time simulations. Rust is the language I've always wanted for this kind of work and it's pretty blissful, but writing an engine is still a stupendous quantity of effort.

If your heart isn't set on Writing Your Own Engine, you should at least start with a prototype built on some framework like LibGDX, Monogame, LÖVE, or HaxeFlixel. I've worked with the latter two and you'd be astonished how much control they give you over the actual rendering and gameplay. The best part of using these is not having to write your own asset loaders, or even hook them up to the graphics APIs. I haven't actually used Unity but I'm told it's basically the same idea, with a few more batteries included, like the scene editor. There are a number of Unity games that restrict movement to 2D planes and just use the 3D support for fancy visual effects.
>>
holy shit /g/ i'm mad, i'm doing a small c project, and i'm getting inconsistent behavior.

i'm using '<' and '>' to use files for stdin and stdout, respectively. sometimes, an extra newline is included. sometimes it isn't, and the rules governing this make no sense.

for example, if putchar() the characters from the file consisting of the string "help!" into a new one, i get "help!". if i do that and, additionally, printf each character's integer code, i get a sixth one in the form of a newline. essentially, using just putchar(), the output file is "help!". using both putchar() and printf(), it is "hheellpp!!\n\n" with two newlines.
in fact, if i count the number of characters that are "put", but don't use printf(), i still get 6 instead of 5, but there's no newline so it's a mysterious empty character (which is not '\0'), but i can't read it because the moment i do it becomes a '\n'!

why is this? am i crazy?
>>
>>56152293

Thanks, Anon. I'm installing Haxeflixel right now.

[spoiler]God I wish there was an easy way to get what I want done without having to resort to Gamemaker or RPGmaker (which would take way too many compromises.). Fuck me for not teaching myself programming when I was younger.[/spoiler]
>>
>>56152566
I have no idea what I'm talking about, so this is a while guess... use fflush between putchar and printf
man fflush
>>
>>56152713
>while guess
wild, wtf

also, someone pls explain fflush to me.
>>
>>56152746
putchar doesn't immediately write the character to the file. That would be a syscall for ever character and would be incredibly inefficient. So every write operation is cached and fflush flushes the contents of the cache to disk. Which is probably the cause of the weirdness caused by putchar and printf, but I can't say exactly why.
>>
>>56152785
read the asm? :P
is it a threaded program?
btw, thanks for the explanation
>>
(defun pajeet-destroyer (n)
(dotimes (i n)
(format t "~%~:[~d~:;~:*~{~c~^~}~]"
(append (and (zerop (rem i 3)) (coerce "fizz" 'list))
(and (zerop (rem i 5)) (coerce "buzz" 'list)))
i)))
>>
>>56152886
>"~%~:[~d~:;~:*~{~c~^~}~]"
>self-documenting code
>>
>>56152566
if you want to see what character it is, cast it to an int before sending it to stdout. look up the character code on an ascii table
>>
>>56152886
>>56152911
>:*~{
ebin
>>
Who here knows

SucC++
>>
>>56147400
cmath
>>
>>56152930
i have, it's the newline character
here's another example of the inconsistency i'm talking about:
consider the input file "help"
if i output one character at a time, i get the output file "help"
if i output one character at a time and count the characters, i get the output file "help5"
if i ouput one character at a time, count the characters, and look at the last one, i get "help5\n" (or help510 if i cast it to an int)
>>
>>56149767
>I'm in an IT-Security Masters program in Bochum, Germany and work part-time for people who use the term Cybersecurity unironically.
>Cybersecurity unironically

So what is cybersecurity supposed to be called?
>>
>>56153003
information security, aka, infosec
>>
>>56153130
Same thing
>>
File: 1468274225076.png (150KB, 1024x713px) Image search: [Google]
1468274225076.png
150KB, 1024x713px
>>56152886
> ~%~:

M-MASAKA

SNAILU OPURATURU?
>>
>>56147013
>
Box::new(Foo {a: 1, b: 'x'})

Jesus fucking christ, what ugliness.
>>
what data structure would you recommend for a scheduling program? I was thinking XML and just nesting like

>-August
>--First of the month (Monday)
>---Driving
>----Time
>----Description
>---Eating
>----Time

or something like that but I don't like parsing XML much, it requires two separate libraries, one to read it and one to write
using python at the moment
>>
>>56153338
How are the Python libs for JSON and YAML, I bet they'd be alright given how much Python is used for web related content. That being said I don't see why the read and write separation is necessarily bad if you only need one for a particular module.
>>
>>56153371
no idea but I'll look into them
>>
Nested if else statements can get confusing :S
>>
>>56151650
Not that Anon.

I still can't believe people shit on Go for trying to force programmers into handling errors properly. I swear the detractors must just use some catchall for exceptions and hope for the best. Error handling is important and I wish people would care about it.
>>
Is C the most fun programming language? What are some cool things that can be done with C(besides linux) ? I am currently learning it at the moment, and want some ideas for future projects.
>>
>>56153476
Why did you decide to learn C and not C++?
>>
>>56153507
Because I read that C was a good foundation for C++. Once I understood C, C++ was going to be a bit easier to understand.
>>
>>56153476
>Is C the most fun programming language?
I haven't used it in ages but it's still my favorite, so small and simple, super easy to grasp concepts, and pointers are powerful.
>What are some cool things that can be done with C
Pretty much anything? Though you will re-invent the wheel, and learn things in that process. Or you just could use a library.
I wanted to do a regex and a game in C (like tamagotchi), but ended doing just a simple TODO program.
>>56153521
>Once I understood C, C++ was going to be a bit easier to understand
This is correct.
>>
>>56153548
Oh cool, I also was planning on making a Chrono Crusader like game, and add my own spin on it. I will start working on it once I get a firm grasp on the language. It should be pretty fun, and if it turns out alright, who knows, i may even sell it on steam or something.
>>
File: humblebooks.jpg (672KB, 874x1079px) Image search: [Google]
humblebooks.jpg
672KB, 874x1079px
Is this worth $8/$15 for the LISP books? Probably only use one since they all cover different dialects.
>>
>>56153642
see >>56151846
>>
>>56153642
You can get most of those for free online on their websites.
>>
>>56153642
This is all new-age scripting programmer shit and is not worth your time at all.
It should have dawned on you when you saw a book called "If Hemingway Wrote Javascript".
>>
>>56153642
Only get the $1 books
>>
>>56153642
Eloquent Javascript actually looks like a real CS book, you can just tell by the cover
>>
>>56151253
is haskell a meme then?
>>
>>56153903
don't bother, it's written by a male feminist and functional programming zealot
>>
>>56154024
Definitely.
>>
>>56154114
I fucking that a great language is dismissed just because its not widely used.

haskell has god-tier syntax, type system, and is fucntional programming.
It makes you feel like a god while you're invocating it.

I fucking hate this world
>>
>>56153423
yes, but there is no better way to do it
>>
>>56154146
else if statements :0
>>
>>56153423
>>56154158
stop emoting, it's annoying
>>
>>56154115

Use an IDE. Clion is very good and makes use of GDB. Some manner of Valgrind integration was planned, but I don't think that's gotten off the ground yet. I believe some people have attempted plugins to that effect.
>>
>>56154143
Do something more than an exercise in it, though.
>>
>>56154164
>it's annoying
Why.. D:
>>
And I'd like to make it clear that JetBrains doesn't pay me, except that I get their products free by virtue of being a student. Is this bribery? Probably. It certainly works, though.
>>
>>56154115
you didn't even mention a language
>>
>>56154211
>C on Linux
>>
>>56154178
shut the fuck up you anarcho-autist-capitalist-pig
>>
I'd like to make it clear that SSPS Statistics and Matlab don't pay me, except that I get their products free by virtue of being a student. Is this bribery? Probably. It certainly works, though.
>>
>>56154255
>>56154242
>>
>>56154255
>SSPS Statistics

No SAS? I thought people here were power users.

>>56154242

Very rude, pinko.
>>
>>56154178
I thought you used emacs
>>
>>56154396

For some things, and generally on Linux systems.
>>
guys, aren't C, haskell and lisp kinocore?
>>
>>56154477
Report submitted! This window will close in 3 seconds...
>>
>>56154477
what the fuck is kino, if i might ask?
>>
>>56154326
>being a cuck
>>
>>56154530
its a patrician way for saying that you like something
"rei is kino imo"
>>
>>56154530
kino is another word for cinema/theater etc.

'pure kino' is a /tv/ thing, saying x is pure kino is saying that x is a really good movie or show or whatever, most people outside of the board use it incorrectly
>>
>>56154477
No

Only Haskell will make you reach Satori
>>
>>56154530
it's a word shitposters use to let everybody know they can't be taken seriously

I have NEVER seen a quality post using the word kino
>>
>>56154748
>>56154748
>>56154748
>>56154748
>>56154748
>>
>>56154709
shitposting is kino
its an art
>>
How do you implement pi types?
When do you substitute the value of x in the type t in pi x:t. e?

>>56154751
We're at 303 you fucking idiot
>>
File: 20160410_104201.png (72KB, 233x289px) Image search: [Google]
20160410_104201.png
72KB, 233x289px
>>56152991
>5, 10
CRLF? Maybe "newline" is 2 characters in your world because you just unwittingly unmasked yourself as an ignorant winfag?
>>
>>56154796
*in e

Nevermind
>>
Jesus Christ, and now everyone's migrated over before the bump limit. Thanks retard.
>>
>>56154978
don't worry, we'll get there soon
>>
>>56155001
very soon
>>
>>56155035
maybe a bit sooner than expected even
>>
>>56155051
maybe
>>
wheres the next thread
Thread posts: 312
Thread images: 20


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.