/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

github.com/asweigart/my_first_tic_tac_toe/blob/master/tictactoe.py
onsmalltalk.com/objects-classes-and-constructors-smalltalk-style
twitter.com/SFWRedditGifs

Thank you for using an anime image, let's all love lain.

But I already love Lain.

I'm learning how to make an operating system with osdev

Well yeah, recursion as a concept is easy, and even in application it's easy enough (actually got to use it on my own for initial window placement position based on resolution) but my professor's the type of guy who says one thing but means another AND doesn't like it when students stray too far away from what they're "supposed" to know at that point. Not exactly a killer combination when it comes to projects.

how do I display the results of a division in racket and not the operation?

(display (/ variable 4))
actually displays (16/4) rather than (4)

(display eval(/ variable 4))

?: literal data is not allowed;
no #%datum syntax transformer is bound in: 5569/300

I'm working on defeating my inability to sit down and do work. It's not easy.

github.com/asweigart/my_first_tic_tac_toe/blob/master/tictactoe.py

Get a rope and tie yourself to your chair

oh dear

>(This project is a joke.)

...

>codegenerator Initial add.
>README.md Some people don't realize this is a joke.
Huh.

...

Client wants me to convert an XML feed with regularly updated data to his database and have the changes reflect every time the XML changes
Fuck my life

I'l probably just play videogames or shitpost on /dpt/ if I do.

that should take 10 minutes tops.

git gud pleb

Are these recursive rules the same?

c -> a || a c

and
c -> a || c a

What external libraries do you use? Or are you all not invented here programmers?

10 minutes for an autist like you but I have shitposting and watching muh videos to do and work is taking away from it

Which one is more suitable and easier for simple GUI applications: Qt or wxWidgets?

I just started learning Qt after learning C++11, and the lack of standard library usage kinda bothers me. But I guess in the real world, C++ programmers don't care so much about the standard library?

pleb

Qt because you can go with QML which is amazing for quick GUI/layouting.

Let's see... an OpenGL wrapper, a library for reading native drawing tablet input, and a handful of utility libraries ripped from Github because I don't feel like doing my own Matrix math or filetype decoding.

loser

Can someone post that image with the huge list of beginner programming projects?

still pleb

cool

Which language(s)?

Prolog and a little bit of turbo pascal

Depends on the project. For the current one I'm using Boost.Filesystem, JsonCpp, Lua, Sqlite3, and SFML.

Indeed. It's written in Python after all.

still loser

I generally despise external libraries because of how annoying they make building your program - especially if they use different build systems and recursively has more external deps.
If I do use one I tend to gut it and include it essentially inline in my own sources.
But some sane libraries I so use are stb's image, vorbis and truetype.

You have to realize that the STL is not that old.
Most of it came with c++11 and was buggy shit in the beginning.
The C++ standard works slowly, where stuff like Qt and boost can react faster.

Qt is fine for making graphical applications.
It is easy to write, and mostly gets out of your way.

>Python programmers

github.com/asweigart/my_first_tic_tac_toe/blob/master/tictactoe.py

Java. I get why it gets a bad rep, but it's quite comfy.

Man, I really need to implement spline interpolation for my strokes already.

>posting the same link twice

kys please

how can a language be "comfy"?????

What's up with MSVS?
I have a project I have been working on and I figured I'd attempt to build it on Windows, and while the project builds fine on Linux using either clang or gcc with -Wall -Werror, MSVS15 throws a fuck ton of errors.

Is the C++14 support incomplete or are gcc/clang breaking some standard rules because they can figure a better way?

How can a language be comfortable? Is that a serious question? I find it hard to believe anyone who has ever used C++'s virtual function maps or Javascript's dynamic typing would ever ask how Java's implementation of object hierarchy could be comfortable.

Best library for Graphical UI in C++? GTK+? X? Qt?

Looking for a mix of good performance and ease of use.

Shape shape = new Shape();

shape.drawACircle(50,4,"Blue",50,50);

There is nothing wrong with this

I think you have to enable C++14 support manually with some project settings in MSVS. At least that's how it used to be; I'm not too familiar with the IDE these data

If it was written in {your favorite language} would it be less of a joke?

comfy is an adjective that millennials use because they have tiny vocabularies, and it denotes a generic feeling of pleasantness, nothing more.

where is it being drawn?

Qt, no question.

Could you draw a circle without using the drawACircle function?

java is anything but "comfy" though
so many inconceivably dumb design decisions that just dont make any sense
it boggles my mind how shitty java really is when you try to use it for anything serious

can someone tell a javascript scrub why the second one logs undefined

var JData = {

"2082": {
"etitle": "Wages Of Fear, The",
}
};

console.log(JData[2082].etitle);

for (var x in JData) {
console.log(x.etitle);
}
[/code}

Isn't Qt closed source?

>it denotes a general feeling of pleasantness
Yes, in other words comfortable. Man, I thought I was a grandpa, but seeing the way these 20 year olds react to each new abbreviation the younger-uns come up with makes me glad I'm not aging as fast as you.

I think I looked it up the other day and it said that it's enabled by default, and I'd like to think that's true since most of the C++14 features that my project uses work just fine, it's just these few things that throw a fit and I'm not sure who to blame.

For instance this code:
struct Value
{
unsigned min = 0;
unsigned max = 0;
};

std::vector values{};
values.push_back({5, 10});

Works fine with GCC/clang but MSVS bitches that you cannot bind an initializer list to const Value &.

No.

Keep telling yourself that. Me? I'm getting back to work. Enjoy your nested scopes.

