/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

learnxinyminutes.com/
youtu.be/K2rvoCQksG8?t=1h14m5s
github.com/sbcl/sbcl
docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html
twitter.com/NSFWRedditVideo

Firsr for Lua JIT

Anyone else here learning to program because they're a friendless NEET loser and have literally nothing else to do all day? Making lines on a screen move the way I wanted them to makes me feel accomplished for a few minutes before I remember how much of a useless failure i am and how much of a joke my life is. Also it helps me sleep at night because at least i was """productive""". I mean, I was gonna sit there staring at a computer screen all day anyways, at least this way i'm making some kind of progress, right? Right?

...

shitboards. Let me rephrase my post to be on topic. What programming project will make me employable?

Business idea: OCaml with good syntax

Loli rape simulator.

>What [...] will make me employable?
A degree

C influenced languages get an automatic F in my book.

Depends what kind of dev you want to be lad.
>front/back/full stack webdev
>Front/back/full for non-web
>embedded systems
>network
And then theres a whole other branch for games.

I took some classes for c++ and java almost a decade ago and now I want to get back into programming but have forgot most of what I learned. What books should I get for C, C++, Java, Python, and Bash?

why cant I just learn a single language and when I need to program in another language I just remember how I did it in my learned language and just google "how to x in x"

That's probably what most people do. A lot of programming knowledge is universal.

start with the GNU C reference. Then read the linux programming interface and make some toy system programs

>GNU C

After a while you won't even be googling "how to x in x," you'll just be googling "x syntax cheat sheet" and "x standard library"

how would you handle struct alignment in c++ in 32/64 bit code? looks like making all members the same size is the best way but shit stops working when you use pointers, should i store everything as 64 bit or what? storing pointers in uint64 on a 32 bit systems looks like a suicide

Are you passing structs raw between programs or some shit?
Don't be stupid: serialise your shit properly.

no, passing just between dll files. these dlls can be compiled by different compilers/versions and i want to avoid that one dll can have a different struct size than other

Why the hell are you trying to link 32-bit and 64-bit code together?
That's just not going to work.

(You)
(You)
(You)
I for a fact was correct the compiler wasn't correctly configured and it had literally nothing to do with my code.
Left is my .pro of the QTCreator project which should be doing the same as what i did manually on the right side
(don't mind the error at execution it tries to connect to a not existing database).
This also means that the way i am trying? to use qmake is wrong though i don't get why because this is what i am supposed to do to add flags to the compiler

no, the problem is
struct{
char* ptr;
int64 value;
};
but this compiled on gcc and vs can generate different struct sizes because of paddings, the solution could be
struct{
uint64 ptr;
int64 value;
};
this guarantees the same struct size on every compiler, but this is dirty when compiled on 32 bit systems, thats what i am talking about

>but this compiled on gcc and vs can generate different struct sizes because of paddings
No they wouldn't.

Also, I forgot to mention:
Good fucking luck trying to link C++ code from different compilers together.

yes they would, exe compiled in gcc and dll compiled in vs could not work together because they align members with different padding, program would just crash

it doesnt work for you because you assume everything is padded the same way, thats where you are wrong kiddo

>C
K&R
>C++
wait until you know C
>Java
Thinking in Java, by Bruce Eckel
>Python
Learn python after C, you just need google and stackoverflow
>bash
About 2 hours max

This website has good basic introductions to the syntax of basically every language
learnxinyminutes.com/

Also you should learn Scheme from The Little Schemer and SICP. It's my favorite language and it's a lot of fun.

The alignment restrictions in x86 for a pointer is 8 bytes (the same as its size).
There is no reason that a compiler would insert padding between those members.
However, there are MANY fundamental flaws of C++ preventing you from doing what you're trying to do.
Give up.

>x86
x86-64 I mean.

This seems like a terrible fucking idea. Learn proper IPC.

except pointers are 4 bytes on 32 bit machines, and compiler would add padding

You can't fucking link 32-bit and 64-bit code together in the first place, idiot.
That's a complete non-issue.

Reminder that programming is a means to an end. A tool.

If you're not already well-versed in another useful topic, you're the definition of a code monkey.

what about matlab

Reminder that mathematics is a means to an end. A tool.

If you're not already well-versed in another useful topic, you're the definition of a number puncher.

im not talking about mixing 32 and 64, the issue is that the first example in would work on x64 perfectly but its not guaranteed to work on x86 because on compiler added padding and other not

Who the fuck cares? Why is it so important?
Chuck an alignas on it and shut the hell up.

Not sure if this was intended to be ironic, but it's also true.

fuck off nigger if you have nothing better to add

Matlab is a very good tool for mathematical programming. Personally, I'd rather use Python or Scheme for that purpose, but matlab is a fine tool (matlab is actually built on top of python and numpy iirc).
It's definitely something to be familiar with. A lot of colleges are not allowing their students to use graphing calculators, and are instead using matlab in classrooms. Most academics I know love it, and most engineering types are at least neutral to it (they'd use a sliderule if they could though), so it can't be that fucking bad.

