/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: 1500270534860.png (540x698, 572K)

Other urls found in this thread:

clojure.org/
clojurescript.org
braveclojure.com
4clojure.com/
parens-of-the-dead.com/
clojurians.slack.com/
clojureverse.org/
clojure.in/
youtube.com/user/ClojureTV/videos
clojure-conj.org/
cursive-ide.com
lighttable.com
nightcoders.net
sekao.net/nightcode
sekao.net/lightmod
cider.readthedocs.io/en/latest
edx.org/micromasters/software-development
edx.org/course/cs-all-introduction-computer-science-harveymuddx-cs005x-0
learnxinyminutes.com/docs/clojure/
youtube.com/watch?v=rFejpH_tAHM
clojure-toolbox.com/
youtube.com/watch?v=oU_A4eKBRvY
sarabander.github.io/sicp/
sicp.moe/
twitter.com/SFWRedditVideos

Creating reusable boilerplate in OOP

I don't think this is remotely relevant.
The raw statistic of "code reusability" is basically irrelevant considering that if 90% of your code is boilerplate and you're able to copy all the boilerplate then you've managed to reuse 90% of which 100% didn't need to be written.
Additionally, let's consider a language like C where the whole point of writing it is either to work close to the hardware (embedded) or to be able to tweak every last bit of code so that you can get good performance and have smaller binaries.
If you write something like glib/gobject you can have 10000s of lines of code which are "reusable", except it's all a waste of space, you have written generic data structures which likely perform worse than if you had just used a higher level language to begin with. Having lots of reusable code in a language like C just suggests that maybe you used C for the wrong job.

The time for you to learn clojure(script) has come, user.
Learn what is considered to be the ultimate programming language
and be part of the most prestigious programming community.

clojure.org/
clojurescript.org

Learn
braveclojure.com
4clojure.com/
parens-of-the-dead.com/

Community
clojurians.slack.com/
clojureverse.org/
clojure.in/
youtube.com/user/ClojureTV/videos
clojure-conj.org/

IDE
cursive-ide.com
lighttable.com
nightcoders.net
sekao.net/nightcode
sekao.net/lightmod
cider.readthedocs.io/en/latest

Attached: braveclojure.png (900x900, 104K)

what programming language should i learn for first time programming ?

Haskell

Scheme!

Does it make any use of thisKindOfCamelCase?
I can't stand thisKindOfCamelCase and when considering languages to learn I only pick ones which do not use thisKindOfCamelCase in the standard library (or in the actual language itself *cough*swift*cough*).
And if it uses ThisKindOfPascalCase then does it do anything StupidLikePretendingThatXmlIsAWord?
If the answers to these questions are no, and clojure uses primarily lisp-naming-scheme then I'll happily look into it.

logo then turbo pascal then some assembly language then c

This, unironically. Although you'll be disappointed with the rest of programming since none of it is as fun as scheme was to learn/use.

do the tutorial on code.org then
edx.org/micromasters/software-development
or
edx.org/course/cs-all-introduction-computer-science-harveymuddx-cs005x-0

after this, you will have a base solid enough to go on your own.

Attached: advanced_data_structures.png (805x657, 327K)

Good luck convincing OOPsies to understand. They're in too deep. Most of them don't even understand the basics of FP. We've had people argue that cons must copy the whole list in case another thread mutates it and therefore it takes O(n) time and therefore FP is slow.

only when you interop with java

Java is a blight on the industry.

here is a quick grasp of clojure
learnxinyminutes.com/docs/clojure/

Is there any reason to interop with Java?
Is it something I would find myself doing often if I wanted to get something done quickly?

based and redpilled

clojure is implemented on top of the jvm, java ecosystem is vast and oracle's hotspot is the state of art of programming language virtual machine. because of this, clojure has access to everything you would need.

I really like this talk
youtube.com/watch?v=rFejpH_tAHM
>readability is, by my opinion, the most important feature of a programming language

Attached: Untitled.png (934x608, 129K)

So I'll be having to write a lot of thisKindOfCamelCase. I guess I'll pass then.

I really like you user~~~

Attached: 1474884215155.png (336x523, 91K)

it would be rare actually, clojure has a big ecosystem on its own.