GPL is basically "closed source" to everyone but hobbyists and linux developers.

No large company wants to touch GPL code, many won't even touch LGPL code.

Java is the king for enterprise business software no other language does it better

Qt is open source and it's dual licensed.
You can use it even comercially as long as you link dynamically.

for (var x in JData) {
console.log(JData[x].etitle);
}

C# does it better. In every single way.

It's not really the operation but the result in a factorial form, as most lisp derivates actually store and handle numbers in that format instead of the normal floating point numbers or integers.

>How can a language be comfortable? Is that a serious question?
Yes. It seems to impossible by definition.

oh

thanks man

What do people mean by "objects" in a non OOP language like C? I've tried searching for it but I just get introductions to OOP.

Probably primitive/struct instances.

What do you think an object is?
In it's simplest form, it's just a compound type that holds stateful information, aka a struct.

>Java is the king for enterprise business software no other language does it better
lol

>non OOP language like C
C is an object-oriented language.

List dataBuffer;

public void write(int data) {
byte[] bArr = ByteBuffer.allocate(4).putInt(data).array();
for(int i = 0; i < data.length; i++) {
dataBuffer.add(data[i]);
}
}


sick language bro :^)

Ask in

Only objective C. Regular imperative C is not

Outside the OOP context it's just a piece of data. Can be a single primitive or multiple primitives. Generally they assign some greater meaning to it. Like a bitmap object would (possibly) be a pointer to image data with width and height, maybe even pixel format.

But the interpretation you get from context is usually the right one. Because there's no clear meaning to it outside of OOP or where it's been defined.

>Regular imperative C is not
Are you telling me that objects are not easily implemented in C?

There's nothing stopping you from doing stupid shit in C to emulate OO features in other languages.
Those languages just hide details from you, like including a self pointer whenever you call a member function of a class.

does this look nice?
obj1.doWork(&obj, ...)

This:
onsmalltalk.com/objects-classes-and-constructors-smalltalk-style
Is not easily implemented in C.

You can implement it in C but it's not easily implemented.

C does not support inheritance or polymorphism, therefore it is not object oriented. It is object based.

Is "object" the most overloaded term in computer science?

Classes, Interfaces, Member functions, Abstract classes, Polymorphism, Generics

>OOP is an implicit this pointer
There's way more to it than that.
>C doesn't support polymorphism
It does.
>inheritance
Most 'oop' languages do this as poorly as you do it in C honestly.

>C does not support inheritance
Wrong.
>or polymorphism
Wrong.

>polymorphism
Did you have some kind of head injury in childhood?

It's certainly up there. Any of the terms describing implementation details on an abstract level tend to be very overloaded.

It's up there at least.

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

Can you name some actually useful features of OO languages?
Because stuff like operator overloading, function overloading, and polymorphism were a mistake and have very little practical application outside the narrow examples in programming textbooks.

I can't even think of a single use for operator overloading besides matrix multiplication and string concatenation.

Are you implying Ocaml programmers are aliens descending from the aliens that built the pyramids?

They actually are their ancestors.

>I can't even think of a single use for operator overloading besides matrix multiplication and string concatenation.

Well yeah there's your answer, when you need to operate on some data members but don't want to do it on the basis of individual members you can use operator overloading and it's not just useful for string concat and matrix manipulation, you could apply that to also say, color class, date/time class and such.

Function overloading is also quite useful.

This is a strictly non-Jewish thread.

Shape square = new Shape();
square.drawACircle(50,4,"Blue",50,50);


i don't like

>matrix multiplication
You don't think Matrix Multiplication gets used literally billions of times per second in almost every single video game?

>How about vector math?
>How about simplifying your libraries to make it easier for other devs to use?
Nah. Not very useful at all my dude

Why notShape shape = new Circle(50,4,"Blue",50,50);

shape.Draw();?

I Cee what you did there

>I can't even think of a single use for operator overloading besides matrix multiplication and string concatenation.

Heh, this kid doesn't even use duct tape

>Because stuff like operator overloading, function overloading, and polymorphism were a mistake and have very little practical application outside the narrow examples in programming textbooks.
None of those are OO features. I'm surprised you picked those.
>operator overloading
Yeah it's certainly overrated. What it allows you to do outside of the obvious where it lets you do math is that it often lets you express non-math things in a different structure than function calls. Trivially obvious when you look at how you write them.

I don't know enough OOP to tell you what OOP actually invents (I've only written C++ 'OOP'). The idea of not allowing direct assignment to types where the fields would otherwise be plainly visible and accessible (private vs public). The rest is just old stuff. All I can see that OOP really gives you is orienting your program in terms of the abstract concept of objects (very often pertaining to the real world, as that's how it's taught).

It's no big deal really.
c=matmul(a,b);
vs
c=a * b;
are very similar and once you're used to the function call way of doing it I don't think you'd mind.
I won't deny that it's slightly prettier to have operator overloading.

But you should probably re-read the comment because he said math operations are a valid use for operator overloading.

type Presses = Int
type Digit = Char
countPress :: [(Digit, Presses)] -> Presses
countPress p@[(dig, pre)] = foldr (\(a, b) -> (+) b) 0 p


Why is this giving me non-exhaustive patterns? it works when I only have one digit, presses pair though.

Very unclear unless it's obvious from context what it does.
Is this drawing a shape on a screen via global state or is it drawing a shape into itself. So for instance a snowman might be a few circles at different offsets and a few lines.
Seems a pity to make it a member function when it could be a more generic thing.

you use the pattern p@[(dig, pre)]
which only covers
[(_, _)]

i.e. a one element list