GCC has the packed attribute. Have you tried that?

Working on a cyberpunk imageboard, 4kev.org

>mathematics
>number
What did she mean by this?

What? Are you implying that mathematics does not contain numbers?
"Field punchers" just doesn't have the same ring to it.

we need to go 128-bit

why

you fucking retard

128-bit
wider

We're nowhere near the address space limitations of 64-bit.
There is very little to be gained by going further.

>dude 4k
>dude 5k
>dude 8k lmao
Its the same shit.
R&D is fine and should never stop.
But consumer 128b hardware is not fucking needed right now. We need to completely phase out 32b first.

who says the address bus needs to be 128bit?

The only languages which should have GC are functional languages. Prove me wrong.

are you guys seriously this dumb or are you pretending to be retarded

128-bit
wider
OP HAS A PIC OF HIDAMARI SKETCH

oh, you were making a reddit joke.
that explains it.

so, when you guys first started out coding, how long would it take you to do a practice problem out of a book? like a math sequence like a fibonaci or collatz?

>Prove me wrong
Unnecessary. You used the word "should".

when i first started trying to code, i was not able to compile an hello world program for about two years. no, i am not joking. yes, i invested hours every day on trying to understand what the fuck coding was about.

now i don't have any problem with any kind of project i want to make, and i use daily programs i have made to help in my language learning, including a spartan e-reader that has the only purpose of maximizing language learning efficiency at the expense of other desiderable features

>like a math sequence like a fibonaci or collatz?
These types of things are useless, and teach you absolutely nothing.

Anything that shows you aren't a shit. I am making a decent salary for where I live and most of my experience is hobby stuff. I have 6 months work placement from school, a two year diploma, and everything else is personal life hobby projects.

Kys pajeet

"left fold in c#"

Apparently it's aggregate.

>JBlow doesnt believe in DRY
Jai C O N F I R M E D DOA

link?

jai will literally save programming, if you don't like what jai does you can basically make it become a completely different language thanks to the best metaprogramming in computer history, lisp can suck dicks

youtu.be/K2rvoCQksG8?t=1h14m5s
Jai is not going to do anything but be another ded language the creator becomes delusional about.

Seriously though where all the cute euro traps.

Yeah, the functional part of C# tends to annoy people with a functional background, but I believe the motivation was to make the LINQ functions easier to understand for those with a SQL background, and those who otherwise don't have functional/set knowledge.

Personally, I find them easier to read and understand what they do, but I'm coming from the latter camp here.

Yeah I understand that, and I don't really get upset about it. It just means doing a bit of documentation checking.

>Jai is not going to do anything but be another ded language the creator becomes delusional about.

the thing jai has and no one language ever had is the metaprogramming.

you want a borrower like rust? you can. you want garbage collection? ok. you want pure functions? done. dependent types? sure. you want to enforce your style guide? you can make a metaprogram that aborts compilation if you don't follow it.

this is just not comparable to anything else.

how do I use code format in comment again

>a language with no std and anyone can inject their own bullshit
Wow, because that worked so well for Lisp, and is currently working great for haskell.
And jai already has dependent types, albeit in their current form the syntax is disgusting and hes unironcially using $T, $K

good thing im also a pro gamer and a good personal trainer in the gym!

read the rules

Lisp is a ball of mud

And if he goes through with INFINITE META, so will jai.
A good language cannot be X & Y & Z & A with hacks. You choose one or the other.

Also why would you need metaops for pure functions?

Lisp is the most powerful programming language.

Being a ball of mud is not a bad thing. Lisp is a ball of mud because the more mud you stick on it, it's still Lisp. You can add OOP and functional programming, memory management, whatever you want, and it still looks like Lisp. You can implement every data structure you can imagine through lists.
Lisp is a ball of mud, in contrast with say APL, which is more like a diamond. It's very pretty and has good uses, but if you tried to stick more diamonds on it, you'd have a weird cluster of diamonds, held together with adhesive. APL does not lend itself to extension and adaptation.
I've not taken a close look at Jai, but it might have similar qualities. A language that does everything will either be incredibly simple like Lisp, or incredibly complicated, like say Scala.

>lisp has no standard library

No sane person wants a language that can do and be anything. It has no focus or hope of staying usable, and will always be inferior to specialized languages.
And god help you in trying to contribute to someone else's repo, say they go nuts and it's a whole other world just to build it.

>that no true scotsman
Opinion discarded.

Fuck off retard, Lisp has all the standard shit like arrays, strings, and a multitude of functions to compliment each type and constructs (OOP, Conditions, Packages, Streams)
>a whole other world to build it
Highely unlikely. Kys.

>Highely unlikely. Kys.
With the claims of
>you want a borrower like rust? you can. you want garbage collection? ok. you want pure functions? done. dependent types? sure. you want to enforce your style guide? you can make a metaprogram that aborts compilation if you don't follow it.
Its not that unlikely.

