/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

doc.rust-lang.org/book/
doc.rust-lang.org/reference.html
doc.rust-lang.org/nomicon/
2ton.com.au/HeavyThing/
blog.rust-lang.org/2015/05/11/traits.html
rustbyexample.com/scope/move.html
doc.rust-lang.org/book/traits.html
twitter.com/SFWRedditVideos

What's the best language?

first for c++17
>gcc7 when

Object Pascal

C++ is only just getting options and variants.
Took them a while.

SPARK

They are near to useless without pattern matching tho.

Yeah, but options will still come in useful though.
Before you either had to hack in some kind of invalid state in your object and override operator bool, or return a pointer which forces you to either heap allocate or use global state.

Now you can just return an std::optional which is still miles better than the above "solutions" but yeah, without pattern matching it is still lacking.

give me a project, i need to feel useful

C

x86_64 multitasking kernel.

how about a kernel for my own ISA?
is that permissible?

Yes. In fact that's even better.
Do you already have a VM for your ISA?

get a copy of the ii irc turn vim into an irc client

yes, though the mmu isn't finished.
i'd probably work on that first.

I can move or place the text cursor with all four arrow keys or the mouse.

Next issue will probably have to be marking text.

What are you waiting for, Sup Forums?

doc.rust-lang.org/book/
doc.rust-lang.org/reference.html

*Not for the brainlets*

doc.rust-lang.org/nomicon/

Working on some javascript stuff
I hate it
I have no idea how to use it