clojure-toolbox.com/

Then I might look into it at some point.

Reposting from last thread because I'd like to make sure I'm getting the right idea.

I'm trying to understand the semantics of some constructs in Scheme. Please tell me if I get any of the following wrong - especially the terminology, I'm not familiar with much of this.
A define, a let, a lambda expression or any other named binding names a cell and associates it with a value. Inside an expression, a symbol can be used to select a cell and retrieve the value it refers to. When a symbol is used the interpreter selects a cell according to lexical scoping rules and uses the value in that cell.
set! mutates a cell, causing it to be associated with a different value. The value itself is not mutated, all values are immutable.
Inside a closure, captured cells are the same as those in the containing scope. So with code like this:
(define (foo bar)
(define (closure-1)
; something that mutates bar
)
(define (closure-2)
; something that uses bar
)
Applying closure-1 will change the value reference within the cell referred to by bar within closure-2, because bar refers to the same cell in both. However, whatever cell was used to provide the value for bar when foo was applied will not be mutated, because that is a distinct cell and a value reference was copied from that cell into the newly created "bar" cell when the procedure was applied.
Symbols inside an eval'd expression are just strings, and they are bound to cells within the lexical environment of the eval when they are eval'd. So code like this:
(define foo #t)
(define (bar)
(define foo #f)
'foo)
(eval (bar))

Yields #t.

>months later
>still posting islamic propaganda in the op
Where have all the cool anons gone?

Attached: 1500410448712.jpg (640x480, 24K)

They were too worried with their retarded OOP vs. FP rivalry to even notice. I hate nu-/dpt/!

OOP is islamic propaganda.

I'm
Replying to:
Windows 10. The issue seems to be intermittent and has disappeared for now, but it's part of the process to port a Windows 7 application.

>What are you working on
winged jet engine robot-kamikadze for kill aircariers or just tanks
youtube.com/watch?v=oU_A4eKBRvY

>he hasn't read SICP yet

h-here f-for you, a-user
sarabander.github.io/sicp/

Attached: sicptakethis.jpg (1920x1080, 484K)

If I know and have experience with other languages already, does SICP teach anything besides scheme?

>If I know and have experience with other languages already, does SICP teach anything besides scheme?
Functional programming.

sicp is not about scheme, it's about abstraction then implementation of the said abstraction.

Alhamdolliah today we learnt some ReactJS and have been productive.
I hope you all guys get something done today whatever it is, you can do it!

>tfw started reading but never finished because can't focus on it unless it's of solid paper
At this rate I'm gonna be blind before I'm gonna be wizard.

Attached: 1492206849286.jpg (700x849, 280K)

can you explain the sicp snake meme to me

Attached: 1338542333128.jpg (2048x1536, 123K)

Trying to study c++.
The problem is I can't find any material related to hardware manipulation using c++.
Could any of you guys please recommend me some good books/tutorials on the subject?

Tunnel vision here. I haven't been able to read a book since grade-school. I only do well with digital text because it can be condensed horizontally, or more generally, you can modify basically any aspect of the text.

You might want to devote some time to finding out what your eyes prefer on your screen. Calibrate the display, play with font rendering settings, change the font face, the kerning, the weight, sub-pixel patterns, etc.
Just basically twist knobs until the text looks good to you yourself. It might make it easier for you in general. Or not lmao

What is the technical purpose of pointers in not OOP languages like C?

Remember when /dpt/ couldn't average two ints in C

Reference a point in memory, it's arbitrary, on purpose. You can do whatever you want with them.

don't

it's not specific to sicp, it's the /prog/snake from the defunct /prog/ textual board.

>The problem is I can't find any material related to hardware manipulation using c++.
What does this mean?
What do you want to manipulate?
Most MCUs deal with peripherals with memory mapped registers. x86 does communications via ports, interrupts and memory mapped io, arm is just mmio and interrupts.
If all you want to learn about is how to write higher level code to work with these things then your best bet is to use C instead of C++ since C++ is going to get in your way more than it will help.
Or do you want to talk to a USB device from your operating system? Then it once again has nothing to do with C++ but rather with operating system interfaces and libraries which abstract some of the details (e.g. libusb).
Pointers have nothing to do with OOP. In non OOP non FP languages they're used to do anything you can dream of, in OOP languages they're used to shoot yourself in the foot more effectively.

>SICP
snakes in computer programs?

Attached: Naamloos-2.jpg (600x600, 34K)

eval apply

Attached: SICP 6.png (566x650, 318K)

I will give it another try. Stocking up on carrot juice from tomorrow, I heard it's good for the sight.

I see

I thought runtime abstract object inheritance requires pointers

sicp.moe/

>I thought runtime abstract object inheritance requires pointers
Sure, but you don't see it. It's an implementation detail. It's not the same as "using pointers" because for all you know it could be implemented in some completely unusual way and you would never know.

What is C++?

Real shit, I was reading about Vitamin A and Lutein the other day. I grabbed some because "why not". And I think it is having an impact, however, I'm also doing eye exercises at the same time, so it's hard to say if it's either, or both. In addition I take other shit that may impact it. I haven't isolated it yet.

My problem seems to be something with coordination more than anything else, not sure of your own issue(s) or if it would help. But I suggest you explore the space, it's worth improving vision if you can, imo.

C++ still hides these details from you.
You're not using pointers, you're using a language which handles some pointers behind the scenes.
You might have a pointer to a class instance but this is distinct from OOP.

Whatever C points to internally, is incremented and returned. /s

c++ is a name, not a piece of code.

If you're familliar with Go, The interface types are probably a good example of using pointers to underneath but being a distinct abstraction from just a pointer to a struct, because it doesn't have to be that, it could change.

Yes, another example of something which you can implement with pointers in a language like C but which is distinct from "using pointers" because the "pointers" which may or may not be used behind the scenes are not exposed.

a concept and its implementations are different things.

When did I say otherwise?

I was recommended to eat raw egg once by my p.ed teacher back in high school thought it didn't feel like it was making any difference, my problem is that my eyes get tired easily, if I read normal paper books for 30 minutes straight, my vision goes down by 60-70% for the rest of the day, sometimes after long reading sessions the next day I have almost always a blurry eye when I wake up and it doesn't go back to normal for a couple hours, I see even flashes of light, looking it up I found it's related to retinal detachment which in my case is definitely genetic, considering both my parents wear glasses. I feel comfortable with screens but probably due to concentration issues I can't really get into reading on them, right now I'm using a 43" tv as pc screen, one and half meters away from me, it's the best setup I managed to find after trying many things, it doesn't hurt in the least.

you can not have interfaces in c. not even objects.

Thanks for the answer.
I programmed a lot in very high level languages (like java) and I wanted to try something related to embedded and hardware programming, so I thought that c++ would be a good start.
I started reading Bjarnes Programming with c++ book but it doesn't seem that it is going to cover embedded/hardware programming with c++.
Is there some sort of "babys first embedded programming book" out there?

Refactoring legacy code to enable a third path but the legacy code uses boolean checks for the existing two paths, so I am basically rewriting the entire application to allow for multiple paths.

God I fucking hate pajeets.

Yes you can.
Are you fucking stupid?

They may not be a language feature, but that doesn't mean you can't have them.
Additionally, objects are already a concept in C. They're just not the OOP kinds of objects.
I literally learned the basics of embedded development by buying some AVR microcontrollers and a cheap AVR ISP (in system programmer) and reading the manual and writing some C with avr-libc.
But at the same time avr-libc hides a lot of the details from you anyway (nothing important so don't worry). The next step I took was to write bare metal C for a Teensy 3.2 (freescale MK20DX256 chip).
So really the best books are a C book to learn C (The C Programming Language (2nd Edition) or C Programming: A Modern Approach) and the programming manual for the MCU you want to use.
And if you want to learn how to write operating system kernels, there's things like "Operating Systems Design and Implementation", but there are also plenty of free resources on websites like osdev.org.

Smalltalk

no, i know the C standard like my own pocket, i can tell you that there is no way to do a proper object.

I've been meditating with my eyes closed, with the intent of trying to mentally disable the processing of vision (not seeing blackness, but not seeing).
I do this, standard eye exercises, and then that again.
Rest, exercise, rest.
Standard as in: palming, crossing eyes in both horizontal directions, distance focus, rolling of eyes, focus on an object and move it around, focus on an object and move around it.

My eyes feel less hot and stressed, and I noticed they're not nearly as red as they used to be. But initially, it makes it worse. I felt eye tired for days, but in maybe 2-3 weeks it felt better in general.

Not sure if this was direct either though. I also did things like change my font recently which can reduce stress in itself, or those vitamins, or all of it. It requires some effort and may not actually result in anything. But for me, it seems to be helping.

struct base
{
struct base_vtable *vptr;
int x;
int y;
};

struct derived
{
struct base base;
int z;
int w;
};
there's your object you faggot

Troll

this is nothing else than a data type. object is the abstraction of both the data (the attributes) and the implementation of the operations set by an interface.

Thanks a lot for the answers man, read a bit about AVRs and decided I will be purchasing one and learning embedded by programming it

Why bother putting plugs on the end of electrical wires? Why put receptacles in walls? Seems like unnecessary boilerplate. It would be so much simpler, and houses would cost much less, just having the bare wires sticking out of the walls and you'd just twist the wires of whatever you wanted to turn on around the wires coming from the wall. And why bother color-coding them? The current moves in both directions in grid electricity, so there's really no positive or negative, right?

Of course, there'd have to be a switch on the wire on the hot side so you didn't kill yourself trying to hook up something to a live mains wire. And which one's hot? better put a switch on both sides. Oh, and if you ever hooked up one A/C-consuming device the opposite way from another, and touched them both at the same time, you can kiss your ass goodbye. That's not to mention what would happen if you got a few other wires crossed and tried to run your computer or TV off of 220V, or hooked up the grounding wire of the device to a supply wire from the wall.

Electrical engineers do so for a reason.

Interfaces, classes, namespaces, various conventions etc all exist for similar reasons as the rules for electrical systems; they provide a clear set of rules for creating things that supply or consume the resource (in this case, the logic of the code), because if they didn't exist, every programmer of the language (and even some end users) would require a lot of esoteric knowledge about every detail of a program they were working in (as happens in FP), to understand the expectations of the language itself and the conventions used by previous programmers (and where they may have deviated), in order to make the correct decision about how to consume code previously written (even by the same programmer; do you code exactly the same way you did five years ago?)

This code is, by definition, boilerplate.

That's why software engineers use OOP, while hobbyists use FP. Stay mad.

put it in a different TU and use forward declared structs and functions.

why

then that's an abstract data type but not an object.

>be me
>wanna make something for fun/portfolio
>gonna use online json libraries
>know that python/js are best for json parsing
>wanna be different
>use java
>too far in to stop now
WHY DIDN'T YOU WARN ME Jow Forums?????

what is the difference in this case

You don't know it well enough to know that "object" is defined in the C standard.
Define "proper object" anyway.
Just a heads up though, if you do this without any guidance you're literally jumping into the deep end. I personally enjoyed this immensely but it wasn't quick and required a lot of patience.
>literally missing the point
The difference is that when an electrician installs your electrical wiring, they don't have to manufacture all the electrical sockets, or mine the copper ore or also build your house.
>This code is, by definition, boilerplate.
You don't know what boilerplate is.
>That's why software engineers use OOP, while hobbyists use FP. Stay mad.
Pajeets use OOP, software engineers solve problems.

>The difference is that when an electrician installs your electrical wiring, they don't have to manufacture all the electrical sockets, or mine the copper ore or also build your house.
Neither has a software engineer, you fucking moron. Your framework and IDE will do all that for you. You've obviously never once developed software professionally in your entire life...

an object has an interface, an adt doesn't.

a quick example of adt vs object

with an object, both the data and the implementation is hidden.
sort(Sortable o) :=
o.sort(); // you don't know which underlying implementation of sort() will be call


with an adt, you have to know which implementation to call
sort(Sortable o) :=
Type(o)
is ArrayOfInt then ArrayOfInt_sort(o);
is ArrayOfFloat then ArrayOfFloat_sort(o);
end

because of this, object favor inheritance while adt favor the operations.

it's obvious that we are talking about the data abstraction technique.

...

>language is shit
>but that's okay because IDEs deal with most of the shitness

Yep, you're fucking retarded.
Yes, there's no SANE way, but there's certainly a way, and it's not that difficult.
You're just a shitty fucking programmer who probably doesn't know how any of those even work.

>Yes, there's no SANE way, but there's certainly a way, and it's not that difficult.
prove it then

JavaScript rocks!

You have no idea what you're talking about.
Pass a vtable to a function. Fucking done.

>Neither has a software engineer,
But an OOP programmer does
>Your framework and IDE will do all that for you.
I'll try this again because last time it had funny results:
If I don't need to write the code because my "framework" or "IDE" can write it for me, why is it there to begin with, because surely if my "IDE" or "framework" can write it then the programming language could imply it.
Additionally, this just proves my point that 90% of the code "reuse" which was touted as a major benefit of OOP is just boilerplate which was auto-generated and which nobody looked at.
>You've obviously never once developed software professionally in your entire life...
Yes, obviously, except today, and yesterday, and the day before, and on Tuesday, and Monday, oh and last week, and the week before that... do I need to keep going?
You can get rid of having to do switches on a type with vtables, so I think you missed his point.

It has already been posted here

and how you are going to do that without breaking the data abstraction?
>You have no idea what you're talking about.
you don't even know the difference between an object and an adt. i advice you to read william cook's paper on the subject.

>You can get rid of having to do switches on a type with vtables, so I think you missed his point.

the attributes are not hidden at all in that example. try again.

An object is just a data type with functions that take itself as the first parameter.

>But an OOP programmer does
Except no, you're completely clueless.
>why is it there to begin with
See >do I need to keep going?
Nah, you may consider what you do "professional", but you're an amateur who only gets away with it because our industry has massive demand and greatly lacks enough skilled workforce.

Leaving bare wires sticking out of walls isn't professional, no matter what you say, and I or anybody I know would never hire you.

Stay frustrated.

Member visibility is not needed to have "proper objects".

absolutely not, you are confusing the concept with one of its numerous implementation. an object is a data abstraction technique which then allows all kind of interface abstraction techniques know as design patterns.

yes it is, it's the most important feature of an object.

With this technique you can build an interface that hides the data and the implementation.
// sortable.h
#pragma once

struct sortable;
void sort(struct sortable*);

void array_ctor(struct sortable**);
void linked_list_ctor(struct sortable**);

// sortable.c
struct sortable_vtable { void (*sort)(sortable*); };
struct sortable { struct sortable_vtable *vptr; };

struct array { struct sortable; int data[]; };
struct list { struct sortable; struct node { struct node *next; int data; } *head; };

void sort(struct sortable *sortable)
{
(*sortable->sort)(sortable);
}

void linked_list_sort(struct sortable *sortable)
{
struct linked_list *list = (void*) sortable;
// do your shit
}

struct sortable_vtable linked_list_sortable_vtable = { &linked_list_sort };

void linked_list_ctor(struct sortable **sortable)
{
*sortable = malloc(sizeof(struct linked_list));
(**sortable).vptr = &linked_list_sortable_vtable;
}

>there are people who've spent multiple decades taking part in bad faith discussions about programming languages

I'm trying to wrap my head around what you're doing, but I think I'm getting stuck at what you think (eval ...) does. eval is not as simple as you make it out to be, and even with modifications, your code will not do what you think it does in Scheme.

>Inside an expression, a symbol can be used to select a cell and retrieve the value it refers to.
No? That's not how symbols work and, at best, can only be done with very finicky usage of eval.

>you are confusing the concept with one of its numerous implementation
C supports an implementation of objects, therefore it supports objects.
>b-b-b-but this academic paper says t-
Shove it up your fucking ass, because it's meaningless in any practical sense.
>an object is a data abstraction technique which then allows all kind of interface abstraction techniques know as design patterns.
Yeah C structs and vtables allow you to do just that.

Don't you realize that C++ classes are literally just abstracts away ? That's what C++ objects look like underneath.

>it's the most important feature of an object.
least*
polymorphism is the most important feature of an object.

Does anyone here have experience in a QA role? What was the interview like? And what the fuck is a scripting test?