>No sane person wants a language that can do and be anything
Common Lisp and C++ would like a word with you. It's also interesting to note that the major modern OOP+imperative languages (Java, C#, C++) have been working to add better support for higher order functions, lambdas, and other functional principles.
>always be inferior to specialized languages
I can think of a few specialized languages that do very well for niche tasks, such as SQL or regular expressions. C could even be considered a specialized language, and it does very well for itself in resource constrained environments, but I wouldn't say that a specialized language is always better than a flexible language. Java (before it gained generics, functors, lambda's, and many of the other niceties we appreciate today) was fucking terrible, because development in Java mandated OOP for even the most minor tasks.
>And god help you in trying to contribute to someone else's repo
That's why communities develop idioms. C++ has them, Python has them, Common Lisp and Scheme have them. People figure out good ways to do things, and stick with those good ways, but that doesn't mean that these idioms need to be enforced by the language. If someone's project is a fucking mess, that's because they're bad at organizing a project, not because their language is bad.

>Java was fucking terrible
>was

>That's why communities develop idioms.
Please follow the reply chain.
His whole point was people can just enforce their own entire standards.

Inane dpt trendie comment.
Contribute to the discussion with talking points, moron.

you sound like a virgin lol

>whole other world just to build it
have you even looked at jai? one of the selling points is that you don't even need a build system. any project using jai just needs to point the compiler at a single jai file and that jai file does all the work.

try to contribute to a repo in any other language without a standard for projects, like C/C++, then tell me how easy it was to build it. I can think of a dozen build systems off the top of my head, from the simplest makefile/bash script to batshit insane like bazel

Not him but Java is still pretty much the same as it always was, new features like generics and lambdas are all just syntax sugar for the same old shit we used to do with casts and anonymous classes.

is jai the new thing to shill in this thread
i didn't receive the shill memo

Lisp is a body that bends to the will of time.
Realy important shit like OOP, GC, and Conditions, get added to the standard, and no-one can implement it in Lisp, you'd have to write your own Lisp.

Ignore Sup Forums memes for a moment, modern Java with functors, an REPL, and generic programming is perfectly suitable for business applications. The only things it lacks that C# has that I can think of are easy C interop, something as good as ASP.NET, and properties
You're wrong, a lambda does not create an anonymous class, and generics provide compile time type safety.
And what is wrong with that?
Isn't CLOS implemented in Common Lisp?

>Isn't CLOS implemented in CL?
Nope.

Ok so I got this project in java to make a binary search tree with duplicates so each node is a linked list of items which are considered to be duplicates
I have to implement all the methods of the standard binary search tree class to this new class im making
the normal insert is:
protected BinaryNode insert( AnyType x, BinaryNode t )
{
if( t == null )
t = new BinaryNode( x );
else if( x.compareTo( t.element ) < 0 )
t.left = insert( x, t.left );
else if( x.compareTo( t.element ) > 0 )
t.right = insert( x, t.right );
else
throw new DuplicateItemException( x.toString( ) ); // Duplicate
return t;
}


I tried to make it with a linked list and it didn't work, the comapareTo method is said to be not found

protected BinaryNode insert( LinkedList x, BinaryNode t )
{
if( t == null )
t = new BinaryNode( x );
else if( x.element().compareTo( t.element.element() ) < 0 )
t.left = insert( x, t.left );
else if( x.element().compareTo( t.element.element() ) > 0 )
t.right = insert( x, t.right );
else
throw new DuplicateItemException( x.toString( ) ); // Duplicate
return t;
}


There was this on the standard binary search tree class declaration
public class BinarySearchTree

let me introduce you to templates in c++

Let me clarify, it depends on the implementation, and stuff is mostly written in the Daddy language for efficiency purposes.
I'm not well versed in CLOS, though.
It seems more likely that CLOS be implemented in the Daddy language.

I'm just looking at SBCL and I don't see CLOS anywhere in the very small body of C code they use.
github.com/sbcl/sbcl
You might be right for CLisp though, I don't know, I don't touch that Jewish shit

Regardless, I know for a fact that Scheme has many object systems, and all of them are in native Scheme.

Its already been done by that other user.

He is just spewing bullshit. CLOS is implemented in CL. Early versions of CL did not include CLOS.

In order to use the compareTo method on your LinkedList objects, your LinkedList class must implement Comparable. This indicates that your object can be compared to itself. Then you'll have to write your own compareTo(LinkedList) method, which is left as an exercise to the reader.

docs.oracle.com/javase/8/docs/api/java/lang/Comparable.html

>Realy important shit like OOP

Why don't C and C++ have arbitrary width integer types?
It would be nice to be able to do something like
int x;
if for some reason I ever needed specifically a 40-bit integer.
Being able to do
int x;
would also be helpful if I ever needed more than 64 bits. I know that's by definition more than even any modern processor can address in one go, but that being the case, it would of course be handled with invisible extra memory accesses, just like large structs, right?
I know you can do this in C++ by implementing a bigint class but it would be nice to be able to do this in C.

>What are you working on, Sup Forums?- 96 posts and 8 image replies shown.

a twitter client for emacs that doesn't require an account using splinter

include stdint.h silly