For example, after creating an object, how do I make a base function (I don't know the proper term)? is it even possible?
Something like this:

var testObj = function(data){
this.values = [];
for(var i in data)
this.values.push(i);
}
testObj.prototype.BASEMETHOD = function(index)
{
return this.values[index];
}
var test = new testObj([1,2,3,4,5,6,7,8,9]);
console.log(testObj(3));
>>> 4

Common Lisp

Nim

EO

None of them.

Make a Sup Forums terminal client.
Targeted at Linux users.

FreeDOS*

I'm learning it right now, I keep getting aggravated where I write a function to do something simple (like remove duplicates from a list) just to find there is something like (remove-duplicates ).

I guess it's good I'm getting used to the syntax.

anyone know a good way to fix this?

...

Yeah, I feel your pain. Keep the hyperspec nearby is all I can say. You can get a local copy if you (ql:quickload 'clhs).

>see old books on pascal and cobol in my dads shelf
>pick one of them up for shits
>grab whatever cobol and pascal compiler i can find
>test book example against compiler
>errors everywhere
maybe i should stick with mathematics.

I know that feeling. Even worse (in Haskell at least) is looking at the implementation and it's basically magic.

I'm not exactly sure what these images are expressing.

I'm interested, how does one set up an efficient Common Lisp system.
I know about quickload, and how it serves as a package manager of sorts.
I have heard of ASDF, which I still have no idea what it does exactly.
Since there is multiple implementations, how do I incorporate a quickloaded library with ease into CLISP or SBCL?

I have a VM, the clock is by when the CPU ends its cycle. Since all devices run on this clock, when a device sends an interrupt to the CPU, the functions blocks, and the cycle never finishes.

>old books
are you fucking retarded?

its easier to study by reading physical ones.

When you raise an interrupt, set a flag somewhere.
At the end of each cycle, check the flag and process the interrupt if it's set.

This is how real CPU's do it I'm pretty sure. They check a pin after each cycle.

what happens is that interrupt pin is raised, and it is held by the device until it is serviced, so interrupts aren't "lost" AFAIK

>2017
>not reading the book on your pc next to open terminal

thanks that helps a lot too! Good to know that is available

I haven't taken a look at SBCL but from what I read about it's run-time compilation and it's performance it was one of the reasons I was drawn to try out CL

Is software engineering really that depressing and miserable? I'm poor as fuck and want to get a well paying job. Nature and science are cool in theory but in practice I hated doing labs. I think electricity is cool but I'm way too dumb for electrical engineering. Programming is pretty cool, conceptually, and I can also learn it from my room, which is a huge plus. I've been learning Python and C++, but I keep hearing that computer science majors are miserable and programming is a terrible career. Anyone care to offer insight?

yeah but the book becomes useless if i cant compile shit from its examples, learning programming is not like math. in mathematics you are the interpreter, in programming the computer is the interpreter.

it depends on where you find yourself

some programmers end up in a situation where they are stuck doing tickets or tasks on a system that bugs are being reported for faster than patches can be released.

others find themselves chasing clients for scraps because they tried to bootstrap themselves in a precarious way,

then there are consultants like me, who are ultimately thieves and swindlers, but live very comfortable happy lives :-D

Software engineering is a lot like science research

If you're decent you can find something fulfilling but pays like shit
or you can find something that pays well but is a shit job
If you have years of experience and connections you can find something both fulfilling and wealthy
If you're shit you can get imported from another country

What do you mean it's "held" by the device?

You can't really guarantee that interrupts won't be lost.
When the interrupt flag is raised, the CPU pushes the instruction pointer and some other stuff to the stack and then jumps to an interrupt handler.
When the handler has finished servicing the device interrupt, it then raises some kind of signal (for example, on the x86, it writes to port 0x20 and 0xA0 which are owned by the Programmable Interrupt Controller or PIC) to notify the system that it can send more interrupts.
Then the handler pops the stuff off the stack and returns to wherever it was before the interrupt came in.

Note that the PIC in the x86 doesn't maintain a backlog of interrupts, so if you wait too long before sending the signal, you can miss interrupts.

In most cases you can avoid missed interrupts by just simply having the device wait for a response of some sorts, or the device could contain it's own queue of events like the keyboard contains a ring buffer of keystrokes.
But for devices like the timer, you just have to simply process the interrupts in time in order to not miss them. That means you have to be very careful about disabling interrupts (for atomicity) and make sure you only do it for the shortest amount of time possible.

It's shit I know, but that's how it is.
I'm not sure if I understood your question properly, but I hope that answered it.

Nowadays there is Roswell (check github) which can install a CL setup for you automatically. You can use quickproject to set up your own projects that you can load with quicklisp. Quicklisp makes use of ASDF (another system definition facility). As far as deploying your projects, there are a few options. You can distribute a FASL file which is what gets produced when you compile a lisp file. You load a FASL with (load "filename.fasl"). Of course, that means a lisp implementation has to be installed on a user's system, which might not be what you want. Buildapp takes care of this problem, but will likely produce large binaries since the entire lisp image gets saved. ECL solves this problem by compiling to C.

ssh 2ton.com.au

2ton.com.au/HeavyThing/

connect as new user
press ctrl-j
join channel g

what i meant is that the interrupt line is held by the device usually until it is serviced, not that you can't lose an interrupt if it stops holding it while you have interrupts disabled

like that's at least partially correct right?

>thinking its about time I should learn a bit about programming
>finally decide to take an intro course
>excited to begin
>this should be fun
>first few weeks are kind of easy and fun, simple data types and operators
>hit week 5
>find the fifth prime number between the 20th and 67th value in this list of lists and express it as a square root of its index value times the 4th root of the third value of the seventh list

Is there HONESTLY, any PRACTICAL application for the convoluted fucking prime number exercise problems? Do people honestly fuck with prime numbers out in the real world when they are programming that much? I was doing so well until they decided to turn this shit into a brain teaser. Thinking about dropping the course and just saying fuck it

What's a null byte injection?

this is just a suggestion which should probably be on /qa/, but I think there should become a programming board specifcally for these threads. Also Lainchan has that and it is wonderful.(even though I don't go there I just browse their irc channel)

Rust and Idris are good stepping stones. By themselves they are interesting enough to be played with but a synergy will be amazing.

>like that's at least partially correct right?
Yeah, but why does your function block? and which function?

i've been just using an .sbclrc file and I put some hotkeys in vim to run whatever lisp code is in my buffer through to it. simple enough to try out code and get a response but still be able to go up lines and edit stuff, etc

I would post a link to a helpful page but with two neurons to rub together you should be able to find it yourself.

the function that interrupts the cpu

cont.
When programming, my setup is as follows: emacs + SLIME, paredit, quicklisp, and a local copy of the hyperspec. Nothing too fancy. My .emacs is a hodgepodge of different snippets found on emacswiki or github:
;for paredit and other interesting things
(require 'package)
(add-to-list 'package-archives
'("melpa" . "melpa.org/packages/") t)
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "elpa.gnu.org/packages/")))
(package-initialize)

(setq inferior-lisp-program "sbcl") ;change to whatever implementation you use
(add-to-list 'load-path "/usr/share/emacs/site-lisp/slime/")
(require 'slime)
(slime-setup '(slime-fancy))

;you may not need this
(setq slime-contribs '(slime-fancy))

(autoload 'enable-paredit-mode "paredit" "Turn on pseudo-structural editing of Lisp code." t)
(add-hook 'emacs-lisp-mode-hook #'enable-paredit-mode)
(add-hook 'eval-expression-minibuffer-setup-hook #'enable-paredit-mode)
(add-hook 'ielm-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-mode-hook #'enable-paredit-mode)
(add-hook 'lisp-interaction-mode-hook #'enable-paredit-mode)
(add-hook 'scheme-mode-hook #'enable-paredit-mode)

;miscellaneous stuff
(setq
backup-by-copying t ; don't clobber symlinks
backup-directory-alist
'(("." . "~/.saves")) ; don't litter my fs tree
delete-old-versions t
kept-new-versions 6
kept-old-versions 2
version-control t) ; use versioned backups

(setq-default indent-tabs-mode nil)

All it should do is set the flag and return.
The device will be serviced later from the interrupt handler.

i feel autistic because i got btfo by 3 questions on K&R's bit manipulation section and now i seriously want to learn assembly before going any further

It's much easier to visualize bit manipulation in C than in assembly.

Professor gave us an extra credit assignment to create our own semaphore that can work for all system processes. Is there some way to do this?

>Is there some way to do this?
Yes.

i want to gain a better understanding of low level through learning assembly. i don't actually want to program in assembly. my university doesn't offer any asm classes, i've literally never done anything low level in my life

I guess I better do some research

What course user?

They're all trash, they don't actually teach you much outside of syntax

Just read SICP and teach yourself. You should be able to figure it out.

Any C# programmers here? Can you list a few of your first practice programming projects written in the language? I'm learning it on my own from a book but want some ideas for projects to apply my knowledge to. Can be with or without WinForms.

Swift

texteditor
game
chat
crud webapp

go

Just do standard programming challenges. Once you have commandline programs down, go back and try adding in a GUI through winforms. Once you've done that, try and tackle WPF.

God fucking speed when you get to WPF.

Rust

this

Ideaguys, feed me some ideas for "A Small World"

I just got into WPF a few days ago after making lame stuff in WinForms for a while and god damn I love it. It was pretty tough to get into at first but it's really flexible. I can actually make fairly complex good looking UI now.

The difficulty curve shoots into the stratosphere once you start dealing with data bindings and Model-View-ViewModel design practices.

Or maybe it just "clicks" for you, which if it does then you can make a shitload of money specializing in WPF UI

Thank you very much

what is it?

post lines which allow for running current lisp code

Nasm.

>zero-cost abstractions
>move semantics
>trait-based generics
Some kind soul please, explain me, in plain english, what this mean.

>>zero-cost abstractions
Abstractions with zero cost

>>move semantics
Semantics for moving

>>trait-based generics
Generics based on traits

Yeah I bet. I haven't really gotten that deep into it yet but I'm hooking up an SQLite database to a listbox of items to display certain properties, which was really simple. That MVVM concept though, I haven't bothered to look into that yet. WPF devs make a shitload of money huh? That's surprising. I might look into that some more.

>zero-cost abstractions
Abstractions that don't add any time/space overhead.

>move semantics
You can shallow copy a value to a new location but you're not allowed to use the old value any more. You can deep copy a value to keep using the old one. This is important for reasoning about ownership.

>trait-based generics
You can constrain your generic types to implement traits (kind of like interfaces) for static dispatch.

>>zero-cost abstractions
blog.rust-lang.org/2015/05/11/traits.html
>>move semantics
rustbyexample.com/scope/move.html
>>trait-based generics
doc.rust-lang.org/book/traits.html

WPF devs make a little more than a "standard" dev at a company, but it's more like you're guaranteed a job and will be pampered like royalty.

Any good simple app project ideas that might be marginally unique?

I just got my smart phone repaired after a year of it being broken and I want to get into Android dev.

Ah okay. That sounds nice haha

Solve P vs NP. No one has done it so far!

Simple

PCI defines a "programming interface" type for most device classes to support generic drivers.
Where can I find what these interface types mean?

Flappy Bird

Idea: 2D game engine in S7 Scheme, similar to Lua's Love 2D.

Isn't it solved?

Esoteric languages don't qualify, son.

You are esoteric.

N = 1

CS student faggot here learning Java

Project due in two hours and I'm afraid Sup Forums is the only place I can go for this. This loop is in main and is supposed to throw up the options for the user after it takes their input, processes it, and does its thing. The problem is that when i tries to loop, it has a NoSuchElementException for the line where the scanner is turned into a string. I've had a couple people look at this and they had no idea either. Can someone please help me fix this? I'm sure it's some really stupid thing I've got to be missing here.

>read SICP
>First chapter is nothing but abstract math exercises and examples

use nextInt

my fuckig eyes are on fire

still gives the same error
from the spaghetti code or the rainbow vomit syntax coloring